不告訴你..
2007-03-23 13:41:01 UTC
小弟剛學java不久,
昨天再試寫 計算機 程式的時候,
compiler 盡然出現
嚜磨mport java.awt.*;
這個錯誤,是在第一行,
我第一行是寫
import java.awt.*;
怎麼找都找不到錯誤,請問有人發生過同樣的問題嘛?
如果compiler出現正常訊息我應該找的出來,,
可是出現中文字我就不知道該怎麼解決了@@
我的程式碼如下
import java.awt.*;
import java.awt.event.*;
public class Calculator implements ActionListener
{
TextField tf = new TextField();
String[] ary1 =
{"7","8","9","-","4","5","6","+","1","2","3","*","0",".","/","="};
Button[] btn = new Button[ary1.length];
public Calculator()
{
Frame f = new Frame("Calculator");
f.setSize(200,250);
f.add(tf,"North");
Panel p = new Panel();
f.add( p );
p.setLayout(new GridLayout(4,4,4,4));
for(int i=0 ; i<ary1.length ; i++){
btn[i]= new Button(ary1[i]);
p.add(btn[i]);
btn[i].addActionListener(this);
}//for
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args)
{
new Calculator();
}//main
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
tf.setText(cmd);
}
}//class
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.236.176
昨天再試寫 計算機 程式的時候,
compiler 盡然出現
嚜磨mport java.awt.*;
這個錯誤,是在第一行,
我第一行是寫
import java.awt.*;
怎麼找都找不到錯誤,請問有人發生過同樣的問題嘛?
如果compiler出現正常訊息我應該找的出來,,
可是出現中文字我就不知道該怎麼解決了@@
我的程式碼如下
import java.awt.*;
import java.awt.event.*;
public class Calculator implements ActionListener
{
TextField tf = new TextField();
String[] ary1 =
{"7","8","9","-","4","5","6","+","1","2","3","*","0",".","/","="};
Button[] btn = new Button[ary1.length];
public Calculator()
{
Frame f = new Frame("Calculator");
f.setSize(200,250);
f.add(tf,"North");
Panel p = new Panel();
f.add( p );
p.setLayout(new GridLayout(4,4,4,4));
for(int i=0 ; i<ary1.length ; i++){
btn[i]= new Button(ary1[i]);
p.add(btn[i]);
btn[i].addActionListener(this);
}//for
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args)
{
new Calculator();
}//main
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
tf.setText(cmd);
}
}//class
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.236.176