Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Start another JFrame while in a Class that extends JFrame  RSS feed

 
Rocky Rocha
Ranch Hand
Posts: 40
Android Chrome Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, and foremost, here is the code that I am having trouble with:


What I want to do is make it so that when I press the back button in CusQuery it goes closes the CusQuery window and shows the LauncherFrame window. I have tried Thread.Sleep(); and many other things including a while loop. I have had this problem for hours.
 
Rob Camick
Ranch Hand
Posts: 2778
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I certainly am not going to read all that code.

If you have a problem then you need to learn to simplify the problem.

So you need to:

1. Create a JFrame with a button
2. add an ActionListener to the button
3. When you click the button you close the current frame and display another JFrame.

There is no need for all the other components added to the frames because you question is NOT about the components, but about the showing/hiding frames.

If you post the simplified code then maybe we can help.
 
Norm Radder
Rancher
Posts: 2037
26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have had this problem for hours.

Please explain what the problem is.  What does the existing code do?  What is the problem with what the current code does?

Note: Computer generated names are very hard to work with.  Can you change the variable names to describe the content that the variable holds?
 
Fred Kleinschmidt
Bartender
Posts: 544
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is usually not a good idea to extend JFrame.
And especially in your case, since you are not overriding any of JFrame's methods.
You also have no need for your class to extend any Component, since you do not override any GUI methods.
You should just create a JFrame, then create a JPanel and place it in the JFrame, then create all of your other components and add them to that JPanel.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!