Java复习学习笔记:swing中必备的代码,基本控件等【诗书画唱】

布局方式:this.setLayout(null);
大小:this.setSize(width,height)
显示的位置:this.setlocationrelativeto(null);居中显示
释放资this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
显示窗体:this.setVisible(true);
基本控件:
JLabel:文本控件
JTextField:文本框
JPasswordField:密码框
JComboBox:下拉框
JButton:按钮
JLabel lb1=new JLabel("用户名");
//设置显示的位置:
lb1.setBounds(x轴位置,y轴位置,宽度,高度)
this.add(lb1);
//设置字体:
声明字体类:
Font f=new Font("使用的什么字体",字体的粗细bold,字体的大小25)
lb1.setFont(f);
改变字体的颜色:this.setForeground(Color.red);
改变背景色:this.setBackground(颜色值)
JCheckBox:复选框
JRadioButton:单选框
分组:
ButtonGroup bg1=new ButtonGroup();
bg1.add()
JTextArea:文本域
JScrollPane jsp=new JScrollPane("谁要设置滚动条就传入谁");
jt1.setLineWrap(true);