-2

好的,所以我不确定为什么这个程序不起作用

线程“主”java.lang.Error 中的异常:未解决的编译问题:在 Means34.main(Means34.java:96)

即使我删除了代码行,所以没有第 96 行,我仍然会收到此消息。谁能告诉我为什么会这样?

import java.awt.*;
import BreezyGUI.*;

public class Means34 extends GBFrame{
    public Means34(){
        setTitle("Draw + means");
        red.setBackground(Color.red);
        green.setBackground(Color.green);
        pink.setBackground(Color.pink);
        blue.setBackground(Color.blue);
        magenta.setBackground(Color.magenta);
        cyan.setBackground(Color.cyan);
    }
    static Frame frm;
    Label firstNumLabel = addLabel ("Input: First Num",1,1,1,1);
    DoubleField firstNumField= addDoubleField (0,1,2,1,1);
    Label secondNumLabel = addLabel ("Input: Second Num",2,1,1,1);
    DoubleField secondNumField = addDoubleField (0,2,2,1,1);
    Label arithmeticLabel = addLabel ("Output: Arithmetic",3,1,1,1);
    DoubleField arithmeticField= addDoubleField (0,3,2,1,1);
    Label harmonicLabel = addLabel ("Output: Harmonic",4,1,1,1);
    DoubleField harmonicField= addDoubleField (0,4,2,1,1);
    Label geometricLabel = addLabel ("Output: Geometric",5,1,1,1);
    DoubleField geometricField= addDoubleField (0,5,2,1,1);
    Button convertButton= addButton ("Find Means",6,1,1,1);
    Button clearButton= addButton ("Clear",6,2,1,1);
    Label coll1Label = addLabel ("Color 1",7,1,1,1);
    Label coll2Label = addLabel ("Color 2",7,2,1,1);
    Label col1Label = addLabel ("               ",8,1,1,1);
    Label col2Label = addLabel ("               ",8,2,1,1);
    Label meancoll=addLabel ("Mean Color",7,3,1,1);
    Label meancol=addLabel ("               ",8,3,1,1);
    Button red = addButton ("               ",1,3,1,1);
    Button green = addButton ("               ",2,3,1,1);
    Button pink = addButton ("               ",3,3,1,1);
    Button blue = addButton ("               ",4,3,1,1);
    Button magenta = addButton ("              ",5,3,1,1);
    Button cyan = addButton ("               ",6,3,1,1);
    Checkbox colorone= addCheckbox("Choose first color",4,4,1,1);
    Checkbox colortwo= addCheckbox("Choose second color",5,4,1,1);



    double first;
    double second;
    double arithmetic;
    double harmonic;
    double geometric;
    Color meancolor;



    public  void colorer(Checkbox check, Button buttonObj, Button butt, Label labal, Color coler){
        if (check.getState()){
            if (buttonObj==butt){
                labal.setBackground(coler);
            }
        }
    }

    public void buttonClicked (Button buttonObj) {
        colorer(colorone, buttonObj,cyan,col1Label,Color.cyan);
        colorer(colorone, buttonObj,red,col1Label,Color.red);
        colorer(colorone, buttonObj,green,col1Label,Color.green);
        colorer(colorone, buttonObj,pink,col1Label,Color.pink);
        colorer(colorone, buttonObj,blue,col1Label,Color.blue);
        colorer(colorone, buttonObj,magenta,col1Label,Color.magenta);
        colorer(colortwo, buttonObj,cyan,col2Label,Color.cyan);
        colorer(colortwo, buttonObj,red,col2Label,Color.red);
        colorer(colortwo, buttonObj,green,col2Label,Color.green);
        colorer(colortwo, buttonObj,pink,col2Label,Color.pink);
        colorer(colortwo, buttonObj,blue,col2Label,Color.blue);
        colorer(colortwo, buttonObj,magenta,col2Label,Color.magenta);
        if (buttonObj==convertButton){
            first=firstNumField.getNumber();
            second=secondNumField.getNumber();
            arithmetic= (first + second)/2 ;
            harmonic= ((1/first) + (1/second))/2;
            geometric= Math.sqrt((first*second)) ;
            arithmeticField.setNumber(arithmetic);
            harmonicField.setNumber(harmonic);
            geometricField.setNumber(geometric);
            frm.revalidate();
        }
    }

    public void mouseDragged(int x, int y){
        Graphics l= getGraphics();
        l.setColor(Color.green);
        l.fillOval((x -50),(y - 50),10,10);
    }

    public static void main(String[] args){
        frm= new Means34();
        frm.setSize (300,300);
        frm.setVisible (True);
    }
}
4

1 回答 1

1

它对我来说编译和运行都很好,除了我必须换行

frm.setVisible (True);  

frm.setVisible (true);
于 2013-10-31T13:09:14.513 回答