为啥这个文件用JAVAC和JAVA可以运行,但是用NETBEANS运行不了.
为什么这个文件用JAVAC和JAVA可以运行,但是用NETBEANS运行不了.....import?java.awt.* ??import?java.awt
为什么这个文件用JAVAC和JAVA可以运行,但是用NETBEANS运行不了.....
- import?java.awt.*; ??
- import?java.awt.event.*; ??
- import?javax.swing.*; ??
- public?class?Calculator?{ ??
- ???? ??
- ????/** ?
- ?????*?Creates?a?new?instance?of?Calculator ?
- ?????*?@param?args? ?
- ?????*/??
- ????public?static?void?main(String[]?args)?{ ??
- ????????CalFrame?frame=new?CalFrame(); ??
- ????????frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ??
- ????????frame.show(); ??
- ????} ??
- ???? ??
- ???? ??
- } ??
- class?CalFrame?extends?JFrame{ ??
- ????public?CalFrame(){ ??
- ????????setTitle("龙斌原创计算器程序"); ??
- ????????setSize(300,300); ??
- ????????Container?contentPane=getContentPane(); ??
- ????????CalPanel?panel=new?CalPanel(); ??
- ????????contentPane.add(panel); ??
- ????????pack(); ??
- ???????? ??
- ????} ??
- } ??
- class?CalPanel?extends?JPanel{ ??
- ????public?CalPanel(){ ??
- ????????setLayout(new?BorderLayout()); ??
- ????????result=0; ??
- ????????lastCommand="="; ??
- ????????start=true; ??
- ????????display=new?JLabel("0"); ??
- ????????add(display,BorderLayout.NORTH); ??
- ????????ActionListener?insert=new?InsertAction(); ??
- ????????ActionListener?command=new?CommandAction(); ??
- ???????? ??
- ????????panel=new?JPanel(); ??
- ????????panel.setLayout(new?GridLayout(4,4)); ??
- ????????addButton("7",insert); ??
- ????????addButton("8",insert); ??
- ????????addButton("9",insert); ??
- ????????addButton("/",command); ??
- ???????? ??
- ????????addButton("4",insert); ??
- ????????addButton("5",insert); ??
- ????????addButton("6",insert); ??
- ????????addButton("*",command); ??
- ???????? ??
- ????????addButton("1",insert); ??
- ????????addButton("2",insert); ??
- ????????addButton("3",insert); ??
- ????????addButton("-",command); ??
- ???? ??
- ????????addButton("0",insert); ??
- ????????addButton(".",insert); ??
- ????????addButton("=",insert); ??
- ????????addButton("+",command); ??
- ???????? ??
- ????????add(panel,BorderLayout.CENTER); ??
- ????} ??
- ???? ??
- ????private?void?addButton(String?label,ActionListener?listener){ ??
- ????????JButton?button=new?JButton(label); ??
- ????????button.addActionListener(listener); ??
- ????????panel.add(button); ??
- ????} ??
- ???? ??
- ????private?class?InsertAction?implements?ActionListener{ ??
- ????????public?void?actionPerformed(ActionEvent?event){ ??
- ????????????String?input=event.getActionCommand(); ??
- ????????????if(start){ ??
- ????????????????display.setText(""); ??
- ????????????????start=false; ??
- ????????????} ??
- ????????????display.setText(display.getText()+input); ??
- ????????} ??
- ????} ??
- ????private?class?CommandAction?implements?ActionListener{ ??
- ????????public?void?actionPerformed(ActionEvent?evt){ ??
- ???????????String?command=evt.getActionCommand();? ??
- ???????????if(start){ ??
- ???????????????if(command.equals("-")){ ??
- ???????????????????display.setText(command); ??
- ???????????????????start=false; ??
- ???????????????} ??
- ???????????????else?lastCommand=command; ??
- ???????????} ??
- ???????????else{ ??
- ???????????????calculate(Double.parseDouble(display.getText())); ??
- ???????????????lastCommand=command; ??
- ???????????????start=true; ??
- ???????????} ??
- ????????} ??
- ????} ??
- ??
- ?public?void?calculate(double?x){ ??
- ?????if(lastCommand.equals("+"))?result+=x; ??
- ?????else?if(lastCommand.equals("-"))?result-=x; ??
- ?????else?if(lastCommand.equals("*"))?result*=x; ??
- ?????else?if(lastCommand.equals("/"))?result/=x; ??
- ?????else?if(lastCommand.equals("="))?result=x; ??
- ?????display.setText(""+result); ??
- ?} ??
- ?private?JLabel?display; ??
- ?private?JPanel?panel; ??
- ?private?double?result; ??
- ?private?String?lastCommand; ??
- ?private?boolean?start; ??
- ???? ??
- } ??
- ??
?
init:
deps-jar:
compile:
compile-test:
.F
Time: 0
There was 1 failure:
1) warning(junit.framework.TestSuite$1)junit.framework.AssertionFailedError: No tests found in Calculator
FAILURES!!!
Tests run: 1,? Failures: 1,? Errors: 0
debug-test:
生成成功(总时间:1 秒)
使用NETBEANS编译就会出现如下错误: