| View previous topic :: View next topic |
| Author |
Message |
Double Dragon Guest
|
Posted: Thu May 13, 2004 11:17 pm Post subject: Please help me with this mysterious problem!!! |
|
|
I read this code again and again, but cant figure why it gives that error.
Please help me locate it..just paste it in jbuilder and it'll underline that
automatically!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class jlistdemo extends JFrame
{
private JList mylist;
private JTextField output;
private String[] names={"USA","UK","Kuwait","Bahrain"};
public jlistdemo()
{
super("JList Demo");
setSize(200,200);
setVisible(true);
Container c=getContentPane();
c.setLayout(new FlowLayout());
mylist=new JList(names);
mylist.setVisibleRowCount(2);
mylist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
mylist.addListSelectionListener(new ListSelectionListener() //Gives
error here!!!
{
public void valueChanged(ListSelectionEvent e) {
String temp = mylist.getSelectedValue().toString();
output.setText("The Capital Of " + temp);
if (temp.equals("USA")) {
output.setText(output.getText() + " Is Washington");
}
else if (temp.equals("UK")) {
output.setText(output.getText() + " Is London");
}
else if (temp.equals("Kuwait")) {
output.setText(output.getText() + " Is Kuwait City");
}
else if (temp.equals("Bahrain")) {
output.setText(output.getText() + " Is Manama");
}
}
});
c.add(new JScrollPane(mylist));
output=new JTextField(15);
output.setEditable(false);
c.add(output);
}
public static void main(String args[])
{
jlistdemo j=new jlistdemo();
j.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
e.getWindow().setVisible(false);
e.getWindow().dispose();
System.exit(0);
}
});
}
}
|
|
| Back to top |
|
 |
Tor Iver Wilhelmsen Guest
|
Posted: Fri May 14, 2004 7:10 am Post subject: Re: Please help me with this mysterious problem!!! |
|
|
"Double Dragon" <mdoubledragon (AT) hotmail (DOT) com> writes:
| Quote: | mylist.addListSelectionListener(new ListSelectionListener() //Gives
error here!!!
|
What error?
|
|
| Back to top |
|
 |
Double Dragon Guest
|
Posted: Fri May 14, 2004 12:14 pm Post subject: Re: Please help me with this mysterious problem!!! |
|
|
It says Class ListSelectionListener in class jlistdemo, cannot resolve
symbol
"Tor Iver Wilhelmsen (TeamB)" <tor.wilhelmsen (AT) ergo (DOT) no> wrote
| Quote: | "Double Dragon" <mdoubledragon (AT) hotmail (DOT) com> writes:
mylist.addListSelectionListener(new ListSelectionListener()
//Gives
error here!!!
What error?
|
|
|
| Back to top |
|
 |
Arthur Ore Guest
|
Posted: Fri May 14, 2004 12:24 pm Post subject: Re: Please help me with this mysterious problem!!! |
|
|
You are missing an import statement
import javax.swing.event.*;
Arth
"Double Dragon" <mdoubledragon (AT) hotmail (DOT) com> wrote
| Quote: | It says Class ListSelectionListener in class jlistdemo, cannot resolve
symbol
"Tor Iver Wilhelmsen (TeamB)" <tor.wilhelmsen (AT) ergo (DOT) no> wrote in message
news:un04bscvg.fsf (AT) ergo (DOT) no...
"Double Dragon" <mdoubledragon (AT) hotmail (DOT) com> writes:
mylist.addListSelectionListener(new ListSelectionListener()
//Gives
error here!!!
What error?
|
|
|
| Back to top |
|
 |
Double Dragon Guest
|
Posted: Fri May 14, 2004 9:03 pm Post subject: Re: Please help me with this mysterious problem!!! |
|
|
Thanks Sir! I am very grateful for your help!! This single statement bugged
me for days!!!
"Arthur Ore" <nospamthx_arthur (AT) nospamthx_arthurore (DOT) freeserve.co.uk> wrote in
message news:40a4ba96 (AT) newsgroups (DOT) borland.com...
| Quote: | You are missing an import statement
import javax.swing.event.*;
Arth
"Double Dragon" <mdoubledragon (AT) hotmail (DOT) com> wrote in message
news:40a4b7a9 (AT) newsgroups (DOT) borland.com...
It says Class ListSelectionListener in class jlistdemo, cannot resolve
symbol
"Tor Iver Wilhelmsen (TeamB)" <tor.wilhelmsen (AT) ergo (DOT) no> wrote in message
news:un04bscvg.fsf (AT) ergo (DOT) no...
"Double Dragon" <mdoubledragon (AT) hotmail (DOT) com> writes:
mylist.addListSelectionListener(new ListSelectionListener()
//Gives
error here!!!
What error?
|
|
|
| Back to top |
|
 |
|