用户界面

package daima;
import java.awt.Color;

import javax.swing.*;  
public class text2 {
    JFrame f;
    JPanel  p;
    JButton  b1,b2;
    JLabel   l1,l2;
    JTextField  t1,t2;
    public text2(){
        f=new JFrame();
        p=new JPanel();
        p=new JPanel();
        b1=new JButton("确定");
        b2=new JButton("取消");
        l1=new JLabel("用户名:");
        l2=new JLabel("口令:");
        t1=new JTextField(10);
        t2=new JTextField(10);
        p.add(l1);
        p.add(t1);
        p.add(l2);
        p.add(t2);
        p.add(b1);
        p.add(b2);
        f.add(p);
        f.setSize(100,200);
        f.setVisible(true);
        p.setBackground(Color.pink);
    }
        public static void main(String[] args) {
            new text2();
    }
    
}


package daima;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class text  {
    JFrame  f;
    JPanel  p;
    JButton b1,b2;
    JLabel  l1,l2,l3,l4,l5,l6,l7,l8,l9;
    JTextField t1,t2,t3,t4,t5,t6;
    public text(){
        f=new JFrame();
        p=new JPanel();
        b1=new JButton("开");
        b2=new JButton("关");
        l1=new JLabel("当前时间:");
        l2=new JLabel("时");
        l3=new JLabel("分");
        l4=new JLabel("秒");
        l5=new JLabel("闹钟时间:");
        l6=new JLabel("闹钟设置");
        l7=new JLabel("时");
        l8=new JLabel("分");
        l9=new JLabel("秒");
        t1=new JTextField(5);
        t2=new JTextField(5);
        t3=new JTextField(5);
        t4=new JTextField(5);
        t5=new JTextField(5);
        t6=new JTextField(5);
        p.add(l1);
        p.add(t1);
        p.add(l7);
        p.add(t2);
        p.add(l8);
        p.add(t3);
        p.add(l9);
        p.add(l5);
        p.add(t4);
        p.add(l2);
        p.add(t5);
        p.add(l3);
        p.add(t6);
        p.add(l4);
        p.add(l6);
        p.add(b1);
        p.add(b2);
        f.add(p);
        f.setSize(400,300);
        p.setSize(350,200);
        f.setVisible(true);
        p.setBackground(Color.pink);
       
    }
    public static void main(String[] args) {
        new text();
    }
}

原文地址:https://www.cnblogs.com/lusilin/p/10908292.html