Thursday, 15 May 2014

java - JLabel not displayed -



java - JLabel not displayed -

i have jlabel imageicon isn't showing.

public class lockscreen extends jframe { jpanel layer; jbutton signin; imageicon heartlock; string heartlockpath; jlabel heartlockdisplay; string arrowpath; public lockscreen(){ super("startseite"); setsize(700, 400); setlocation(100, 100); setdefaultcloseoperation(jframe.exit_on_close); arrowpath = "c:\\users\\saydanan\\pictures\\fürmydiary\\right_arrow.png"; signin = new jbutton(); signin.setsize(19, 12); signin.seticon(new imageicon(arrowpath)); signin.setlocation(250, 500); heartlockpath = "c:\\users\\saydananpicturesfürmydiary\\082326-green-jelly-icon-business-lock-heart.png"; heartlock = new imageicon(heartlockpath); heartlockdisplay = new jlabel(); heartlockdisplay.seticon(heartlock); heartlockdisplay.setlocation(250, 250); heartlockdisplay.setsize(heartlock.geticonwidth(), heartlock.geticonheight()); heartlockdisplay.setvisible(true); layer = new jpanel(); layer.setbackground(color.black); /*layer.setlayout(...);*/ addeverything(layer); getcontentpane().add(layer); setvisible(true); } public void addeverything(jpanel panel){ panel.add(signin); panel.add(heartlockdisplay); panel.repaint(); } }

you need add together it, , set visible.

as in:

panel.add(heartlockdisplay); heartlockdisplay.setvisible(true); panel.setvisible(true);

java swing jlabel

No comments:

Post a Comment