Results 1 to 4 of 4
Thread: JDesktopPanel & JInternalFrame
- 04-17-2011, 08:31 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
JDesktopPanel & JInternalFrame
i have hundreds of JInternalFrames control by JMenu and JdesktopPanel, each button add JInternalFrame to DesktopPanel, my problem is when i press the same button twice, it opens the same screen twice, how can i validate if the screen is alive before open it another time?
-
JInternalFrame has an isClosed() method to determine whether the frame has been close.
JInternalFrame (Java 2 Platform SE v1.4.2))
- 04-17-2011, 11:03 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
well, i tried it but let me show u part of the code :
private void jMenuItem1ActionPerformed(java.awt.event.ActionEve nt evt) {
JInternalFrameEx usrmain= new JInternalFrameEx();
jDesktopPane1.add(usrmain);
usrmain.setVisible(true);
}
this is the listener funtion, it creates new object of the frame then added to the desktoppane. so each time this function called , new instance of JInternalFrameEx will be created so when i validate isClose() . it will be pointing to the new instance , where the old instance still opened
i hope you got my point
- 04-17-2011, 11:22 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Why not make that listener remember whether or not it created that JInternalFrame before? Something like this will do:
kind regards,Java Code:class YourListener implements ActionListener { private JInternalFrame usrmain; // remembers the JInternalFrame public void actionPerformed(ActionEvent ae) { if (usrmain == null) { // not yet created? usrmain= new JInternalFrameEx(); jDesktopPane1.add(usrmain); usrmain.setVisible(true); } } }
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
jInternalFrame
By kiranjava in forum Advanced JavaReplies: 1Last Post: 05-20-2010, 12:04 PM -
How to reload JInternalFrame
By chyrl in forum AWT / SwingReplies: 42Last Post: 04-16-2010, 01:29 PM -
How to refresh my JInternalFrame upon CUD
By chyrl in forum AWT / SwingReplies: 2Last Post: 04-01-2010, 04:22 PM -
JInternalFrame Help
By collin389 in forum New To JavaReplies: 2Last Post: 03-16-2010, 12:23 AM -
JInternalFrame Help
By collin389 in forum AWT / SwingReplies: 1Last Post: 03-15-2010, 09:24 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks