Close the current UI and open another one

Hello everyone,
I've got the following code and I want to close the current window and open another one. When i use "System.exit(1);" it closes everything when I use "this.dispose()" it doesn't close anything what could I try to get this to work? any suggestions?
the code is:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
//public class Equip_or_Job implements ActionListener {
public class Equip_or_Job extends Frame implements ActionListener {
    JFrame dFrame;
    JPanel jePanel;
    JButton choice;
    JComboBox jeqid = new JComboBox();
    public Equip_or_Job() {
        //Create and set up the window.
        dFrame = new JFrame("Work with Jobid or Equipid");
        dFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Create and set up the panel.
        jePanel = new JPanel(new GridLayout(2, 1));
        dFrame.getContentPane().setLayout(new BorderLayout());
        //Add the widgets.
        addWidgets();
        //Set the default button.
        dFrame.getRootPane().setDefaultButton(choice);
        //Add the panel to the window.
        dFrame.getContentPane().add(jePanel, BorderLayout.CENTER);
        //Display the window.
        dFrame.pack();
        dFrame.setVisible(true);
Create and add the widgets.
    private void addWidgets() {
         //Create widgets.
          jeqid.addItem("Chose by Job");
          jeqid.addItem("Chose by Equipment");
          choice = new JButton("Chose");
            //Listen to events from the Convert button.
            choice.addActionListener(this);
          jePanel.add(jeqid);
          jePanel.add(choice);
    public void actionPerformed(ActionEvent event) {
          String sel = (String) jeqid.getSelectedItem();
        if("Chose by Job".equals(sel)){
               InsertNewDates inj = new InsertNewDates();
               //System.exit(1);
               dispose();
          else if("Chose by Equipment".equals(sel)){
               InsertNewDates ineq = new InsertNewDates();
               //System.exit(1);
               dispose();
Create the GUI and show it.  For thread safety,
this method should be invoked from the
event-dispatching thread.
    private static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        try {
               UIManager.setLookAndFeel(
                    UIManager.getCrossPlatformLookAndFeelClassName());
          catch (Exception e) { }
        Equip_or_Job eorj = new Equip_or_Job();
    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
thanks in advance :o)

I'm not exactly sure what you want to do, but...:
dFrame.setVisible(false) hides the current Frame and the application is still running
Best reagrds, Marco

Similar Messages

  • I had a problem with my mouse double(multiple) clicking when I didn't want it to, now pressing enter in a window like this will close the current window and open one of my Taboo sites, and the cursor keys don't work.

    This happens in any text entry window, but there is no problem with Wordpad or Word or other apps, just in Firefox. It's like the keyboard mapping has gotten fouled up in Firefox, but I can't find where I might check what is going on.

    You may have '''Switched ON Caret Browsing'''. press '''F7 (on Mac: fn + F7)''' to toggle '''Caret Browsing ON/OFF'''
    * click '''Firefox''' button and click '''Options''' -> Advanced -> General -> remove
    Checkmark from '''Always use the cursor keys to navigate within pages'''
    * http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    * http://kb.mozillazine.org/Accessibility_features_of_Firefox
    Check and tell if its working.

  • How can I give a name to excel sheet and open another one?

    Hello!
    I use CSVWriter for writing in excel file.
    I have 2 questions:
    1.     How can I give a name to a Sheet in excel file?
    2.     How can I save the first Sheet and open another one with a different name?
    Thanks!

    This is the equivalent in Apache POI which may or may not help. I've never used CSVWriter.
    HSSFSheet sheet1 = workbook.createSheet("sheet1Name");
    HSSFSheet sheet2 = workbook.createSheet("sheet2Name");Then you can use either sheet object to write your contents. Look at the documentation for CSVWriter that pertains to sheets as it should tell you how.

  • Close current gui and open another?

    how can i close the current gui and then open another? what would be a suitable way to so? so far i do it using the following code but it does not close the current window and it takes a couple of seconds to load the other gui screen..
       private void btn_registerActionPerformed(java.awt.event.ActionEvent evt) {                                            
             Register Register_gui = new Register();
             Register_gui.setTitle("Login");
             Register_gui.setSize(467, 460);
             Register_gui.getSize();
             Register_gui.setVisible(true);// TODO add your handling code here:
             new Login().setVisible(false);
        }     

    Instead of new Login().setVisible(false); use dispose();This assumes that the event handler is a member of the frame you want to close. If not, you'll have to provide the handler with a reference.

  • HT1918 My Apple ID (email address) is somehow registered to the US store even though I live in the UK. Can I close the US account and open a UK one with the same ID/email?

    My Apple ID (email address) is somehow registered to the US store even though I live in the UK. Is there any way I can close the US account and open a UK one with the same ID/email?

    No, but you can change the country of your iTunes Store account. Sign into your iTunes Store account and click the "change country" link. You'll need a valid UK credit card to complete the change. If you have any credit balance remaining, you'll need to contact the iTunes Store to clear that for you before you'll be able to change the country.
    Note that if you purchased anything from the US iTunes Store, you probably will not be able to re-download it nor update apps once you change the country. So you may prefer to set up a new email address so you can create a new account in the UK iTunes Store. You can change the email address to which receipts and other notices are sent to your actual email address, if you prefer.
    Regards.

  • When I open a new window, the current window is closed. I would like to keep the current window and open the new window without losing my current window. I checked "Open new window in a new tab instead" under tabs

    When I open a new window, the current window is closed. I would like to keep the current window and open the new window without losing my current window. I checked "Open new window in a new tab instead" under tabs
    == This happened ==
    Every time Firefox opened
    == Noticed yesterday, June27, 2010

    i just went into preferences, deleted what was in the home page, and entered a new home page address which solved the problem, 

  • After login close the login window and open home page in new window

    Hi guys,
    I want to go to a new window for the "home page" without browser back button etc. after login validation.
    And also close the login window at the same time.
    Here is the code I used after the login validation.
    ExtendedRenderKitService erks =Service.getRenderKitService(FacesContext.getCurrentInstance(),ExtendedRenderKitService.class);
    StringBuilder script = new StringBuilder();
    script.append(" params = 'width='+screen.availWidth-10;\n" +
    " params += ', height='+screen.availHeight-50;\n" +
    " params += ', top=0, left=0'\n" +
    " params += ', fullscreen=yes';\n" +
    " params += ', scrollbars=1';\n" +
    " params += ', resizable=1';\n" +
    " params += ', status=1';\n" +
    "window.close();\n" +
    " newwin=window.open('home.jspx','xxxxxxxxx', params);\n" +
    " if (window.focus) {newwin.focus()}");
    erks.addScript(FacesContext.getCurrentInstance(), script.toString());
    This successfully opens a new window. I want to close the current login window at the same time.
    Please help me with this.
    Regards !
    Sameera

    on the 'Submit' onclick event add some JavaScript code:
    this.form.target = '_blank';

  • Firefox cannot open/reload any websites after resuming from a system standby. I have to close the current window and start a new session, then it works again

    I am using Firefox v 13.0.1 (Mozilla Firefox for Ubuntu canonical 1.0) on Ubuntu 12.04 LTS. Whenever my system resumes from standby I am not able to open/load any webpages in the Firefox session that was already running before the standby. I don't get any error message, but the page doesn't load at all. If I close the session and start a new one everything works fine.

    Not necessarily: rv:1.9.2.8 indicates a Firefox 3.6.8 version
    *Mozilla/5.0 (X11; Linux i686; rv:1.9.2.8) Gecko/20100722 Firefox/4.0.1
    You can check for a possibly corrupted user agent.
    See:
    *https://support.mozilla.org/kb/Finding+your+Firefox+version
    *https://support.mozilla.org/kb/websites-say-firefox-outdated-or-incompatible
    *http://kb.mozillazine.org/Resetting_your_useragent_string_to_its_compiled-in_default

  • Help,how close pop-up window ,and open another view

    Hello,
    How click the pop-up window button ,then close the pop-up window .
    At the same time open another VIEW,and  transfer PO number to the VIEW.
    thanks

    Hi,
    First step is set the SCREEN TYPE as "Modal Dialog Box" in screen property tab.
    Then in PBO of the popup screen take a new GUI status and select DIALOG BOX as status type.
    Then assign some function code in 'X' button say 'CANCEL'.
    the put ur logic like below :
    PBO
    module gui_status.
    PAI.
    module user_command.
    module gui_status.
       set pf-status 'ZPOPUP'.
    endmodule.
    module user_command.
      if ok_popup = 'CANCEL'. " Where ok_popup is the ok_code variable in ur popup screen , also define it in TOP include
        leave to screen 0.
    endif.
    endmodule.
    Hope this will solve your problem and help you to put your logic.
    Thanks

  • HTML-DB OAE Javascript to close current window and open a new window

    Hi everybody,
    We work with 1.6.
    What we want is to close the current window and open a new window with the URL mentionned in the window.open('http://www.cf.qc/pls/portal/PORTAL.....,'newwindow').
    The new window opening fires only once although we call it many times.
    Our javascript is:
    function closeTest()
    { alert('closeTest');
    if('&REQUEST.'=='QUITTER2'){     
    w = window.self;
    w.opener = w;
    w.close();
    window.open('http://www.cf.qc/pls/portal/PORTAL.home','newwindow','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
    We call it on our application attributes :
    OnLoad="closeTest()"
    Thanks. Bye.

    Try this on for size:
    I have included two functions.
    windowRebuild() - opens a new window, maximizes it based on the screen size, removes all toolbars, and then closes the old window.
    myLocation(appName, pageName) - builds a url referencing an HTMLDB application, specfic to what server you are currently on. Very useful when you have an application on 3 different servers(dev, test, prod servers), you wouldn't want the server name hardcoded if you plan to export the app to another server.
    Also, you need to be careful when using &APP_ID. I am not completely certain how that is resolved at runtime, but I've found it only works when the javascript is in the HTML Header of a page and not stored in the template of the page.
    <script language="JavaScript1.1" type="text/javascript">
      This functions is for internal application use.
      Examples of myLocation:
      url = myLocation('&APP_ID.', 'APP_PUBLIC_PAGE');
      url = myLocation('MY_APP_ALIAS', 'MY_PAGE_ALIAS');
      url = myLocation('184', '10');
    function myLocation(myApp, myPage){
      var myHost = location.host;
      var newURL;
      newURL = 'http://'+myHost+'/pls/htmldb/f?p='+myApp.toString()+':'+myPage.toString();
      return newURL;
    /*  Function windowRebuild()
    *   This function will open a new window and close the old window.
    *   This function will also maximize the new window and remove all toolbars.
    function windowRebuild(){
       if(window.name != 'myAppWin'){
        var url = myLocation('&APP_ID.', 'PAGE_ALIAS');
        var myWin = window.open(url,'myAppWin','toolbar=0,scrollbars=1,menubar=0,status=1,resizable=1,location=0');
        window.opener = 'x';
        window.close();
       if(window.name == 'myAppWin'){
        window.moveTo(0,0);
        window.resizeTo(screen.availWidth,screen.availHeight);
    </script>Let me know if that works or you need some more explanation.
    Chris

  • Programatically close current window and open new window

    hi,
    I am in a click event of a button and want to close the current window and open a new window if a condition is met.
    else if(MyText.Content=="OpenNew")
    newwindow sw = new newwindow();
    sw.Dispatcher.Invoke(new Action(() => sw.Show()));
    this.Dispatcher.Invoke(new Action(() => this.Close()));
    But I always get the System.InvalidOperationException.
    Pls help me with this.
    Thanks,
    Shaleen
    TheHexLord

    If you are trying to create the window on a new thread, you must set the  ApartmentState of the window to STA as described here:
    http://reedcopsey.com/2011/11/28/launching-a-wpf-window-in-a-separate-thread-part-1/
    But you should probably just move the creation of the thread and the call to its Show() method on to the UI thread:
    else if(MyText.Content=="OpenNew")
    this.Dispatcher.Invoke(new Action(() =>
    InfoPanel sw = new InfoPanel();
    sw.Show();
    this.Close();
    Please remember to mark helpful posts as answer.

  • Firefox lags too much when i download and close the current window, then try to open a new window. why?

    ok, everytime i download something the download window pops up, so i let it download and i like to keep it open so i can monitor my downloads. now, the problem is when i close the current firefox browser window and try to re-open a new one. my firefox browser window starts lagging/hangs very bad when i open up a new browser window. i have my settings set up to clear my history everytime i close my firefox, so i was wondering why it does this? is it because my history gets cleared and i still have my download window opened?

    Have a look at this post, see if it is of any help (though related to Vista, but same issue can be there with Window 7 also)
    http://www.vistax64.com/browsers-mail/265937-firefox-exe-still-running.html

  • Close one vi and open another

    Hi
    Is it possible to open another vi when I click a button and close the current vi.
    thanks 

    Here, try this. Enter the path to the VI you want to launch and run the program. When you press the button, the VI you specified will be launched and the program will be closed.
    Mike...
    Message Edited by mikeporter on 07-02-2007 07:43 PM
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
    Attachments:
    launch on click.vi ‏19 KB

  • Unable to open firefox - get message that " a copy is already open and only one copy can be open at a time. I have dragged the app to the waste basket and downloaded another firefox app. However same result". I have a IMAC , V.10.6.3.

    Unable to open firefox - get message that " a copy is already open and only one copy can be open at a time. I have dragged the app to the waste basket and downloaded another firefox app. However same result". I have a IMAC , V.10.6.3.
    I get above message when I click on the firefox icon.

    This worked, I used the method described in this link http://forums.mozillazine.org/viewtopic.php?t=365156, and opened the Mozilla profile screen with the terminal on my mac, using the language given in the links. Then I duplicated my original profile to save the bookmarks, etc. Put them in a folder listed Duplicate profile with the date. With the open profile screen, I deleted my original profile, created new profile folder and then a new profile. Note that profile cannot be created in the system library, it must be created on the disc, because the library will not allow writing into it. After I created my new profile folder, I dragged all my old information into it, and it worked. Firefox closed and the error disappeared. You must be VERY careful to make sure Firefox is closed anytime you are doing anything with the profile folders. I think that is what caused my original problem.

  • How can I open a new page (using "Pages") when I already have another page open?  It just keeps reverting to the page I have opened already and won't let me open another one?

    How can I open a new page (using "Pages") when I already have another page open?  It just keeps reverting to the page I have opened already and won't let me open another one?

    To make a new document, go to File > New From Template chooser and choose the type of document you wish to create.
    To add a new page to an existing document go to Insert > Sections > Blank.

Maybe you are looking for

  • How can I get command values from a VI executed by reference ? NEWBIE

    Hi, I'm running a sub-vi in a "Secondary Front Face" (excuse for the translation if not correct, I'm working on a French version). In order to run this VI, I pass a reference. All is working fine but I don't know how can I get the values entered by t

  • How do i reinstall my previous apps from a previous iphone to a new one?

    my 3GS iPhone was stolen and I have upgraded to iPhone 4 but when I come to install my previous apps Itunes store doesn't recognises me even though I am using my previous user and password is there anyone out there that knows about this kind of probl

  • Qualifications info required

    Hello All, I am basically BI Consultant, we have a requirement to pull Qualifications Data from SAP ECC, Clients requirement is "A relationship is created between a Qualification and either a Job or a Position.  Any employee who holds either the job

  • Official C_TB1200_07 certificate

    I passed SAP C_TB1200_07 test on October 24, 2010, in a Pearson VUE Authorized Testing Center in Mississauga, Ontario, Canada. But I havenu2019t received the official certificate yet. All I have now is a print-out certificate on an A4 pager from the

  • I think I have a GHOST in my computer!  Need some exorcism!

    OK, it's not a ghost, but it's a mysterious "t" file that shows up on my office computer's desktop whenever anything is moved to/from the desktop or saved on it. Every time I click on it, it disappears!! It doesn't seem to cause any other problems, b