java - Successfully updating Look and Feel but still having errors -
i trying update , feel without errors, can't figure out doing wrong.
this window class:
public class window extends jframe { private static final long serialversionuid = 1l; public window() { setdefaultcloseoperation(exit_on_close); setlayout(new miglayout()); setextendedstate(jframe.maximized_both); setminimumsize(new dimension(600, 700)); setvisible(true); setcontentpane(new jpanel() { private static final long serialversionuid = 1l; public void paintcomponent(graphics g) { g.drawimage(new imageicon("start.jpg").getimage(), 0, 0, getwidth(), getheight(), this); } }); } }
and main update ui (look , feel)
public class main { public static void main(string[] args) { window.setdefaultlookandfeeldecorated(true); try { uimanager.setlookandfeel(new substancegraphitelookandfeel()); } catch (unsupportedlookandfeelexception e) {} window window = new window(); } }
the console says error comes line: window window = new window();
then line: setcontentpane(new jpanel() {
but if delete whole setcontentpane bloc, error points constructor.
any appreciated. thank you!
substancegraphitelookandfeel() must wrapped invokelater()
window window = new window(); shold wrapped invokelater(), more see in oracle tutorial initial thread
g.drawimage(new imageicon("start.jpg").getimage(), 0, 0, getwidth(), getheight(), this);
use bufferedimage, load local variable
paintcomponent invoked every mouse, key events , internal methods implemented in apis, quite hard , long imageicon("start.jpg").getimage() called repeatly, how many times event fired repaint,
load local variable
setcontentpane(new jpanel() {, override getmin/max/preferredsize
Comments
Post a Comment