java - Change content pane on button press -
i want button change contentpane in frame. admin panel , user panel in 2 different jpanel classes gets called in mainwindow class frame.
my code looks follows:
the method button calls:
public void changecontent() throws exception{ mainwindow mw = new mainwindow(); adminui admin = new adminui (); mw.frame.getcontentpane().removeall(); mw.frame.setcontentpane(admin); mw.frame.revalidate(); mw.frame.repaint(); }
this method being called in "public mainwindow()" method in mainwindow class (the 1 frame) show contentpane in beginning:
public void admin() throws exception { frame = new jframe("admin panel"); frame.setresizable(false); frame.setbounds(100, 100, 256, 457); frame.setdefaultcloseoperation(jframe.exit_on_close); adminui admin = new adminui(); frame.setcontentpane(admin); }
an equal method exists userui.
i have tried called userui() method in mainwindow when press button, doesn't refresh window, , neither changeconten() method. need help. used search feature on stackoverflow no success.
Comments
Post a Comment