그래서 현재 저는 대학용 자바 서적으로 GUI 코딩을 가르치고 있습니다. 그러나이 오류는 모두 이해할 수 있습니다.정적이 아닌 변수 정적 콘텐츠에서 참조 할 수 없습니다. Java
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();
이제이 프로그램의 기본 기능은 섭씨로 변환하고 섭씨로 변환하는 것입니다. 그것은 간단하지만 나는이 오류가 무엇인지 모르겠다. 나는이 책에서 정확히 입력하고있다. 누구든지 도움을받을 수 있다면 감사하겠습니다! 고맙습니다.
고마워요! 어리석은 작은 실수는 간과 했어. 다시 한 번 감사드립니다! –