主题:小弟我初学JAVA 现在遇到点小问题 ,希望各位高手们能帮忙看看
小弟我初学JAVA 现在遇到点小问题 ,希望各位高手们能帮忙看看。
系统报错说:30行和33行出错; 源代码如下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WelcomeTest
{
public static void main(String arg [])
{
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 Panel = new WelcomePanel();
Container contentPane = getContentPane();
contentPane.add(Panel);
}
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 200;
}
class WelcomePanel extents JPanel
{
public WelcomePanel()
{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(output);
add(btnn);
btnn.addActionListener(new
ActionListener()
{ public void actionPerformed(ActionEvent Event)
{ String s = input.getText();
output.setText("Hello "+s+",欢迎您参加Java考试!");
}
});
}
}
系统报错说:30行和33行出错; 源代码如下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WelcomeTest
{
public static void main(String arg [])
{
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 Panel = new WelcomePanel();
Container contentPane = getContentPane();
contentPane.add(Panel);
}
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 200;
}
class WelcomePanel extents JPanel
{
public WelcomePanel()
{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(output);
add(btnn);
btnn.addActionListener(new
ActionListener()
{ public void actionPerformed(ActionEvent Event)
{ String s = input.getText();
output.setText("Hello "+s+",欢迎您参加Java考试!");
}
});
}
}