swing - Java JFrame Background not working. Only working when I move the actual window -
i having problems setting image background. image show when move entire window. below fragment of code including setting background image.
playbutton = new jbutton(pbi); instructionbutton = new jbutton(ibi); quitbutton = new jbutton(qbi); mainframe = new jframe("my major project"); mainframe.setdefaultcloseoperation(jframe.exit_on_close); mainframe.setsize(800, 600); mainframe.setlocationrelativeto(null); mainframe.setlayout(null); mainframe.setlayout(new borderlayout()); mainframe.setcontentpane(new jlabel(new imageicon("background.gif"))); mainframe.setlayout(new flowlayout()); mainframe.setdefaultcloseoperation(jframe.exit_on_close);
in order update jframe
, need call mainframe.repaint();
.
Comments
Post a Comment