-
Java Newbie: Working with GUI Windows
I come from a VB background and am trying to learn java
I have been working with JDK 1.3 and learning the elements of
Swing. I have created a "form" using JFrame and have added
some buttons to it. When I click the "ADD" button I open up another
"form", again another class that creates a JFrame with components
on it. I have added an event to close the second window when
the user clicks the X button and I am trying to add an event
to a "CLOSE" button which will do the same thing (simply close
the window and return focus to the original form). So here
is what I am doing:
1. class1 creates a GUI window with buttons and textfields
2. click the 'ADD' button which calls a method in Class2
3. class2 method creates a second form or window with more buttons
and textfields
4. close the second window by hitting the X button or clicking
a close button (X works fine - close button not working)
The JFrame is public and is called frmMain1, So when I call the
openForm method in class2 from class1 I create the frmMain1 JFrame like this
-3 methods that create 3 panels containing buttons and text
-show the frmMain1.setVisible(true);
I add an ActionListener for the CLOSE button and when the user
clicks the button I use frmMain1.setVisible(false); -- doesn't work
and I don't know why? The button works because I added a
JOptionPane.showMessageDialog to be invoked when the button is clicked
but I can't get the JFrame to go away. Am I on the right path
or is there a better way to open and close multiple windows in
a single application??? Any help would be very much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks