The Artima Developer Community
Sponsored Link

Java Answers Forum
Binding a Vector index to an Item Listener

2 replies on 1 page. Most recent reply: Oct 7, 2005 5:02 AM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Binding a Vector index to an Item Listener Posted: Oct 7, 2005 3:50 AM
Reply to this message Reply
Advertisement
Ok here goes:

I have a JDialog, all Panels, JComboBoxes, JLabels that are to be added to this
JDailog are only determined at Run Time. That's not the problem, That has been
fixed with GridBag Layout and Increasing Y values of the Constraints.

The problem is when I add a JComboBox for instance I want to find the
easiest way to add an ItemListener such that when it toys with values
in a vector e.g. Vector <Integer> my_vals; i.e. I want to bind a particular
ItemListener to a particular index in the Vector...

Any suggestions.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Binding a Vector index to an Item Listener Posted: Oct 7, 2005 4:07 AM
Reply to this message Reply
Its OK I'll write a separate class that implements
ItemListener and has Custom methods such as
String getValueIWant();  

When I want a value for a particular ComboBox I'll use:
if(myPanel.getComponent(n) instanceof (JComboBox))
   comboBox.getItemListener()[i].getValueIWant();

I hope it works, else I'll get fired ;o)

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Binding a Vector index to an Item Listener Posted: Oct 7, 2005 5:02 AM
Reply to this message Reply
Worked like a charm, though with all the castings I feel
sorry for whom ever is going to maintain the code
(would be nice to find a simpler way), anyways, as
Gay - Z said:

"Im a hustler baby!"

Flat View: This topic has 2 replies on 1 page
Topic: two server and many client.... Previous Topic   Next Topic Topic: Running thread in JFrame using Jpannel

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use