Hey - Sorry if this is an irritatingly simple problem, but I'm a newbie to the Java language and I can't see where I'm going wrong with this. I get an error with my code when trying to define 'label3' - "cannot find symbol - class Jlabel". It seems to work fine with 'label' and 'label2', but not 'label3' ! Why is this? I would really appreciate any help you could give...

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*  ;

// Class definition

public class IfElseDemo extends JPanel implements ChangeListener {

    // Local variable declarations
    private JLabel label, label2, label3;
    private JSlider slider, slider2;
    private int value = 1;
       
    // Constructor method declaration

    public IfElseDemo() {
        
        // Local variable declarations
        int minValue = 0;
        int maxValue = 100;
        int initValue = value;

       // Use the BorderLayout layout manager
       setLayout(new BorderLayout());

       // Instantiate a slider using Swing class JSlider  
       slider = new JSlider(JSlider.VERTICAL, minValue, maxValue, initValue);
       slider2 = new JSlider(JSlider.VERTICAL, minValue, maxValue, initValue);
       // Add the slider to the north portion of the JPanel
       add(slider, BorderLayout.WEST);
       add(slider2, BorderLayout.EAST);

       // Register the slider with Java
       slider.addChangeListener(this); 
       slider2.addChangeListener(this);
       // Instantiate labels reporting the current value of the slider
       label = new JLabel("Value: " + value + "%");
       label2 = new JLabel();
       label3 = new Jlabel ("Value: " + value + "%");

       // Add the labels to the panel
       add(label,BorderLayout.CENTER);
       add(label2.BorderLayout.WEST);
       add(label3,BorderLayout.SOUTH);
       
       // Create a new window using the Swing class JFrame and add this panel
       makeFrame();
    }
.....
   
}

Recommended Answers

All 4 Replies

Java is case sensitive. Jlabel != JLabel

Check your spelling. Java is case sensitive.

you don't have a capital L in label3 = new JLabel

God Dammit! I KNEW it would be something as blatantly obvious as that.:$

Thanks very much guys!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.