This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opening a JFrame

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, if I have a JFrame which has just been closed, using the X button at the top.

Then this JFrame object is not null and it is not visible, but when I call .setVisible(true),
it still does not appear.

Can anyone help?

Thanks
 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Change the default to hide the frame.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that, but how do I reopen it, don't want to instantiate it again.

Thanks
 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE showing the problem.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heres sample code



When we just keep pressing the button, it updates the JFrame as expected.
But when the JFrame is closed, it is not null, and calling reset does not display it.

Can anyone get the frame to display if it is closed with the X, thanks
 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but when I call .setVisible(true), it still does not appear.


I don't see where you invoke setVisible(true) again.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh.


I put

if 'not visible', make visible, but missed off the not ( ! )

Which is why it didn't do that, and remained invisible

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic