Solved

Simple Gui question........

Posted on 2004-04-30
3
210 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
Comment Utility
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
Comment Utility
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
Comment Utility

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 73
How Complex Is This Java Course ? 9 62
Books that can get me started on JAVA 2 52
github account with ecipse 1 15
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now