Cannot find Symbol Color.XXX in class color

Hi guys,

I'm not sure which part of the programm actually creates the error, but whenever I compile a programm where I've used e.g. labels with a specific color for the font, I get every single time since 1 month the same error message:

Compiliere C:\Dokumente und Einstellungen\Michael\Desktop\Javaeditor\Frame\methoden.java mit Java-Compiler

methoden.java:49:32: cannot find symbol

symbol : variable WHITE

location:class Color

textfield.setBackground(Color.WHITE);

^

The strange thing is that I wrote a simple programm where I used the same commands half a year ago on the same computer, and it worked perfectly!!

But since a month I get those errors without having done anything to the computer! I didn't install anything. It's an old notebook just for the java programming we're doing in school, that's why I don't need to install anything. By the way, the error appeared when I still had Java 5 installed. But even the complete deinstallation of the old java version and an update to the latest version couldn't solve the problem.

Can anyone help, please?

[1170 byte] By [Terrorfuchsa] at [2007-11-27 2:36:36]
# 1
G黷en tag Michael,>programmprogram because this is an English forum ; ) Sorry, it was just a little joke.do you have import java.awt.Color; in the beginning of your java file ?plz, post the whole code and tell us what JDK or JRE are you using.
java_2006a at 2007-7-12 2:56:03 > top of Java-index,Desktop,Core GUI APIs...
# 2

I got the files from my teacher at school. They say it's the JDK 6 and JRE 6 - Update 1. And i do have imported the java.awt.Color at the beginning of my file.

Here's the whole code, but don't tell me what I can do better about the code, I know it's nothing really good^^

Oh, and by the way, I imported all those files just to test if it would work better with having imported all of these, but it did not help at all.

import java.awt.*;

import java.awt.color.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.text.*;

import java.text.*;

// Autor: Michael Cybulski

// Datum: 01.03.2007

public class BMI extends JFrame {

// Anfang Variablen

private JLabel lbl_01 = new JLabel();

private JLabel lbl_02 = new JLabel();

private JTextField txt_01 = new JTextField();

private JLabel lbl_03 = new JLabel();

private JLabel lbl_04 = new JLabel();

private JTextField txt_02 = new JTextField();

private JLabel lbl_05 = new JLabel();

private JLabel lbl_06 = new JLabel();

private JRadioButton rd_01 = new JRadioButton();

private JRadioButton rd_02 = new JRadioButton();

private JButton bt_01 = new JButton();

private JLabel lbl_07 = new JLabel();

private String[] jList1Daten = {};

private JPanel jButtonGroup1Panel = new JPanel();

private String[] combo_01Daten = {"00 - 24", "25 - 34", "35 - 44", "45 - 54", "55 - 64", "65+"};

private JComboBox combo_01 = new JComboBox(combo_01Daten);

private JLabel lbl_08 = new JLabel();

private JLabel lbl_10 = new JLabel();

private JLabel lbl_11 = new JLabel();

private JLabel lbl_bmi = new JLabel();

private JLabel lbl_12 = new JLabel();

private JLabel lbl_kat = new JLabel();

private JLabel lbl_13 = new JLabel();

private JLabel lbl_erg = new JLabel();

private JLabel lbl_14 = new JLabel();

private JButton bt_02 = new JButton();

double bmi01, txt01, txt02;

int combo, untergrenze, obergrenze;

String bmi_text, kategorie, ergebniss;

boolean vis01,vis02;

DecimalFormat df = new DecimalFormat("00.00");

// Ende Variablen

public BMI(String title) {

// Frame-Initialisierung

super(title);

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent evt) { System.exit(0); }

});

int frameWidth = 400;

int frameHeight = 400;

setSize(frameWidth, frameHeight);

Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

int x = (d.width - getSize().width) / 2;

int y = (d.height - getSize().height) / 2;

setLocation(x, y);

Container cp = getContentPane();

cp.setLayout(null);

// Anfang Komponenten

lbl_01.setBounds(96, 24, 245, 56);

lbl_01.setText("BMI Berechnung");

lbl_01.setFont (new Font("Chiller", Font.ITALIC, 39));

lbl_01.setForeground(Color.black);

cp.add(lbl_01);

lbl_02.setBounds(16, 120, 81, 27);

lbl_02.setText("Gewicht");

lbl_02.setFont (new Font("Times New Roman", Font.PLAIN, 21));

lbl_02.setForeground(Color.BLACK);

cp.add(lbl_02);

txt_01.setBounds(16, 160, 81, 24);

txt_01.setEditable(true);

txt_01.setBackground(Color.WHITE);

txt_01.setText("");

txt_01.setDocument(new IntegerDocument());

cp.add(txt_01);

lbl_03.setBounds(39, 188, 39, 19);

lbl_03.setText("In Kg");

lbl_03.setFont (new Font("Times New Roman", Font.PLAIN, 15));

lbl_03.setForeground(Color.BLACK);

cp.add(lbl_03);

lbl_04.setBounds(288, 120, 60, 27);

lbl_04.setText("Gr鲞e");

lbl_04.setFont (new Font("Times New Roman", Font.PLAIN, 21));

lbl_04.setForeground(Color.BLACK);

cp.add(lbl_04);

txt_02.setBounds(283, 160, 81, 24);

txt_02.setEditable(true);

txt_02.setBackground(Color.WHITE);

txt_02.setText("");

txt_02.setDocument(new IntegerDocument());

cp.add(txt_02);

lbl_05.setBounds(304, 188, 34, 19);

lbl_05.setText("In cm");

lbl_05.setFont (new Font("Times New Roman", Font.PLAIN, 15));

lbl_05.setForeground(Color.BLACK);

cp.add(lbl_05);

lbl_06.setBounds(136, 120, 107, 27);

lbl_06.setText("Geschlecht");

lbl_06.setFont (new Font("Times New Roman", Font.PLAIN, 21));

lbl_06.setForeground(Color.BLACK);

cp.add(lbl_06);

rd_01.setBounds(136, 168, 113, 17);

rd_01.setFont (new Font("Times New Roman", Font.PLAIN, 14));

rd_01.setForeground(Color.BLACK);

rd_01.setSelected(false);

rd_01.setText("M鋘nlich");

cp.add(rd_01);

rd_01.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {

rd_01ActionPerformed(evt);

}

});

rd_02.setBounds(136, 192, 113, 17);

rd_02.setFont (new Font("Times New Roman", Font.PLAIN, 14));

rd_02.setForeground(Color.BLACK);

rd_02.setSelected(false);

rd_02.setText("Weiblich");

cp.add(rd_02);

rd_02.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {

rd_02ActionPerformed(evt);

}

});

bt_01.setBounds(240, 264, 125, 25);

bt_01.setFont (new Font("Comic Sans MS", Font.PLAIN, 15));

bt_01.setForeground(Color.BLACK);

bt_01.setText("Berechnen");

cp.add(bt_01);

bt_01.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {

bt_01ActionPerformed(evt);

}

});

lbl_07.setBounds(72, 232, 83, 27);

lbl_07.setText("Ihr Alter");

lbl_07.setFont (new Font("Times New Roman", Font.PLAIN, 21));

cp.add(lbl_07);

combo_01.setBounds(48, 264, 145, 24);

combo_01.setBackground(Color.WHITE);

cp.add(combo_01);

lbl_08.setBounds(32, 312, 350, 21);

lbl_08.setText("");

lbl_08.setFont (new Font("Times New Roman", Font.PLAIN, 17));

lbl_08.setForeground(Color.BLACK);

cp.add(lbl_08);

//Anfang Komponenten f黵 Ergebniss-Fenster

lbl_10.setBounds(96, 24, 245, 56);

lbl_10.setText("BMI Berechnung");

lbl_10.setFont(new Font("Chiller", Font.ITALIC, 39));

lbl_10.setForeground(Color.BLACK);

cp.add(lbl_10);

lbl_10.setVisible(false);

lbl_11.setBounds(40, 144, 164, 27);

lbl_11.setText("Ihr BMI betr鋑t:");

lbl_11.setFont(new Font("Times New Roman", Font.ITALIC, 21));

lbl_11.setForeground(Color.BLACK);

cp.add(lbl_11);

lbl_11.setVisible(false);

lbl_bmi.setBounds(604, 3, 400, 400);

lbl_bmi.setText(bmi_text);

lbl_bmi.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));

cp.add(lbl_bmi);

lbl_bmi.setVisible(false);

lbl_12.setBounds(40, 200, 72, 20);

lbl_12.setText("Kategorie:");

lbl_12.setFont(new Font("MS Sans Serif", Font.PLAIN, 15));

lbl_12.setForeground(Color.BLACK);

cp.add(lbl_12);

lbl_12.setVisible(false);

lbl_kat.setBounds(128, 200, 200, 20);

lbl_kat.setText(kategorie);

lbl_kat.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));

cp.add(lbl_kat);

lbl_kat.setVisible(false);

lbl_13.setBounds(40, 248, 75, 20);

lbl_13.setText("Ergebniss:");

lbl_13.setFont(new Font("MS Sans Serif", Font.PLAIN, 15));

lbl_13.setForeground(Color.BLACK);

cp.add(lbl_13);

lbl_13.setVisible(false);

lbl_erg.setBounds(120, 248, 270, 43);

lbl_erg.setText(ergebniss);

lbl_erg.setFont(new Font("Chiller", Font.PLAIN, 31));

lbl_erg.setForeground(Color.BLACK);

cp.add(lbl_erg);

lbl_erg.setVisible(false);

lbl_14.setBounds(40, 224, 53, 14);

lbl_14.setText("(Laut Arzt)");

lbl_14.setFont(new Font("Times New Roman", Font.PLAIN, 11));

cp.add(lbl_14);

lbl_14.setVisible(false);

bt_02.setBounds(40, 312, 100, 25);

bt_02.setFont (new Font("Chiller", Font.PLAIN, 21));

bt_02.setForeground(Color.BLACK);

bt_02.setText("Nochmal");

cp.add(bt_02);

bt_02.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {

bt_02ActionPerformed(evt);

}

});

bt_02.setVisible(false);

bt_02.setEnabled(false);

// Ende Komponenten f黵 Ergebniss-Fenster

// Ende Komponenten

setResizable(false);

setVisible(true);

}

// Anfang Ereignisprozeduren

public void bt_01ActionPerformed(ActionEvent evt) {

//Variablen

try{

Integer.parseInt(txt_01.getText().toString());

}

catch(Exception ex){

Toolkit.getDefaultToolkit().beep();

lbl_08.setText("Sie haben ihr Gewicht nicht angegeben!");

return ;

}

try{

Integer.parseInt(txt_02.getText().toString());

}

catch(Exception ex)

{

Toolkit.getDefaultToolkit().beep();

lbl_08.setText("Sie haben ihre Gr鲞e nicht angegeben!");

return ;

}

if (rd_01.isSelected() == true ){

}

else{

if (rd_02.isSelected() == true ){

}

else{

Toolkit.getDefaultToolkit().beep();

lbl_08.setText("Sie haben ihr Geschlecht nicht angegeben!");

return ;

}

}

txt01 = Double.parseDouble(txt_01.getText());

txt02 = Double.parseDouble(txt_02.getText());

//Ende Variablen

bmi01 = txt01/((txt02/100)*(txt02/100));

bmi_text = df.format(bmi01);

if(combo_01.getSelectedItem().toString().equals("00 - 24")){

untergrenze = 19;

obergrenze = 24;

}

else{

if(combo_01.getSelectedItem().toString().equals("25 - 34")){

untergrenze = 20;

obergrenze = 25;

}

else{

if(combo_01.getSelectedItem().toString().equals("35 - 44")){

untergrenze = 21;

obergrenze = 26;

}

else{

if(combo_01.getSelectedItem().toString().equals("45 - 54")){

untergrenze = 22;

obergrenze = 27;

}

else{

if(combo_01.getSelectedItem().toString().equals("55 - 64")){

untergrenze = 23;

obergrenze = 28;

}

else{

untergrenze = 24;

obergrenze = 29;

}

}

}

}

}

if (rd_01.isSelected() == true ){

untergrenze = untergrenze + 1;

obergrenze = obergrenze + 1;

}

else{

}

if (bmi01 <= untergrenze){

ergebniss = "Vorsicht, sie sind zu d黱n!";

}

else{

if (bmi01 >= obergrenze){

ergebniss = "Sie haben 躡ergewicht!!!";

}

else{

ergebniss = "Alles im Gr黱en Bereich";

}

}

if (bmi01 <= 18.5){

kategorie = "Untergewicht";

}

else{

if (bmi01 <= 25){

kategorie = "Normalgewicht";

}

else{

if (bmi01 <= 30){

kategorie = "Pr鋋dipositas";

}

else{

if (bmi01 <= 35){

kategorie = "Adipositas Grad I";

}

else{

if (bmi01 <= 40){

kategorie = "Adipositas Grad II";

}

else{

kategorie = "Adipositas Grad III";

}

}

}

}

}

vis01 = false;

vis02 = true;

lbl_01.setVisible(vis01);

lbl_02.setVisible(vis01);

lbl_03.setVisible(vis01);

lbl_04.setVisible(vis01);

lbl_05.setVisible(vis01);

lbl_06.setVisible(vis01);

lbl_07.setVisible(vis01);

lbl_08.setVisible(vis01);

txt_01.setVisible(vis01);

txt_02.setVisible(vis01);

rd_01.setVisible(vis01);

rd_02.setVisible(vis01);

bt_01.setVisible(vis01);

bt_01.setEnabled(vis01);

combo_01.setVisible(vis01);

lbl_bmi.setText(bmi_text);

lbl_kat.setText(kategorie);

lbl_erg.setText(ergebniss);

lbl_10.setVisible(vis02);

lbl_11.setVisible(vis02);

lbl_bmi.setVisible(vis02);

lbl_12.setVisible(vis02);

lbl_kat.setVisible(vis02);

lbl_13.setVisible(vis02);

lbl_erg.setVisible(vis02);

lbl_14.setVisible(vis02);

bt_02.setVisible(vis02);

bt_02.setEnabled(vis02);

return;

}

public void rd_01ActionPerformed(ActionEvent evt) {

rd_02.setSelected(false);

}

public void rd_02ActionPerformed(ActionEvent evt) {

rd_01.setSelected(false);

}

public void bt_02ActionPerformed(ActionEvent evt) {

vis02 = false;

vis01 = true;

lbl_01.setVisible(vis01);

lbl_02.setVisible(vis01);

lbl_03.setVisible(vis01);

lbl_04.setVisible(vis01);

lbl_05.setVisible(vis01);

lbl_06.setVisible(vis01);

lbl_07.setVisible(vis01);

lbl_08.setVisible(vis01);

txt_01.setVisible(vis01);

txt_02.setVisible(vis01);

rd_01.setVisible(vis01);

rd_02.setVisible(vis01);

bt_01.setVisible(vis01);

bt_01.setEnabled(vis01);

combo_01.setVisible(vis01);

lbl_10.setVisible(vis02);

lbl_11.setVisible(vis02);

lbl_bmi.setVisible(vis02);

lbl_12.setVisible(vis02);

lbl_kat.setVisible(vis02);

lbl_13.setVisible(vis02);

lbl_erg.setVisible(vis02);

lbl_14.setVisible(vis02);

bt_02.setVisible(vis02);

bt_02.setEnabled(vis02);

txt_01.setText("");

txt_02.setText("");

rd_01.setSelected(false);

rd_02.setSelected(false);

return;

}

// Ende Ereignisprozeduren

public static void main(String[] args) {

new BMI("BMI");

}

// Anfang Spezialereignisse

public class IntegerDocument extends PlainDocument

{

public void insertString(int offset, String s, AttributeSet attributeSet)

throws BadLocationException

{

try{

Integer.parseInt(s);

}

catch (Exception ex) {

Toolkit.getDefaultToolkit().beep();

return;

}

super.insertString(offset, s, attributeSet);

}

}

// Ende Spezialereignisse

}

Terrorfuchsa at 2007-7-12 2:56:03 > top of Java-index,Desktop,Core GUI APIs...