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(Frame.EXIT_ON_CLOSE);
frame.show();
}
}
class WelcomeFrame extends Frame
{ public WelcomeFrame()
{ setTitle("Welcome");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
WelcomePanel panel = new WelcomePanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static final intDEFAULT_WIDTH = 300;
Public static final intDEFAULT_HEIGHT = 200;
}
class WelcomePanel extends Panel
{ public WelcomePanel()
{ Label prompt = new Label("请输入您的名字:")
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("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考试!");
}
});
}
}
\\就是这个源程序,用JAVAC编译的时候,报告有100个错误.真是搞不明白,我跟书上做的是一样,怎么会有错误.请高手指点一下?
import java.awt.event.*;
import javax.swing.*;
public class WelcomeTest
{public static void main(String []args)
{WelcomeFrame frame = new WelcomeFrame();
frame.setDefaultCloseOperation(Frame.EXIT_ON_CLOSE);
frame.show();
}
}
class WelcomeFrame extends Frame
{ public WelcomeFrame()
{ setTitle("Welcome");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
WelcomePanel panel = new WelcomePanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static final intDEFAULT_WIDTH = 300;
Public static final intDEFAULT_HEIGHT = 200;
}
class WelcomePanel extends Panel
{ public WelcomePanel()
{ Label prompt = new Label("请输入您的名字:")
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("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考试!");
}
});
}
}
\\就是这个源程序,用JAVAC编译的时候,报告有100个错误.真是搞不明白,我跟书上做的是一样,怎么会有错误.请高手指点一下?
解决方案 »
- 如何提高 删除 速度 大家说说白 做过的给点建议
- 用JAVA实现基于组播的屏幕共享,可行吗?
- string类型
- 求助??如何改变字体大小??
- 迷惑之中?迷惑之中!
- 如何在tomcat1.0.1中配置smartupload才能使之正确高效率的运行?
- 关于中文版jdk的一点想法
- 如何比较两个数的大小,并按从小到大的次序输出。如:double d1=23.4;double d2=35.1;
- 我在JBotton中怎么关闭本JFram?---请高手指教,最好给个代码!
- 请问为什么在websphere3.5中创建应用服务器时要指定虚拟主机?应用服务器与指定虚拟主机的关系?
- 请问,Array和Arrays的区别
- 文本文件导入sqlserver
字符格式不对!
先粘贴到记事本中,保存,然后重名名为*.java
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 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 extends Panel{
public WelcomePanel() {
Label prompt = new Label("请输入您的名字:");
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("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考试!");
}
});
}
}
IDE来写程序
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 panel = new WelcomePanel();
Container contentPane = this.getContentPane();
contentPane.add(panel);
} public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 200;
}class WelcomePanel extends Panel {
public WelcomePanel() {
Label prompt = new Label("请输入您的名字:");
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("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考试!");
}
});
}
}
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 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 extends JPanel {
public WelcomePanel() {
Label prompt = new Label("请输入您的名字:");
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("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考试!");
}
});
}
}
帮你改了一下
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);//setDefaultCloseOperation();
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 extends Panel
{ public WelcomePanel()
{ Label prompt = new Label("请输入您的名字:");
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("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考试!");
}
});
}
}