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.

Similar Messages

  • 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

  • Closing one GUI and opening another?

    Hi guys,
    (I didnt really know which forum to post this in, so apologies in advance if this is the wrong one).
    I have created a login screen for a system, LoginScreen.java, which accepts a username and password and checks these on the server for validity. This all works fine.
    Once an account is accepted as valid I would like for the login screen to close, and the actual main GUI, Client.java, to open.
    Can anyone tell me the code for doing this? (closing one GUI and opening another).
    Please ask if you need more information on my code.
    Many thanks!

    You can make the Client.java as your main program then just call the LoginScreen.java.
    import javax.swing.*;
    public class Client extends JFrame {
    public static void main (String[] args) {                     
         Login log = new Login();
         log.show();     
    // Here you can put validation if the user is valid before displaying the main GUI
    // If valid user
         Client clt = new Client();
    clt.show();     
    // } else {
    // System.exit(0);
    public Client() {
         super("Client Java");
         setSize(400, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    class Login extends JFrame {
    public Login() {
         super("Login Java");
         setSize(200, 300);
    }

  • 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.

  • 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

  • Getting Powerpoint to close running presentation, and open another?

    Background: Using a Mac Mini (10.4.8) to drive a Digital Signage display. Apache/PHP/MySQL serves a web interface that runs Python scripts that send serial commands (Via Keyspan USB-Serial) to control the display. All that works. There's also a way to upload Powerpoint files to the system, and Powerpoint is always running to provide display content. I'm using folder actions and Applescript to provoke the display of the content once it's uploaded. This is where I get into trouble:
    I was just opening the file (a Powerpoint Slideshow) and that works the first time. But the next time I do it, it opens another hidden window, so it looks like the content never updates.
    So I'm trying to tell application Microsoft Powerpoint to stop the slideshow and close the file, then re-open the file. This part I can't figure out. I can't get Powerpoint to do anything.
    I've been using Macs for years and can do PHP/MySQL and Python, but the sad fact is I don't know jack about Applescript. I've also just realized I don't have my existing code handy to post. It's on a computer behind a firewall at work. Sorry, I'll post my code tomorrow.
    In the meantime, if someone wanted to wanted to crank out some psuedo-code for me, almost anything would probably help me understand what I'm doing wrong.
    Thanks,
    Mac Mini   Mac OS X (10.4.8)  

    OK, now I'm even more confused.
    Telling Powerpoint to stop the show and close open documents works. If I make a script that's just:
    on adding folder items to this_folder after receiving added_items
    try
    tell application "Finder"
    open document file "display.pps" of folder "Powerpoint" of folder "Shared" of folder "Users" of startup disk
    end tell
    end try
    end adding folder items to
    ...that also works to open the file like I want.
    BUT... If I put both the Powerpoint commands and Finder commands in the same script, Powerpoint will close the file like it's supposed to, but the file never opens in the finder.
    So, why won't the 2nd part work when it's after the first part in the same script, but it will work when it's all by itself?
    Thanks for any advice or help,

  • When I close Firefox and open another instance of it to look at a new site I get a pop up window telling me Firefox hasn't shutdown yet.

    When I close Firefox and open another instance of it to look at a new site I get a pop up window telling me Firefox hasn't shutdown yet. I am aware of tabs, but I prefer to just open new windows.
    Do I really need a pop up window telling me that I just closed Firefox? Is there a way to disable it in options? I can't even use Buzof program to auto click for me. I've never had this issue with any other browser and I find it incredibly annoying.

    I am not clear what you mean by:
    ''the program will only alow 1 website for each time I boot my machine,''
    Are you talking about Firefox or something else in the above statement. Firefox will, or should allow you to open quite a few tabs at startup if you wish, although it will be faster the fewer that you do open.
    When you say
    ''I close it the program does not completely close ''
    Again what is happening, what error messages if any do you see, and what exactly makes you think Firefox is not closing properly.
    Presumably you have already clicked on the blue links in my first post and read those articles.

  • My Macbook Pro (OSX 10.6.7 2.26 GHz Intel Core 2 Duo) has started misbehaving on me. When I'm working, the cursor will start spontaneously moving to the left in a straight line, and randomly right clicking on things.  If I close the computer and open it b

    my Macbook Pro (OSX 10.6.7 2.26 GHz Intel Core 2 Duo) has started misbehaving on me. When I'm working, the cursor will start spontaneously moving to the in a straight line, and randomly right clicking on things.
    If I close the computer and open it back up, it sometimes stops for a little while, then will spontaneously start again. Any help would be truly appreciated. Thanks!

    See this knowledge base article. Also, you might want to update to 10.6.8 (don't know that that will fix your problem, but it's the latest version of Snow Leopard).
    Clinton

  • When I switch between networks firefox is not working. I will have to close the browser and open it again!?

    Hi,
    I love firefox!!! I wanted it to be perfect all the time, one issue I come across with it recently is: When I switch between networks (say connecting to myoffice network through VPN when firefox is already open) firefox is not working. I will have to close the browser and open it again to make it work! could you please fix this.
    Thanks.
    Raja Pattamsetty

    If an option or preference settings not being saved after you restart firefox see:
    [http://kb.mozillazine.org/Preferences_not_saved Preferences not saved]
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • 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.

  • Why do my animated themes only work the first time I open the window? Every one that I have tried stops animating if I close the window and open a new one.

    The headline pretty much sums up my problem. Basically, I picked a few different animated themes to try out in the Add-Ons section to personalize my browser window. They look great initially, and in the window that is open when I actually enable the theme. However, if I close that window and open a new one, the theme is stationary and no longer animates.

    Sorry......I was just too impulsive. ( Maybe because it was 4 AM at Taiwan, and I was still trying to solve the problem= = )
    Although to install the add-on "Personas Shuffler" can solve the problem to me, I don't think it was the BEST solution. This evening, I read why the add-on "Personas Shuffler" was made, and found that the BEST solution is:
    1. Open a new tab, and type "about:config" at the URL bar, then search for "lightweightthemes" with the filter.
    2. Change the values of "lightweightThemes.persisted.footerURL" and "lightweightThemes.persisted.headerURL" from true to false( by double click on them).
    3. After doing so, restart Firefox and you will see it works! You don't have to install any add-on.

  • How come my safari windows disappear when I close my laptop and open again? The safari windows I wanted to keep running for the next time I open my laptop disappeared. Why? Help me.

    How come my safari windows disappear when I close my laptop and open again? The safari windows I wanted to keep running for the next time I open my laptop disappeared. Why? Help me.

    Important note, do NOT sleep your macbook Air with headphones attached until this is resolved.
    Ive done a good best of testing on same to confirm not to do that
    also if you have the APP "BOOM" installed........ remove it

  • How to exit from a WebDynpro ABAP application and open another url

    Hi Friends,
    How to exit from a WebDynpro ABAP application and open another url like (www.yahoo.com) in the same window of the WD4 application on click of a Button?
    Regards,
    Xavier

    Hi,
    First of all you should create outbound plug in the window you are trying to exit with plufg type "Exit"
    Then create method handler in the view with this code
            data lo_view_cntr type ref to if_wd_view_controller.
            data lo_win_cntr type ref to if_wd_window_controller.
            data: l_parameter_list type wdr_event_parameter_list,
                  l_parameter type wdr_event_parameter,
                  l_val type ref to data,
                  l_val_url type REF TO data.
            field-symbols: <fs> type any,
                           <fs_url> type any.
            lo_view_cntr  = wd_this->wd_get_api( ).
            lo_win_cntr = lo_view_cntr->get_embedding_window_ctlr( ).
            CREATE DATA l_val type c.
            CREATE DATA l_val_url type string.
            ASSIGN l_val->* to <fs>.
            ASSIGN l_val_url->* to <fs_url>.
            <fs> = 'X'.
            <fs_url> = 'http://your-link.com'.     
            l_parameter-name = 'URL'.
            l_parameter-value = l_val_url.
            INSERT l_parameter INTO TABLE l_parameter_list.
            lo_win_cntr->if_wd_view_controller~fire_plug( EXPORTING plug_name = 'EXIT_PLUG'
                                                                    parameters = l_parameter_list ).
          You can easily change this logic to exit application instead of redirecting to the site
           just changing to
           l_parameter-name = 'CLOSE_WINDOW'.

  • 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, 

Maybe you are looking for

  • Help me i lost money for nothing..

    Hello,i bought diamonds in a game called mini battle saga deluxe worth 14$ apple deducted the money 14$ in my bank account Already but in the game Game master check that all my transaction failed so i didn't get the diamonds but i lost my real money

  • Credit Limit  by specific Material (product)

    Dear Experts, Could you please suggest me any body how to maintain credit limit by specific material (Product). Let say Customer Pepsi has 3 products i.e X,Y and Z....pepsi (customer) has credit limit 100 USD. Here the customer credit limit is 100 us

  • In interactive how to use AT LINE-SELECTION WITH SET PF-STATUS

    Hi all,          I am developing an interactive report in which i am using gui status (pf-status ) for AT USER-COMMAND and AT LINE-SELECTION  event .But when i used at line-selection event is  not working with pf-status even though i use PICK functio

  • Ease in CSS fade rollovers

    Hi all, Trying to create the ease-in effect for the nav buttons, but to no avail. I've pasted in the code, but doesn't seem to target the :hover. http://makingdesign.com.au/index-new.html What am I doing wrong? Michael

  • DAL Exception: ORA-01562: failed to extend rollback segment number 4

    Hi, in our application log, we got sometimes an error ORA-01562: failed to extend rollback segment number 4 and the application hangs and some transactions are blocked. checking the aler database file, we don't found this error but it's appearing oft