java - JLabel and icon mac issue -
so remember 2 years ago had issue displaying icon on label on mac.
i've tried again year whilst working on project , still have same issue. check code works on different computer? either mac or windows know code works , if has idea why doesn't work on mine let me know!
all happens frame appears text , buttons no background image.
public class memoryroom extends jpanel { /** background image of menu screen */ private image bg = new imageicon("memoryroom.jpg").getimage(); /** jframe used in entire game */ protected jframe app; public memoryroom(jframe app) { app.setdefaultcloseoperation(jframe.exit_on_close); app.setvisible(true); app.setsize(1150, 680); this.app = app; initialize(); app.repaint(); } protected void initialize() { //final jpanel menuscreenpanel = new jpanel(); setvisible(true); setsize(1150, 680); setlayout(null); jlabel lblselectgame = new jlabel("please select game wish play:"); lblselectgame.setbounds(320, 180, 600, 50); add(lblselectgame); lblselectgame.setfont(new font("dialog", font.bold, 24)); lblselectgame.setforeground(color.white); jbutton btnsnakesandladders = new jbutton("snakes , ladders"); btnsnakesandladders.setbounds(370, 250, 200, 45); add(btnsnakesandladders); jbutton btndanscrazytic = new jbutton("dan's crazy tic tac toe"); btndanscrazytic.setbounds(590, 250, 200, 45); add(btndanscrazytic); btndanscrazytic.addactionlistener(new actionlistener() { public void actionperformed(actionevent tictactoeevent) { setvisible(false); } }); btnsnakesandladders.addactionlistener(new actionlistener() { public void actionperformed(actionevent snakesandladdersevent) { setvisible(false); } }); app.getcontentpane().add(this); } @override public void paintcomponent(graphics g) { super.paintcomponent(g); g.drawimage(bg, 0, 0, 1150, 680, this); } public static void main (string args []){ new memoryroom(new jframe()); } }
Comments
Post a Comment