• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with multiple JInternalFrames  RSS feed

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code:

When a user selects the text inside the JList, the two text fields should have data displayed. This works fine with one internal frame, but if I have multiple frames, and I click on any JList within a frame other than the internal frame that was most recently created, the text is not diplayed in the panel that I clicked on, but instead in the most recently created panel.
For example, I create 3 internal frames. I select the first one I created to be the focus, and click on the text in the JList. In the third frame created, the text is shown. If I close down the second and third frames, keeping the first one created open, and I click on the JList text, nothing happens (no errors even).
I've tried getting the focus and parent of the JList, getting an array of components from that parent and trying to set the text fields that way, but doesn't work.
The ListListener private inner class is:

Anyone have any suggestions?
Thanks!
Jason
[ March 07, 2002: Message edited by: jason adam ]
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Jason,
Just one suggestion: stop using same variable for all components. Your problem comes about because you are using the same variables:
offsetField
and
summerTimeField
You need to either 1) Use array of components or 2) use the list parent to get the textfield.
The second approach can be seen in the example below.

Regards,
Manfred.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I'll give it a try. I pretty much figured that was the issue. I started playing around with a Vector that holds all the instances of JInternalFrames, and accessing the components from that.
Appreciate the help!
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Groovy, works great!
Here's what I ended up with:

The functionality for the list and textfields isn't in yet, mainly just getting the GUI and events in place, and then will work on the "behind the scenes" stuff.
Thanks again!
[ March 07, 2002: Message edited by: jason adam ]
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,
One thing that might interest you is that the List value changed listener is actually being called twice for every selection. To avoid performing the same thing twice you should place the follow snippet as the first thing in the listener method.

Regards,
Manfred.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, was wondering why that was happening. Had a System.out.println() statement, showed anytime a list item was chosen, two prints would show, when the list was cleared or had a new set of data added, one would show. Thanks again for the tips!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!