Freeform Swing Button Panel

If you have ever wanted to create a panel in java with buttons that can be any shape, then here is your answer

Download the source and demo

implemented methods:

  • setDefaultTextFont(Font a)
  • setDefaultTextColor(Color a)
  • setDefaultTextPosition(Point a)
  • setButtonToolTip(int a,String b)
  • setButtonActionCommand(int a,String b)
  • setButtonText(int a,String b)
  • setButtonTextPosition(int a,Point b)
  • setButtonTextColor(int a,Color b)
  • setButtonTextFont(Font a)
  • setButtonEnable(int a,boolean b)
  • setButtonSelected(int a,boolean b)

How it works

the pannel is laoded with 5 images:

  • normal image
  • highlight image
  • pressed down image
  • disabled image
  • image map

5 images

these 5 images are all that is needed to be able to have a working panel. the way the panel works if by looking
at the last "image map" image, and if u tell the pannel u have 5 buttons, it will find all the areas on that image
with color equal to (0,0,0) to (4,4,4) and identify that area as the button, (ids 0-4)

Demo Applet

This example is based on a windows media player skin I once made, you can download it here.



Source code

Where is the source code for this. You only give downloads for a .jar and a Windows Media Player skin.


all the code is also inside the jar file, just rename it to .zip and extract it