wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes problem with my JFrame; JFrame not closing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with my JFrame; JFrame not closing" Watch "problem with my JFrame; JFrame not closing" New topic
Author

problem with my JFrame; JFrame not closing

mithesh raj
Greenhorn

Joined: Nov 04, 2012
Posts: 10
Hi to all,
I am having problem with my JFrame.
When I click on "Back" button, the classroom details menu appears but the classroom input JFrame stays in the background.
Please help me to correct it.

Here is my code::

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

In future, while posting code, please UseCodeTags I have added them this time for you. As you can see the tags make the code much more easier to read and understand

What is Classroomdetails

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1077
    
  10

You are having 2 frames in your code. Do you know which one you are closing?
The ActionListener is an inner class and you are calling dispose() which means the addclassroom frame is closed. Is that your intent?

Btw, the class name 'addclassroom' is a poor name. You should try and follow some coding conventions.
Also, you are having a common ActionListener in which you are checking the 'text' of the buttons and doing stuff. This is again not a great way of coding ActionListeners.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
mithesh raj
Greenhorn

Joined: Nov 04, 2012
Posts: 10
sorry about the naming conventions....... "addclassroom" is the name of this input form.... When I click on the "Back" button, it should close "addclassroom" to open "Classroomdetails". But this is not the case.

Again when I click on "Save" button...a new form appears while the other one still remains on the background.

Only one form should appear at a time.

I am having problem with both "Save" and "Back" button. Please help me friends.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1077
    
  10

You have too many frames. You also have a ciFrame which is made visible and the "addclassroom" itself extends frame. You have also not told us about Classroomdetails.

You should have only one main frame and rest should be dialogs (JDialog).
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Dialogs should (typically) be used for additional operations and/or input related to the parent form. For switching UI screens, I would recommend something like a CardLayout
mithesh raj
Greenhorn

Joined: Nov 04, 2012
Posts: 10
For the "Save" button, its working.

But I am still having problem with "Back" button... the "Classroomdetails" , which is a sub menu, appears...however the "addclassroom" form still remains in the background.

Please help me.

Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1077
    
  10

You have already been provided help:

Ranganathan Kaliyur Mannar wrote:You have too many frames.

Maneesh Godbole wrote:For switching UI screens, I would recommend something like a CardLayout


So, use only one main frame and use CardLayout to switch screens. Make these changes and if you run into problems, let us know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with my JFrame; JFrame not closing