• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

close window when new one opens

 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've made a menu screen that has a series of buttons that, when clicked on, open up a new window. I want the menu screen to close when a button is clicked and the new window pops up but I can't figure out how to get it to work. Its not a big deal, just a little nuisance thats drivin' me nuts. Any ideas?
 
Ben Zung
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know which part you could not figure out. Do you have some code at all? If you can post them you may get more help.

Good Luck.
 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a login screen, which takes in a user ID and last name and checks it against a text file. After the user has logged in a menu pops up with various buttons that, when clicked on, open up new forms. When the user logs in I want the login screen to no longer be visible after the menu screen pops up. Part of the problem may be that I have setVisible for the screen in its own seperate run method, do you think that I should change my code so it works in the action listener? I was avoiding that at all possible costs as the frames for all of the windows I've made are coded like that.


[ March 20, 2006: Message edited by: Brandi Love ]
 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the code for the menu screen as well, I'm not sure whether I need to code it into the login screen or menu screen...

 
Ben Zung
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a little quick way to do what you wanted.
Move the JFrame variable in your run method in LoginScreen up to be a class level variable(don't forget to say static). And after you verified the 4-digit id, in front of run(new MenuScreen()...) add this code
frame.setVisible(false);
this ought to get rid of the login screen.

Good luck.
 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made those changes, but now when I click the logon button it, for lack of a better word, melded with the menu screen to make this:



Here's the changes I made to the code, bolded...

 
Ben Zung
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot to mention, instead of

call it static way

should get rid of the overlap. And if not
try add

to force a paint.
[ March 20, 2006: Message edited by: Ben Zung ]
 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yay, that fixed it! Thanks Ben!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic