Opening a Second JInternalFrame

Below I have two classes InternalFrameDemo instantiates MyInternalFrame (extends javax.swing.JInternalFrame ) in doing this the application creates a JDesktopPane and creates a MyInternalFrame to put in it.
What I want to happen is when the jButton1 on the MyInternalFrame is clicked is for a second MyInternalFrame to open and the first MyInternalFrame to close is this possible?
I think that I would need to have the action Method in MyInternalFrame trigger a method call in the InternalFrameDemo and do the closing and opening of new MyInternalFrame from there?
Thanks
package components;
import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JFrame;
import javax.swing.KeyStroke;
import java.awt.event.*;
import java.awt.*;
public class InternalFrameDemo extends JFrame
implements ActionListener {
JDesktopPane desktop;
public InternalFrameDemo() {
super("InternalFrameDemo");
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(inset, inset,
screenSize.width - inset*2,
screenSize.height - inset*2);
desktop = new JDesktopPane();
createFrame();
setContentPane(desktop);
setJMenuBar(createMenuBar());
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
protected JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Document");
menu.setMnemonic(KeyEvent.VK_D);
menuBar.add(menu);
JMenuItem menuItem = new JMenuItem("New");
menuItem.setMnemonic(KeyEvent.VK_N);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_N, ActionEvent.ALT_MASK));
menuItem.setActionCommand("new");
menuItem.addActionListener(this);
menu.add(menuItem);
return menuBar;
public void actionPerformed(ActionEvent e) {
if ("new".equals(e.getActionCommand())) {
createFrame();
} else {
quit();
protected void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
frame.setVisible(true);
desktop.add(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
MyInternalFrame frame2 = new MyInternalFrame();
frame.setVisible(true);
desktop.add(frame2);
try {
frame2.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
public void closeWin(){
protected void quit() {
System.exit(0);
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
InternalFrameDemo frame = new InternalFrameDemo();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
public static void main(String[] args) {     
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
/*MyInternalFrame */
package components;
public class MyInternalFrame extends javax.swing.JInternalFrame {
@SuppressWarnings("unchecked")
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(152, 152, 152)
.addComponent(jButton1)
.addContainerGap(169, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(108, 108, 108)
.addComponent(jButton1)
.addContainerGap(147, Short.MAX_VALUE))
pack();
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
this.dispose();
private javax.swing.JButton jButton1;
}

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
I think that I would need to have the action Method in MyInternalFrame trigger a method call in the InternalFrameDemo and do the closing and opening of new MyInternalFrame from there?Correct. So give it a try and see what happens.

Similar Messages

  • Reporting Services - How to open a second table inside report, for each number of client (each apears in first table)

    Reporting Services - How to open a second table inside report, for each number of client (each apears in first table)?
    Exemple:
    Table1
    Cliente name:
    John
    Client number:
    12345
    Survay number of negative answers:
    3
    Table2
    Questions and answers that were negative:
    Question: How much time where you waiting
    Avaluation: 3 (from 1 to 10)
    Answer: They only called me 1 mouth later
    Can you please help me?

    Hi,
    Based on the description, I understand that you want to add subreport in the main report. When previewing the main report, the subreport can be shown in detail. Please see the screenshots on my test:
    In Reporting Services, we can create parameters and pass them from main report to subreport in order to control the data dynamically.
    References:
    Subreports (Report Builder and SSRS)
    Add a Subreport and Parameters (Report Builder and SSRS)
    If I have any misunderstanding, please feel free to contact me.
    Regards,
    Heidi Duan
    Heidi Duan
    TechNet Community Support

  • When I first open Firefox it is fine but if I open a second tab to search another site I get a white screen and have to continually click 'back', click the site link, white screen, back, click the link, white screen and so on.

    When I first open Firefox it is fine but if I open a second tab to search another site I get a white screen and have to continually click 'back', click the site link, white screen, back, click the link, white screen and so on.

    This can also be a problem with the files [http://kb.mozillazine.org/sessionstore.js sessionstore.js] and sessionstore.bak in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder]
    Delete [http://kb.mozillazine.org/sessionstore.js sessionstore.js] and sessionstore.bak in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder]
    If you see files sessionstore-##.js with a number in the left part of the name like sessionstore-1.js then delete those as well.
    You will have to redo App Tabs and Tab Groups after deleting sessionstore.js.
    See:
    * http://kb.mozillazine.org/Session_Restore

  • How can I open a second window in iTunes?

    When I see some albums in the the iTunes Store I want to check whether I have some of the songs already. The Search function in the Store only refers to the store and not to my Library. So how can I open a second window in iTunes (one with the Store and one with my Library) to make it easier to compare?
    Thanks

    My understanding it that was removed from iTunes recently (I still run iTunes 7.5 from 2007), so no, not unless you downgrade iTunes (which is not easy).  You can send feedback to Apple about reinstating it but I have yet to see Apple reinstate something that appeared to have been deliberately removed from its software, despite vociferous complaints on this forum.
    http://www.apple.com/feedback/itunesapp.html

  • I attempt to open a second window from the icon but it does not open then when firefox is closed it will not reopen because it is still running in processes but no window displayed until you kill the process and then restart firefox.

    I attempted to open a new window from the Firefox icon but nothing happens. I then went on browsing and closed Firefox but was later unable to open it. I checked processes and it was already running but there was no window displayed. I am running Windows 7 Professional.
    This is repeated any time I already have the browser open and wish to open a second instance.

    '''<u>Open a second window (not a second tab, that is different) when Firefox is already running and displayed on the monitor</u>'''
    *Firefox button > New Tab > New Window
    *CTRL+N
    *'''''If using the Menu Bar''''': File > New Window
    **To '''''temporarily''''' display and make choices from the Menu Bar press the ALT key or the F10 key
    **Also see: https://support.mozilla.com/en-US/kb/Menu%20bar%20is%20missing
    '''<u>Firefox "hang on exit"</u>'''
    #Stop the Firefox process:
    #*[http://kb.mozillazine.org/Kill_application Mozillazine - Kill application]
    #*Windows 7 users click [http://www.techrepublic.com/blog/window-on-windows/reap-the-benefits-of-windows-7s-task-manager/2576 here]
    #Why Firefox may hang:
    #*[http://support.mozilla.com/en-US/kb/Firefox+hangs Firefox hangs] (see Hang at exit)
    #*[http://kb.mozillazine.org/Firefox_hangs Firefox hangs (Mozillazine)] (see Hang at exit and Closing Firefox properly)
    #*[https://support.mozilla.com/en-US/kb/Firefox+is+already+running+but+is+not+responding Firefox is already running but is not responding]
    #Use Firefox Safe Mode to find a problem with an Extension or Plugin:
    #*Don't check anything when entering Safe Mode, just continue
    #*If the problem does not occur in Safe Mode it is probably and Extension or Plugin causing the problem
    #*See:
    #**[[Safe Mode]] and [http://kb.mozillazine.org/Safe_Mode Safe Mode (Mozillazine)]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes Troubleshooting extensions and themes]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+plugins Troubleshooting plugins]
    #**[http://support.mozilla.com/en-US/kb/Basic+Troubleshooting Basic Troubleshooting]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • When opening a second window, homepage doesn't open and can't access any other site, stays a blank white screen.

    After updating to Firefox 6, every time I open a second window, all I get is a blank, white page. My homepage doesn't open, either, even when I hit the home button. I have to manually type in my homepage address, and then, it's the only address that will show in the address bar, even after I leave the page or open any other tabs. The same thing happens when I open new tabs in the second window. Also, the back and forward arrows, stop, and refresh buttons do not work in the second window. None of the short-cut keys on the keyboard will work with in the second window, either. Most of the time, any page that I go to, in the second window, continues to load, never fully loading.
    I even went back to Firefox 5 to see if that would solve the problem, but it didn't. I still have the same issues.
    Everything appears to be working fine in the first window.
    How can I clear all this up?
    EDIT: I waited a few days and reinstalled Firefox 6.0 and everything seems to be working okay.

    There's a good chance this is related to a bug that kicks in when you do not have Flash running in any tab and you open a new window to a page that does use Flash. The details are in this recent thread: [https://support.mozilla.org/en-US/questions/955659 Opening New Windows and Shockwave Flash].
    I don't know whether opening a Flash site in a private window makes this problem occur more frequently. Maybe it does because the new window is more isolated from the previous one???

  • How to open a second grid, by clicking on first grid

    Hi
    On my htm page, i have a grid, by clicking on any of row of the first grid, i want to open a second grid, below the first gird, which will contain only the values of that row.
    For the first gird, I am using the code      <PARAM NAME="DoubleClickEvent" VALUE="Doubleclick">
    and i have written a function as Doubleclick in the java script.
    Now want code i should write under the function (Doubleclick) in the java script.
    Can you help me out with the code for the same.
    thanks,
    Ashish

    Hi
    Padma,
    I am new to this technology, can u tell me how to hide the second grid, what code i should add in the applet.
    And my grid is containting the following data:
    Airline             AirportTo        AirportFrom      Price
    Jet                     BOM                 DEL                    4500
    Kingfisher           PUN                  IND                     4000
    Say, now when i will select 2nd row, my second grid should get following data
    Airline             AirportTo        AirportFrom      Price
    Kingfisher           PUN                  IND                     4000
    Can you explain the code more in detail.
    thanks,

  • Firefox crashes on opening within seconds. started suddenly several weeks ago and i haven't been able to get on since. i reinstalled but updating didn't work. it won't even open in safe mode. HELP!

    firefox crashes on opening within seconds. this started suddenly a few weeks ago and despite several daily attempts, i still can't load firefox application. it crashes immediately upon startup every time no matter what and crash reporter arrives. i have researched all the articles and followed their suggestions. i installed the newest version of firefox and still get the same results. i can't even open firefox in safe mode.

    You do not want to remove the program directory with a Mac because Firefox is most likely installed in the system Applications directory which is where the system applications are stored.
    Have you tried removing the Firefox plist file from your user library? I have Mac OS 10.6.8 as well, and that file is at /Users/<user name>/Library/Preferences. Close Firefox and remove that file, then start Firefox again.

  • Hello, when I click on the tray icon..FF opens up. I then click again to open a second FF browser..no new Browser..???

    I start my PC click on the FF icon in me lower tray. Browser opens up. I do the same actions again to have a second FF browser beside the first FF and toggle between the two, but it does not open a second FF browser.
    Thank you
    == This happened ==
    Every time Firefox opened
    == all the time

    <u>'''For future questions posted, see:'''</u> [[Using the Troubleshooting Information page]]
    Several add-ons have been reported to not allow new/additional windows to open in Firefox:
    Google Shortcuts
    HP Smart Printing Toolbar
    Skype
    ZoneAlarm Spyblocker Toolbar
    <u>'''Safe Mode'''</u>
    You may need to use '''[[Safe Mode]]''' (click on "Safe Mode" and read) to localize the problem. Firefox Safe Mode is a diagnostic mode that disables Extensions and some other features of Firefox. If you are using a theme, switch to the DEFAULT theme: Tools > Add-ons > Themes <u>'''before'''</u> starting Safe Mode. When entering Safe Mode, do not check any items on the entry window, just click "Continue in Safe Mode". Test to see if the problem you are experiencing is corrected.
    See:
    '''[[Troubleshooting extensions and themes]]'''
    '''[[Troubleshooting plugins]]'''
    '''[[Basic Troubleshooting]]'''
    If the problem does not occur in Safe-mode then disable all of your Extensions and Plug-ins and then try to find which is causing it by enabling <u>'''one at a time'''</u> until the problem reappears. <u>'''You MUST close and restart Firefox after EACH change'''</u> via File > Restart Firefox (on Mac: Firefox > Quit). You can use "Disable all add-ons" on the Safe mode start window.

  • When I open a second Profile while another is running the second cannot access the Internet until I close the first. Why?

    I often have occasions to run more than one Profile simultaneously (usually because of different add-ons I've installed on different Profiles). In the past this worked fine. Now, all of a sudden, if I open a second Profile while the first is running the second cannot access the Internet until I close the first. It keeps looking for a website, and failing, until the system "times out". If I close the first Profile, the second is then able to access the Internet.
    Note: this is not a problem with opening a second Window in Firefox. As long as they are from the same Profile they will both work fine. Nor does this stop me from using a second Profile to look at website files I have saved to my computer. The only problem is that the second Profile cannot get on the Internet.

    I just checked, the setting was for "Automatic proxy configuration URL", in the past it was set on "No Proxy". So I'll try changing that (and/or try other proxy options), and see if that solves the problem.
    If it does, then just one (academic) question remains: why did that happen in the first place? I don't care what the answer is, so long as your suggestion solves the problem.
    Thanks.

  • Open a second window from the first one

    Hi,
    The problem of my application is loosing control when I open the second window, so I know that the problem is the run of the sub VI but I don't find an other possibility to open a second window from the first one knowing that the first sends its vales to the second one. In an other way I want to open two windows simutaneously.
    NB: I attached  a simple verssion of my application.
    Can someone help me please.
    Attachments:
    The main VI.vi ‏21 KB
    The su b VI.vi ‏28 KB

    Hi Basile,
    why do you open a new thread again? Didn't the older one provide a solution?
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • I have photoshop CC. I cannot open two files such as Tiffs and view them side by side. When I open the second file it overrides the first. Do I need to do something with preferences?

    I have photoshop CC. I cannot open two files such as Tiffs and view them side by side. When I open the second file it overrides the first. Do I need to do something with preferences?

    What happens when you try to use the clone stamp tool?
    It should work with the images side by side.
    You can setup photoshop cc to be like photoshop cs2 was on your other mac, by going to Photoshop>Preferences>Interface and unchecking
    Open Documents as Tabs and Enable Floating Document Window Docking
    And also going to Window and unchecking Application Frame

  • Can I open a second iTunes account for my child, but use my email for both accounts?

    I have one iTunes account, my ID is my email address.  I want to open a second account for my daughter, but I want to see her iTunes Store receipts (sent to MY email address).  When I try to set up a new account, it says that I need to enter my email address as my ID, and then says "You already have an account usint this ID).  Can I create an account using the same email, or can I use an ID that's not an email address?

    Welcome to the Apple community Pammy.
    Yes, that's exactly what I'd suggest for the vast majority of users.

  • Can you open a second jsp page as popup/new window?

    Hi all gurus!
    I have a question regarding popups/new windows in an iview application. Instead of starting with a question let me instead describe what I want to do.
    We have a jsp page that presents a search and then the search result in a table where one column is "clickable". When the user clicks a cell a server round trip retreives data specific for that cell value. This is standard functionality and already fixed so here is what differes: we want a new jsp window to open like a popup, with the data retreived from the server round trip and at the same time the first page with the table shall still be there so that you just can close the popup and click the next cell which creates a new server round trip and a new jsp popup and so on.
    My solution which doesn't work yet: In application "a" I have a JavaScript for the clicked cell which opens another iview application "b" in a new window, by window.open("navurl_to_the_iview"), and that works fine.
    At the same time the value of the clicked cell is written to the data bean and the bean is put in the http session (since component session does not reach between applications).
    The second iview "b" retreives the bean from the http session and fills the jsp page with data.
    Here is now the problem: no data is displayed and this because the iview "b" retreives the bean BEFORE iview "a" has been able to put the bean/value into the http session. How do I know this for sure? Simple, if I do a refresh of iview "b" the value is displayed.
    I could do a JavaScript that recursively checks if the value in the bean is null or not but then I have to do a method that retreives the bean from the http session each time.
    This could work but I wonder if this is the most simple solution. So my question for you gents and madams is: do you know of a more simple solution?
    Best regards
    Benny Lange
    Edited by: Benny Lange on Oct 6, 2009 11:33 AM

    Hi you all.
    In this case the solution was to pass the id in the url to the second iview and let that iview use the id to retreive data from the backend system.
    But I still think the question is interesting, if it's possible to open a second jsp window after a server round trip and still have the first one open.
    All the best
    Benny

  • When I open a second tab in Firefox, it does not go to my home page. Instead it goes to a page that displays what looks like a collection of pages (or links) t

    When I open a second tab in Firefox, it does not go to my home page. Instead it goes to a page that displays what looks like a collection of pages (or links) that I have visited in the recent or distant past. I would much rather have it go to my home page which is much more useful to me. I have tried to change this in 'Options' but with no luck. Please fix this.

    See also this article about the New Tab page (about:newtab):
    *https://support.mozilla.org/kb/new-tab-page-show-hide-and-customize-top-sites

Maybe you are looking for

  • How to enable olap option in oracle enterprise edition 10g?

    what are the settings/steps one should take in enabling OLAP option in oracle enterprise edition 10g? If we have an installation of Oracle EE 10g,how can we know that OLAP is enabled or not? Can anyone throw light on OLAP_TABLE function? In Analytic

  • Posting to QM stock while goods receipt

    Hi What are all the options we have to post the goods to Quality stock category at the time of goods receipt? I know off A. In material master, purchasing view - post to inspection stock is active B. If QM control key is active What are the other pos

  • Incompatible format all the sudden

    I am getting "incompatible format" all the sudden when trying to import into Studio Pro. I have tried many different compressions using compressor 3 but I getting the same result. Any help would be greatly appreciated. Thanks!

  • E63 I can't send email

    I can receive email, but can't send them. They just stay in the outbox as deferred or queued. I am using talktalk at home and can receive these emails on my phone but not send. I think that I've set it up correctly, but it doesn't work. Any help?

  • How do you view safari cookies

    Is there a way to view the cookies, or the cache that safari stores in your iphone? also is there a way to look at the deleted history from safari?