現在我工作的,它使用的JButton類(在網上搖擺教程中)的GUI程序,使用此代碼:Java小程序的JButton錯誤
import javax.swing.JButton;
public class HelloWorld extends java.applet.Applet {
public static void main(String[] args) {
@ConstructorProperties(value="Click")
public JButton(String Click); //identifier expected and ; expected error from here
drawString("test",50,25);
}
}
編譯器給出了一個「預期標識符」錯誤和「預期錯誤」。爲什麼是這樣,我該怎麼做?
*「在網上的Swing教程中」。順便說一句 - 1)爲什麼編寫一個小程序?如果是由於老師指定它,請將它們轉介給[爲什麼CS教師應該**停止**教Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should -stop教學-java的小應用程序/)。 2)爲什麼使用AWT?看到[這個答案](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978)有很多很好的理由放棄AWT使用組件有利於Swing。 – 2014-12-19 01:16:51