Interface 2--5.29

package 界面;
import java.awt.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import javax.swing.*;  
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class add {
    JFrame f;
    JPanel p;
    JLabel m,m1,m2,m3;
    JButton b1,b2;
    JTextField t1,t2,t3;
    GridLayout g1;
    public add(){
        f=new JFrame();
        g1=new GridLayout(3,3);
        p=new JPanel(); 
        p.setLayout(g1);
        m=new JLabel ("加数1");
        t1=new JTextField();
        m2=new JLabel ("");
        m1=new JLabel ("加数2");
        t2=new JTextField();
        m3=new JLabel ("");
        b1=new JButton("求和");
        t3=new JTextField();
        b2=new JButton("清除");
        f.add(p);
        p.add(m);
        p.add(t1);
        p.add(m2);
        p.add(m1);
        p.add(t2);
        p.add(m3);
        p.add(b1);
        p.add(t3);
        p.add(b2);
            
        f.setSize(400,300);
        f.setVisible(true);
    }
        public static void main(String[] args){
            new add();
            }           
}

1, the drawing of the interface shown in FIG.

Requirements: When you click the "sum" button, "and" displayed in the "sum" button after line of text, when you click the "Clear" button, the contents of all three lines of text are cleared when the single when hit the close button in the window, the end of the program.

 

Guess you like

Origin www.cnblogs.com/Maxsh/p/10943042.html