Java GUI 设计一个身份证信息的用户界面。当用户提交输入信息后,弹出一个消息框,将输入的内容显示在其中
展开全部
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class test extends JFrame {
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JLabel l1 = new JLabel("姓名");
JLabel l2 = new JLabel("身份号码");
JTextField f1 = new JTextField();
JTextField f2 = new JTextField();
JButton b1 = new JButton("提交");
public test()
{
this.setLayout(new BorderLayout());
p1.setLayout(new GridLayout(2,2));
p1.add(l1);
p1.add(f1);
p1.add(l2);
p1.add(f2);
this.add(p1,BorderLayout.NORTH);
p2.add(b1,BorderLayout.CENTER);
this.add(p2,BorderLayout.CENTER);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"姓名:"+f1.getText()+"\n身份证号码:"+f2.getText());
}
});
this.setSize(200,120);
this.setVisible(true);
}
public static void main(String[] args) {
test t = new test();
}
}
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class test extends JFrame {
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JLabel l1 = new JLabel("姓名");
JLabel l2 = new JLabel("身份号码");
JTextField f1 = new JTextField();
JTextField f2 = new JTextField();
JButton b1 = new JButton("提交");
public test()
{
this.setLayout(new BorderLayout());
p1.setLayout(new GridLayout(2,2));
p1.add(l1);
p1.add(f1);
p1.add(l2);
p1.add(f2);
this.add(p1,BorderLayout.NORTH);
p2.add(b1,BorderLayout.CENTER);
this.add(p2,BorderLayout.CENTER);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"姓名:"+f1.getText()+"\n身份证号码:"+f2.getText());
}
});
this.setSize(200,120);
this.setVisible(true);
}
public static void main(String[] args) {
test t = new test();
}
}
展开全部
设计一个身份证信息的用户界面。当用户提交输入信息后,弹出一个消息框,将输入的内容显示在其中
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class test extends JFrame {
JPanel p2 = new JPanel();
JLabel l2 = new JLabel("身份号码");
JTextField f2 = new JTextField();
JButton b2 = new JButton("提交");
public test(){
this.setLayout(new BorderLayout());
p2.setLayout(new GridLayout(2,2));
p2.add(l2);
p2.add(f2);
this.add(p2,BorderLayout.NORTH);
p2.add(b2,BorderLayout.CENTER);
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"\n身份证号码:"+f2.getText());
}
});
this.setSize(200,120);
this.setVisible(true);
}
public static void main(String[] args) {
test t = new test();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class test extends JFrame {
JPanel p2 = new JPanel();
JLabel l2 = new JLabel("身份号码");
JTextField f2 = new JTextField();
JButton b2 = new JButton("提交");
public test(){
this.setLayout(new BorderLayout());
p2.setLayout(new GridLayout(2,2));
p2.add(l2);
p2.add(f2);
this.add(p2,BorderLayout.NORTH);
p2.add(b2,BorderLayout.CENTER);
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"\n身份证号码:"+f2.getText());
}
});
this.setSize(200,120);
this.setVisible(true);
}
public static void main(String[] args) {
test t = new test();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |