swing - JLayeredPane for Java -
my problem have jframe (with buttons on it)...when clicked on "new" button, call internalframe on screen...the internal frame screen came out , until move internal frame around , found set @ of everything...
i have tried .tofront() , .setalwaysontop() , everything...until came across jlayeredpane , think looking for...but couldn't make work >< can else guide me through it? thanks!
please tell information need..will provide them asap
windowconstruct wconstruct; jdesktoppane desktop = new jdesktoppane(); jinternalframe internalwindows = new jinternalframe(); public mainuser(){ wconstruct = new windowconstruct("..:: user's helpdesk main page ::..", 1500, 800, false, null, "user"); wconstruct.add(desktop); wconstruct.btnnew.addactionlistener(this); } public void actionperformed(actionevent e) { object src = e.getsource(); if(src == wconstruct.btnnew){ internalwindows.setsize(500, 300); internalwindows.settitle("new task"); internalwindows.setlayout(null); internalwindows.setlocation(100,50); internalwindows.setclosable(true); desktop.add(internalwindows); internalwindows.setvisible(true); } }
i don't seem exceptions, attempting create mcve code you've shown. it's not best code, tried maintain code looks as possible. on , let me know how code differs. , again, better down root of problem, should post mcve. means code should runnable, i.e copy,paste,compile,run.
and please consider above comments (i.e. maybe using jdialog, if don't plan make application mdi (see link in comment) type application.
import java.awt.borderlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jdesktoppane; import javax.swing.jframe; import javax.swing.jinternalframe; import javax.swing.swingutilities; public class mainuser implements actionlistener { windowconstruct wconstruct; jdesktoppane desktop = new jdesktoppane(); jinternalframe internalwindows = new jinternalframe(); public mainuser() { wconstruct = new windowconstruct("..:: user's helpdesk main page ::..", 500, 500); wconstruct.add(desktop); wconstruct.btnnew.addactionlistener(this); } public void actionperformed(actionevent e) { object src = e.getsource(); if (src == wconstruct.btnnew) { internalwindows.setsize(500, 300); internalwindows.settitle("new task"); internalwindows.setlayout(null); internalwindows.setclosable(true); internalwindows.setlocation(100, 50); desktop.add(internalwindows); internalwindows.setvisible(true); } } public static void main(string[] args) { swingutilities.invokelater(new runnable() { public void run() { new mainuser(); } }); } class windowconstruct extends jframe { jbutton btnnew = new jbutton("add new"); public windowconstruct(string title, int width, int height) { super(title); setsize(width, height); add(btnnew, borderlayout.page_end); setdefaultcloseoperation(jframe.exit_on_close); setvisible(true); } } }
Comments
Post a Comment