BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Please help me with this mysterious problem!!!

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE
View previous topic :: View next topic  
Author Message
Double Dragon
Guest





PostPosted: Thu May 13, 2004 11:17 pm    Post subject: Please help me with this mysterious problem!!! Reply with quote



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





PostPosted: Fri May 14, 2004 7:10 am    Post subject: Re: Please help me with this mysterious problem!!! Reply with quote



"Double Dragon" <mdoubledragon (AT) hotmail (DOT) com> writes:

Quote:
mylist.addListSelectionListener(new ListSelectionListener() //Gives
error here!!!

What error?

Back to top
Double Dragon
Guest





PostPosted: Fri May 14, 2004 12:14 pm    Post subject: Re: Please help me with this mysterious problem!!! Reply with quote



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





PostPosted: Fri May 14, 2004 12:24 pm    Post subject: Re: Please help me with this mysterious problem!!! Reply with quote

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





PostPosted: Fri May 14, 2004 9:03 pm    Post subject: Re: Please help me with this mysterious problem!!! Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.