这是照着课本打的,怎么显示这样错误:Exception in thread "main" java.lang.NoSuchMethodError:
importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassWelcomeTest{pu...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WelcomeTest {
public static void main(String[] args) {
WelcomeFrame frame=new WelcomeFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class WelcomeFrame extends JFrame{
public WelcomeFrame(){
setTitle("Welcome");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT );
WelcomePanel pancel=new WelcomePanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WIDTH=300;
public static final int DEFAULT_HEIGHT =200;
}
class WelcomePane extends JPanel{
public WelcomePane(){
JLabel prompt=new JLabel ("请输入您的名字:");
final JTextField input=new JTextField(10);
final JTextField output=new JTextField(25);
JButton btnn=new JButton("Welcome");
add(prompt);
add(input);
add(btnn);
btnn.addActionListener=new ActionListener(){
public void actionPerfoemed(ActionEvent event){
String s=input.getText();
output.setText("Hello"+s+",欢迎您加入Java考试!");
}
}
}
} 展开
import java.awt.event.*;
import javax.swing.*;
public class WelcomeTest {
public static void main(String[] args) {
WelcomeFrame frame=new WelcomeFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class WelcomeFrame extends JFrame{
public WelcomeFrame(){
setTitle("Welcome");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT );
WelcomePanel pancel=new WelcomePanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WIDTH=300;
public static final int DEFAULT_HEIGHT =200;
}
class WelcomePane extends JPanel{
public WelcomePane(){
JLabel prompt=new JLabel ("请输入您的名字:");
final JTextField input=new JTextField(10);
final JTextField output=new JTextField(25);
JButton btnn=new JButton("Welcome");
add(prompt);
add(input);
add(btnn);
btnn.addActionListener=new ActionListener(){
public void actionPerfoemed(ActionEvent event){
String s=input.getText();
output.setText("Hello"+s+",欢迎您加入Java考试!");
}
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询