Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Layout Problem  RSS feed

 
Fran Varin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am in the process or writing a class that has a simple menu at the top of the JFrame with a textarea below it. When the frame appears I can see the menu but, when I select an item on the menu it appears to be "under" the text area. When I remove the building of the textarea and contentpane the menu works fine. Here is a snipit of code:

Container c = getContentPane();

setTitle("Console");
setSize(width,height);
setJMenuBar(buildMenu());
c.setLayout(new BorderLayout());
c.add("Center" , aTextArea);


aTextArea is defined as an AWT TextArea. The stuff which is happening here is very simple but, I cannot seem to figure out why I'm seeing the behavior I am. The irony is that I'm sure it is something simple that I've overlooked.

Any help would be appreciated.
Fran
 
Fran Varin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK...so I spend a lot of time doing server coding and not swing... I changed the TextArea to a JTextArea and all is well. Can someone explain this behavior or where it may be documented?
 
Michael Dunn
Ranch Hand
Posts: 4632
 
Fran Varin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
Thank you...I was not aware that the article you pointed out existed. As I mentioned, I don't spend alot of time writing GUI APPS...thanks for your help that cleared it up for me.

Fran
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!