Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

close and open a frame

 
kunagu varun
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends, thank you very much for your quick replies and helped me a lot to solve my previous problem.
This time i have a different question.

How do i make a frame to be hidden and open another one when a button is clicked..

I have written this code in the actionperformed event of one button in frame1


But the error i receive is show() method is deprecated and as well as frame2 is not available. I mean it is treated as an undeclared variable. The intellisense didn't recognized it.

frame1 is one java file and frame2 is another one.

Please hep me to overcome the problem...
 
John Jai
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you try frame.setVisible(false)
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
show is deprecated, and doesn't take an argument anyway, as a quick glance at the API documentation will tell you. hide was its equivalent, but you should use setVisible(false) as the poster says above.
 
kunagu varun
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.. I have used the setVisible(false) method to hide the frame1 of my first java source file. Now how can i activate and display the frame of second java source file. (i have named the frame as frame2)

I cannot use it as


The name frame2 is unrecognized by the intellisense of Eclipse IDE.. How can i activate and load the frame of second java file?

 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a variable named like that? Maybe you could show some code.
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to create an instance of the frame in your second file. i.e. if your other class is called MyFrame, and extends JFrame, you will need something like Try a book like Head First Java to get you going.
 
Henry Wong
author
Sheriff
Posts: 22542
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Topic moved to the Swing forum; as it's probably a more appropriate location.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!