The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Does javax.swing.JToggleButton even lift ??

So, i needed a toggle button, that could do a simple things : be able to set ToggleOn or ToggleOff icons, to have a simple event listeners, like if(toggleOn) {do these things} and if(toggleOff) {do these things}. Now, in reality, JToggleButton doesnt have any of toggling functionality by default, it is 1:1 to a simple JButton ... *moderated*

Re: Does javax.swing.JToggleButton even lift ??

Hmmm. Not sure if this a real question or a rant with little/no purpose other than to vent. I expected you assumed some functionality of JToggleButton that it doesn't have, but you could have determined that on the API page.

Re: Does javax.swing.JToggleButton even lift ??

Yes, i can do it myself, but i noticed, that there is jtogglebutton too, and i expected it to have things like "myJToggleButton.setSelectedIcon(new ImageIcon("images/picture.png"));", just for toggle on/off icons, and "private void myToggleButtonToggleOnPerformed(java.awt.event.Act ionEvent evt);", "private void myToggleButtonToggleOffPerformed(java.awt.event.Ac tionEvent evt);".

Re: Does javax.swing.JToggleButton even lift ??

setSelectedIcon is not what i needed (or just a wrong name choosen by devs), i have made my own real toggle buttons. I have a few more questions, i did not google about them yet, but maybe you know the answers.

(it's optional, i dont have to do this, it would be just additional feature) in my program i'm adding and removing buttons, i know i can set icon on button by "myJButton.setIcon(ImageIcon icon)", is there an easy way to add appearance animation on my button by code, like transparency going from 100% to 0 % ? Cause as far as i now, in gif you can set only one transparrent color, and it wouldnt be high quality animation, and i dont know, if java supports things like animated png (apng), and if it does, i dont know, if apng animation could be played once every time when button appears - i have jpanel panel, i have jbutton button, and i do things like "panel.add(button, 0); panel.repaint()" and "panel.remove(button); panel.repaint();".