• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

close and open a frame

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you try frame.setVisible(false)
 
Ranch Hand
Posts: 441
Scala IntelliJ IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Scala IntelliJ IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23931
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

Henry
 
reply
    Bookmark Topic Watch Topic
  • New Topic