Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Simple Gui question........

Posted on 2004-04-30
3
213 Views
Last Modified: 2010-03-31
I have a class which shows a gui
As well as that there are action listeners for various button-presses, apart from that, nothing else.

When one of the buttons is pressed, within the action listener i call a second class........

mainGui.butStart.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
            callConnect = new Connect();
           callConnect.callResponder(mainGui);
        } /* end actionPerformed */  
}); /* end addActionListener */

This class also shows a gui.

When the cancel button on that gui is pressed, as follows.........i want it to return to the previous gui, but when i do that the first gui disappears as well. How can i stop that?

settingsGui.butCancel.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
                           
               mG.butStart.setEnabled(true);
             mG.butStop.setEnabled(false);
               
                settingsGui.hide();
           
           
           }
 });    


How come when i do the .hide(), the other gui disappears also and how do i stop it from happening?
0
Comment
Question by:vinoboy
3 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10964561
settingsGui is a panel? JFrame?

if you want both of them open are you refering to like a MDI model? (Multiple Document Interface) an example of this model is Ms Word version 97 where there was one big window (parent window) and mulitple other windows (child) anyways I'm sure you know what I'm talking about.

is that what you want?
You can look into the JInternalFrame and the JDesktopFrame classes for more information
Cheers,
Ghost
0
 

Author Comment

by:vinoboy
ID: 10965240
Both the first gui (mainGui) and the second one (settingsGui) are JFrames.

When i click a 'Cancel' button on the second gui (settingsGui) why does the gui behind it (mainGui)also disappear? And how can i solve it?

0
 
LVL 7

Accepted Solution

by:
maheshexp earned 30 total points
ID: 10965356

class Frame1 extends JFrame {
      public Frame1() {
            setSize(200, 300);
            JButton b = new JButton("Open");
            b.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                        new Frame2(Frame1.this); ---> referes to the class Frame1
                  }
            });
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.getContentPane().add(b);
            this.show();
      }
}

class Frame2 extends JFrame {
      public Frame2(final JFrame caller) {
            setSize(200, 300);
            JButton b = new JButton("Close");
            b.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                        caller.show();
                        Frame2.this.hide();
                  }
            });
            this.getContentPane().add(b);
            this.show();
      }
}

public class Test6 {

      public static void main(String[] args) {
            new Frame1();
      }
}
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question