English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Is it possible to change the shape of a JButton to a circle? Also, how would you make icons show up in the Jbuttn? thanks

2006-11-11 18:52:06 · 3 answers · asked by snoboarder2k6 3 in Computers & Internet Programming & Design

3 answers

Q1: Yes, you can create custom JComponents or subclass JButton. To change just the shape, override the paintComponent() method. You will need to understand how to use the Graphics (and perhaps Graphics2D) APIs to do this nicely.

Q2: Most Swing components support images as content (except the text components). Icon support is through the Icon interface, mainly done by using the javax.swing.ImageIcon class (handles basic image file types, such as jpg, gif, png).

button.setIcon(new ImageIcon("file.gif"));

You can also change the icon automatically on rollover (hover), press, and selected by calling supporting methods on the JButton (see the Javadocs).

2006-11-13 06:03:18 · answer #1 · answered by vincentgl 5 · 0 0

its to not problematic to do this you only set the image t null. yet whats better is while you're making it gray out. you're able to do it comparable way particular there's a function in the inconImage type, dont have it with me on the mo, email me and ill look it up later.

2016-10-21 22:53:53 · answer #2 · answered by ? 4 · 0 0

not unless you rewrite the jar file

2006-11-11 19:00:14 · answer #3 · answered by VzjrZ 5 · 0 0

fedest.com, questions and answers