This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Need Your Help----JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need Your Help----JList" Watch "Need Your Help----JList" New topic

Need Your Help----JList

Jess Ishasder

Joined: Feb 19, 2002
Posts: 21
I've created a TabbedPane and put 3 panels on it.
One panel, say subpanel1_A, contains a JList object which shows 2 items--"Label_1", "Label_2". When "Label_1" is selected, a label object will be shown on subpanel1_B. Similarily, when "Label_2" is selected, another label object will be shown on subpanel1_C. The problem is I can dynamically display those objects when a specified item in the List is selected.
Followwing is part of my code:
public class Skill_1 extends JApplet{
//Define a JTabbedPane object
JTabbedPane tabbedPane=null;
//Define JPanel objects
JPanel panel1=null;
JPanel subpanel1_A = null;
JPanel subpanel1_B = null;
JPanel subpanel1_C = null;
//on subpanel1_B
JLabel lblB = null;
//on subpanel1_C
JLabel lblC = null;
JList listPanel1=null;
String[] actions={"Label_1", "Label_2"};
listPanel1 = new JList(actions);
listPanel1.addListSelectionListener(new test (this, lblB, lblC));

class test implements ListSelectionListener{
private Skill_1 myApplet;
JLabel lbl1 = null;
JLabel lbl2 = null;
public test(Skill_1 sk1, JLabel lblB, JLabel lblC)
public void valueChanged(ListSelectionEvent e){
int s = myApplet.listPanel1.getSelectedIndex();
System.out.println("********s = " + s);
else if (s==1){
}//End of valueChanged
}//End of test
Thank you for your help!!!
Jess Ishasder

Joined: Feb 19, 2002
Posts: 21
Sorry!! I mean I "can't" dynamically display those components on the panels when specified item is selected in the list object
I agree. Here's the link:
subject: Need Your Help----JList
It's not a secret anymore!