标签:jbutton flow ado 工资 支持 rip 系统 北京 选项




















xxxxxxxxxx/*** 多种布局管理器,面板组件(JPanel)--使用*/import java.awt.*;import javax.swing.*;public class Window005 extends JFrame{ //定义组件 JPanel jp1,jp2; JButton jb1,jb2,jb3,jb4,jb5,jb6; public static void main(String[] args) { Window005 win=new Window005(); } //构造函数 public Window005(){ //创建组件 jp1=new JPanel();//JPanel布局默认是FlowLayout流布局 jp2=new JPanel(); jb1=new JButton("西瓜"); jb2=new JButton("苹果"); jb3=new JButton("荔枝"); jb4=new JButton("葡萄"); jb5=new JButton("桔子"); jb6=new JButton("香蕉"); //设置布局管理器(Jpanel默认流布局) //添加JPanel jp1.add(jb1); jp1.add(jb2); jp2.add(jb3); jp2.add(jb4); jp2.add(jb5); //把Panel加入JFrame this.add(jp1, BorderLayout.NORTH); this.add(jb6, BorderLayout.CENTER); this.add(jp2, BorderLayout.SOUTH); //设置窗体 this.setSize(300, 250);//窗体大小 this.setLocation(200, 200);//屏幕显示初始位置 this.setVisible(true);//显示 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//退出窗体后将JFrame同时关闭 }}
xxxxxxxxxx/*** Swing组件--文本框(JTextField)/密码框(JPasswordField)/标签(JLable)组件使用*/import java.awt.*;import javax.swing.*;public class Window006 extends JFrame{ //定义组件 JPanel jp1,jp2,jp3;//面板 JLabel jlb1,jlb2;//标签 JButton jb1,jb2;//按钮 JTextField jtf;//文本 JPasswordField jpf;//密码 public static void main(String[] args) { Window006 win=new Window006(); } //构造函数 public Window006(){ //创建面板 jp1=new JPanel(); jp2=new JPanel(); jp3=new JPanel(); //创建标签 jlb1=new JLabel("用户名"); jlb2=new JLabel("密 码"); //创建按钮 jb1=new JButton("登录"); jb2=new JButton("取消"); //创建文本框 jtf=new JTextField(10); //创建密码框 jpf=new JPasswordField(10); //设置布局管理 this.setLayout(new GridLayout(3, 1));//网格式布局 //加入各个组件 jp1.add(jlb1); jp1.add(jtf); jp2.add(jlb2); jp2.add(jpf); jp3.add(jb1); jp3.add(jb2); //加入到JFrame this.add(jp1); this.add(jp2); this.add(jp3); //设置窗体 this.setTitle("用户登录");//窗体标签 this.setSize(300, 150);//窗体大小 this.setLocationRelativeTo(null);//在屏幕中间显示(居中显示) this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//退出关闭JFrame this.setVisible(true);//显示窗体 //锁定窗体 this.setResizable(false); }}
xxxxxxxxxx/*** 复选框组件(JCheckBox)和单选框组件(JRadioButton)使用*/import java.awt.*;import javax.swing.*;public class Window007 extends JFrame{ //定义组件 JPanel jp1,jp2,jp3; JLabel jl1,jl2; JCheckBox jcb1,jcb2,jcb3; JRadioButton jrb1,jrb2; ButtonGroup bg; JButton jb1,jb2; public static void main(String[] args) { Window007 win=new Window007(); } //构造函数 public Window007(){ //创建组件 jp1=new JPanel(); jp2=new JPanel(); jp3=new JPanel(); jl1=new JLabel("你最喜欢的运功:"); jl2=new JLabel("你的性别:"); jcb1=new JCheckBox("足球"); jcb2=new JCheckBox("篮球"); jcb3=new JCheckBox("网球"); jrb1=new JRadioButton("男"); jrb2=new JRadioButton("女"); jb1=new JButton("注册用户"); jb2=new JButton("取消注册"); //一定要把jrb1与jrb2放入到一个ButtonGroup中 ButtonGroup bg=new ButtonGroup(); bg.add(jrb1); bg.add(jrb2); //创建布局 this.setLayout(new GridLayout(3, 1)); //加入组件 jp1.add(jl1); jp1.add(jcb1); jp1.add(jcb2); jp1.add(jcb3); jp2.add(jl2); jp2.add(jrb1); jp2.add(jrb2); jp3.add(jb1); jp3.add(jb2); this.add(jp1); this.add(jp2); this.add(jp3); //设置窗体 this.setTitle("用户注册"); this.setSize(300, 150); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }}
/*** 下拉框(JComboBox)/列表框(JList)/滚动空格(JScrollPane)的使用*/import java.awt.*;import javax.swing.*;public class Window008 extends JFrame{ //定义组件 JPanel jp1,jp2; JLabel jl1,jl2; JComboBox jcb; JList jl; JScrollPane jsp; public static void main(String[] args) { Window008 win=new Window008(); } //构造函数 public Window008(){ //建立组件 jp1=new JPanel(); jp2=new JPanel(); jl1=new JLabel("你的籍贯:"); jl2=new JLabel("旅游地点:"); String[] jg={"北京","上海","天津","火星"}; jcb=new JComboBox(jg); String[] dd={"长城","东方明珠","海河","什么什么"}; jl=new JList(dd); //设置你希望显示多少个选项 jl.setVisibleRowCount(2);//滚动条显示setVisibleRowCount(?)?为显示条数 jsp=new JScrollPane(jl); //设定布局 this.setLayout(new GridLayout(3, 1)); //加入组件 jp1.add(jl1); jp1.add(jcb); jp2.add(jl2); jp2.add(jsp); this.add(jp1); this.add(jp2); //设置窗体 this.setTitle("用户注册"); this.setSize(300, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }}
标签:jbutton flow ado 工资 支持 rip 系统 北京 选项
原文地址:https://www.cnblogs.com/xuxaut-558/p/10045687.html