首页 > Windows开发 > 详细

Swing组件

时间:2019-05-01 20:47:36      阅读:141      评论:0      收藏:0      [点我收藏+]

头大。。感觉好多东西要记住

package swing;

import java.awt.*;
import javax.swing.*;

public class SwingTest1 {
JFrame f;
JPanel p;
JLabel l;
JTextField tf;
JLabel lq;
JPasswordField we;
JTextArea ta;
JScrollPane sp;
ButtonGroup bg;
JRadioButton rb1,rb2;
public SwingTest1() {
f = new JFrame("hello");
p = new JPanel();
l = new JLabel("账号:");
l.setFont(new Font("宋体",Font.BOLD,20));
lq = new JLabel("密码:");
lq.setFont(new Font("宋体",Font.BOLD,20));
tf = new JTextField(10);
we = new JPasswordField(10);
we.setEchoChar(‘0‘);
ta = new JTextArea(5,10);
sp = new JScrollPane(ta);
bg = new ButtonGroup();
rb1 = new JRadioButton("男",true);
rb2 = new JRadioButton("女");
bg.add(rb1);
bg.add(rb2);

f.add(p);
p.add(l);
p.add(tf);
p.add(lq);
p.add(we);
//p.add(ta);
p.add(sp);
p.add(rb1);
p.add(rb2);

f.setVisible(true);
f.setSize(800, 600);
f.setLocation(560, 240);
p.setBackground(new Color(171,214,227));

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main(String[] args) {
// TODO Auto-generated method stub
new SwingTest1();
}

}

 技术分享图片

Swing组件

原文:https://www.cnblogs.com/erlongi/p/10800630.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!