【发布时间】:2013-12-14 04:28:09
【问题描述】:
所以我目前正在用一本大学的 java 书自学 GUI 编码,我理解这一切,但我遇到了这个错误,我很难过。
import javax.swing.*;
import BreezySwing.*;
public class gui
{
public class ConvertWithGUI extends GBFrame
{
private JLabel fahrenheitLabel;
private JLabel celsiusLabel;
private DoubleField fahrenheitField;
private DoubleField celsiusField;
private JButton fahrenheitButton;
private JButton celsiusButton;
public ConvertWithGUI()
{
fahrenheitLabel = addLabel ("Fahrenheit" ,1,1,1,1);
celsiusLabel = addLabel ("Celsius" ,1,2,1,1);
fahrenheitField = addDoubleField (32.0 ,2,1,1,1);
celsiusField = addDoubleField (0.0 ,2,2,1,1);
fahrenheitButton= addButton (">>>>>>" ,3,1,1,1);
celsiusButton = addButton ("<<<<<<" ,3,2,1,1);
}
public void buttonClicked (JButton buttonObj)
{
Thermometer thermo = new Thermometer();
if (buttonObj == fahrenheitButton)
{
thermo.setFahrenheit(fahrenheitField.getNumber());
celsiusField.setNumber (thermo.getCelsius());
}
else
{
thermo.setCelsius(celsiusField.getNumber());
fahrenheitField.setNumber (thermo.getFahrenheit());
}
}
public static void main(String[] args)
{
ConvertWithGUI theGUI = new ConvertWithGUI();
theGUI.setSize(250, 100);
theGUI.setVisible(true);
}
}
}
好的,直到标记的部分为止:
ConvertWithGUI theGUI = new ConvertWithGUI();
导致错误。更具体地说,它在这部分突出显示:
new ConvertWithGUI();
现在这个程序的基本功能是转换和转换摄氏温度。我知道这很简单,但我不知道这个错误是什么,我正在从书中准确地输入这个错误。 如果有人可以提供帮助,我们将不胜感激!谢谢。
【问题讨论】:
标签: java swing class breeze non-static