swing - Buttons and JLabels in Java -
i trying write java program which, when click button, hides button , displays image. have made button disappears label not appear. here code:
final jlabel label = new jlabel(image, jlabel.center); label.setalignmentx(0); label.setalignmenty(0); label.setvisible(false); label.seticon(image); final jbutton button = new jbutton("click"); button.addactionlistener(new actionlistener(){ @override public void actionperformed(actionevent e) { button.setvisible(false); label.setvisible(true); } });
place items on jframe , revalidate() on jframe changes displayed.
Comments
Post a Comment