Thursday, 15 July 2010

Netbeans Jinternalframe single instance -



Netbeans Jinternalframe single instance -

i have developed application using net bean,

1) i'm making project in java api 6. i'm using "net beans 7.1". 2) want utilize jinternalframe in project 3) made bundle , made "jinternalframe" there. , phone call in main application window firing action performed event on "jmenuitem". 4) works fine 1 problem occurs is, if click on "jmenuitem" 1 time again , again, new "jinternalframe" of same instance opening, how can stop that? 5) want that, if open "jinternalframe" 1 time , 1 time again click on "jmenuitem" open same "jinternalframe", should nil or shows window opened , minimized

sample code:

<code> private void empdataactionperformed(java.awt.event.actionevent evt) { emps employees = new emps(); desktop.add(employees); employees.setvisible(true); dimension screensize = toolkit.getdefaulttoolkit().getscreensize(); employees.setbounds(230, 40, screensize.width / 2 - 80, screensize.height / 2 + 105); } <code>

please need help.

here may sample code. hope help. menu action phone call internal frame in main application jdesktoppane in it.

private void yourjinternalframemenuitemactionperformed(java.awt.event.actionevent evt) { yourjinternalframe nw = yourjinternalframe.getinstance(); nw.pack(); //usefull part you.. if open shows, if not creates new 1 if (nw.isvisible()) { } else { desktoppane.add(nw); nw.setvisible(true); } seek { nw.setmaximum(true); } grab (propertyvetoexception ex) { logger.getlogger(mainapplication.class.getname()).log(level.severe, null, ex); } }

put within of yourjinternalframe

private static yourjinternalframe myinstance; public static yourjinternalframe getinstance() { if (myinstance == null) { myinstance = new yourjinternalframe(); } homecoming myinstance;

netbeans jinternalframe

No comments:

Post a Comment