Scope of a JLabel? Also "unchecked operation"
I'm quite new to Java, so I expect what I'm asking is fairly basic, but I
can't find it in my Java book, so I'd be glad if someone could explain very
simply what's the matter.
1)The program I'm writing is called Vectorine, never mind why. Lately I get
this when I compile it: "[...]Vectorine.java uses unchecked or unsafe
operations. Recompile with -Xlint: unchecked for details." It doesn't seem
to stop it running, though, when I comment out the bit that causes problem
2). It didn't do it before I introduced some Swing components. What is
this? Does it matter?
2) The itemStateChanged method can't recognise a perfectly good JTextArea
that I want it to output to, just keeps saying that there is no variable
called "display". Replacing the JTextArea with a JLabel doesn't help, and
in either case they appear all right. It's only the method that can't see
them. Is this about variable scope? My Java book isn't very clear about
This is the program, minus some methods that don't take part in the
public class Vectorine extends JFrame implements ItemListener
// Set up window's initial contents
Container contentArea = getContentPane();
FlowLayout layout = new FlowLayout();
Image picture = Toolkit.getDefaultToolkit().getImage("RobotA.gif");
ImageIcon icon = new ImageIcon(picture);
JLabel picLabel = new JLabel(icon);
JTextField fileslot = new JTextField(20);
JComboBox types = new JComboBox();
JTextArea display = new JTextArea("Type here.", 4, 18);
JScrollPane displayPane = new JScrollPane(display,
public void itemStateChanged(ItemEvent event)
String choice = event.getItem().toString();
display.setText("Option chosen: "+choice); // This is where the
compiler sticks; says it can't find any object called "display".
public static void main()
// show the window
Vectorine v = new Vectorine();
My e-mail address is zen177395 at zendotcodotuk, though I don't check that
account very often.
Post unto others as you would have them post unto you.