• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel over JTextField  RSS feed

 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have a JPanel containing a JList. This panel pops up over the other components of the screen. But, if there is a JTextField behind the panel, when you click on the JPanel when the JTextField is the focus goes to the TextField.
I tried panel.grabFocus() when it pops up but this did not work.
Any ideas?
D
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
I am not sure that I shall answer today your question.
But I beleive that anybody wishing to answer needs the foll. information:
1)Is JPanel inside another container or top-level container?
2)Where is JTextField situated? In a third container or in one of two mentioned in 1)?
 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The TextField is located on the default Container of the Frame.
I also add the Panel to the same Container.
Hope this helps!
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
in first message you mention only javax.swing.* and in second message only java.awt.* classes, o-o-h.
Do you want to tell that TextField and Panel are not overlapping and you have that mentioned problem?
If you have a mixture of awt and swing components, then you must check the references from http://www.javaranch.com/ubb/Forum24/HTML/013240.html, i.e. mixing AWT and SWING components

[This message has been edited by G Vanin (edited November 21, 2001).]
 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, my mistake in the second message. All the components are Swing. Textfield should have read JTextField & Panel should have read JPanel.
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
M.b. it would be useful to remember here that:
1) setVisible() is not bringing to front, you should then call toFront()?
2)you should use repaint() for updating?
3)getContentPane()?
4)Do you use visible border over JPanel instance to see the size (your size m.b. overriden by LayoutManager)
Are JPanel and and JTextField overlapping?
5)Have setLayout(null);? or to any other or just did leave the default one?
PS. Nathan, whare are you?
[This message has been edited by G Vanin (edited November 21, 2001).]
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
I am checking this post. Bad habit finishing what I started
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
I am checking this thread...
Then I had similar difficulties. I believe everybody has those. I really wanted to come to the end of the story
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,

It sounds like you need to change your layout. CardLayout lets you have multiple "cards" that you can switch between. If you try to add components "on top of" others in other layout managers strange effects like you have mentioned may occur.

Or maybe you should open the JPanel with the JList in it in another dialog?

Just some suggestions...
-Nate
[This message has been edited by Nathan Pruett (edited November 26, 2001).]
 
Vinod Venugopal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could u pls post ur code? Then I can understand whats happening.
Vinod
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!