基本功能已经实现,望采纳
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.TextEvent;
import javax.swing.JFrame;
/*
* java编程 完成下图所示的图形用户界面设计,
*/
public class Demo3 {
public static void main(String[] args) {
//创建窗体对象
JFrame jf = new JFrame("信息获取");
//设置大小
jf.setSize(300, 300);
//设置居中
jf.setLocationRelativeTo(null);
//设置布局
jf.setLayout(new FlowLayout());
//设置关闭事件
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//添加label
Label stuClass = new Label("班级");
Label stuNo = new Label("学仔雀号");
Label stuName = new Label("姓名");
//添加文本框
final TextField tfClass = new TextField(30);
final TextField tfNo = new TextField(30);
final TextField tfName = new TextField(30);
//添加按钮
Button confirm = new Button("确定");
Button 滚裤cancel = new Button("取消");
//添加文本域
final TextArea ta = new TextArea(30,30);
//添加
jf.add(stuClass);
jf.add(tfClass);
jf.add(stuNo);
jf.add(tfNo);
jf.add(stuName);
jf.add(tfName);
jf.add(confirm);
jf.add(cancel);
jf.add(ta);
//添加事件
confirm.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
String stuClass = tfClass.getText().trim();
String stuNo = tfNo.getText().trim();
String stuName = 大戚简tfName.getText().trim();
tfClass.setText("");
tfNo.setText("");
tfName.setText("");
ta.append("班级:"+stuClass+"\r\n"+"学号:"+stuNo+"\r\n"+"姓名:"+stuName+"\r\n");
}
});
cancel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.exit(0);
}
});
//显示
jf.setVisible(true);
}
}
用户关系,我来的
安排,这些内容我来理解
分析,结果