• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in JInternal Frame

 
Swapnil Sonawane
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am encountering a problem in using JInternalFrame. I have a JPanel placed inside the content pane of JFrame. It has a button "Show". When I click that button, it opens the JInternalFrame as expected. But the show button stays there for a while, say for a second or two and then it disappears. I wonder why there is that delay. This code is a part of a larger application, so posting code won't help much. But has anybody of you experienced the same behaviour? Thanks.
 
Campbell Ritchie
Marshal
Posts: 52613
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be a threading problem. If it takes a long time to load the JInternalFrame, and the code to make the button disappear is after that code in your actionPerformed method, then the button will remain until after the JInternalFrame is loaded.

You can't try additional threads, because Swing components are not thread-safe, and I don't think this is the sort of thing SwingWorker was intended for.

You could try moving the "button.disappear();" call to before the "new JInternalFrame()" call and seeing whether that makes any difference.
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JInternalFrame should be added to a JDesktopPane anyhow. Not to a JFrame, not to a JPanel.

If your purpose is to visually substitute the JPanel with the JInternalFrame, you might want to take a look at CardLayout.

db
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!