Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing GUI working not properly

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm making a gui of the kind in which i want to display the textfield's content into the panel below it as soon as the button "ADD" is pressed.But i'm not able to do this .I've tried out all the possibilities i could think but, no results.
What's happening in the code below is that when the frame is getting maximised the contents of the tree are getting displayed.But i need the simultaneous display of the contents in the textfield into the panel below it.SO,if anybody can help me sort out this problem,I'will be thankful to him.

THE CODE IS GIVEN BELOW:



[Added Code Tags - Gregg Bolinger]
[ February 08, 2005: Message edited by: Gregg Bolinger ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use code tags. You can add them to your post by using the edit button at the upper right of it. Thanks!
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Swing forum...
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first problem I see is that you are adding your text from you JTextField to an ArrayList and then as you loop over the collection you create a tree for every single entry in the ArrayList. However, you never do anything with the actual text from the textfield beyond passing it to the tree(String s) method. I don't think you meant to perform this logic.

That aside, if you add panel2.validate(); just below your call to the show() method in your ActionListener, the JTree will show up after you click the Add button.
 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the replies.
Jignesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic