0

I am looking to create an ATM style application, in the sense that they will enter a pin and then will check their amount of money, etc. I would like to create a pin system and was looking to use Jbuttons for this. However, I am not too fond of the default skin for the buttons, the sort of orb look. i was wondering if there was a way in which I could apply custom skins to these buttons. I have heard of something like DefaultLookandFeel or something similar but am not sure if this is what I am looking for. I hope someone could direct me in the correct direction, thanks!

Harry Kitchener
  • 255
  • 1
  • 2
  • 8

3 Answers3

0

You can override the paint(Graphics g) method of the JButton and draw anything you want instead of it. Or, if preferred, you can call super.paint first and then draw in addition over default image. You can check the text and state of the button you are drawing by simply calling the state check methods like getText() or isSelected().

The simplest way seems to ask your graphic designer to provide button images for the different state, and the draw these images instead of the button. Just do not resize, otherwise the text may not look well.

You are right it is also possible to implement a pluggable looks and feel but for your case seems overkill.

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93
0

Depending on your situation, you could create a separate custom button class that extends JButton or simply create a new JButton.

Your code will look very similar to something like this:

ImageIcon yourImage = new ImageIcon(imageLocation);
JButton buttonDeposit = new JButton(yourImage);
frame.add(button);
Rob Steiner
  • 125
  • 1
  • 10
0

this link will direct you to the most usable look and feel libraries in java Java Look and Feel (L&F)

but to use them you should include the jar file of each one in your project library these look and feel files will manage the skin of all the component in your GUI

you should use some code in the main method. if you want i can write an example for you.

Community
  • 1
  • 1
soha samy
  • 57
  • 6