Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple Gui question........

Posted on 2004-04-30
3
Medium Priority
?
217 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
[X]
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
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 60 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

660 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