0
public class J_01_FLOW_08 extends JApplet implements ActionListener
{
    String s_value[]={"white sox","red sox","mets","cordianls","blue jays"};
    JList l_list = new JList(s_value);

    JLabel l_label = new JLabel();


    Container c;
    FlowLayout flow = new FlowLayout();


    public void init()
    {
        c = getContentPane();
        c.setLayout(flow);

        c.add(l_list);
        c.add(b);

        l_list.addActionListener(this);
    }


    public void actionPerformed(ActionEvent e) 
    {
        String pick = l_list.getSelectedItem().toString();

        if(l_list.isSelected() == true) 
            l_label.setText(pick);
        }
}

getting error at

l_list.addActionListener(this);




String pick = l_list.getSelectedItem().toString();






 if(l_list.isSelected() == true) 

i dont know how to fix this

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by JamesCherrill
0

You fix it by looking at the API documentation for JList and using method names that are documented there. You didn't post the error messages like you should, but each of those 3 lines tries to call a method that doesn't exist for JList. You can't just guess or make up methoid names for API classes.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.