java界面初学组件肤浅小总结
2017-08-22 09:30
405 查看
容器(可以放组件)JPanel默认的布局管理器是FlowLayout:
JPanel panel=new JPanel();
按钮JButton(可以为汉字 也可以是图片):
JButton button=new JButton("按钮");
或JButton button=new JButton(new ImageIcon(""));//""里为图片路径
复选按钮JCheckBox(可以选多个)
JCheckBox muti_choice1=new JCheckBox("选项1")
JCheckBox muti_choice2=new JCheckBox("选项2")
单选按钮JRadioButton(只能且“必须”选一个):
JRadioButton radio_button1=new JRadioButton("男");
JRadioButton radio_button2=new JRadioButton("女");
ButtonGroup choose=new ButtonGroup();
choose.add(radio_button1);choose.add(radio_button2);
//后边添加到JPanel中还是添加radio_button1。
标签JLabel(只是单纯显示 不可以操作,可以为汉字 也可以是图片)
JLabel label=new JLabel("标签");
或 JLabel label=new JLabel(new ImageIcon(""));
文本框JTextField(可以输入用户名)
JTextField text=new JTextField();
密码框JPasswordField(用来输入密码显示星号)
JPasswordField password=new JPasswordField();
文本域JTextArea(用来输入大量内容,例如记事本内容)
JTextArea text_area=new JTextArea();
容器存放JTabbedPane(呈现容器界面多选一显示)
JTabbedPane choice=new JTabbedPane();
choice.add(panel1);choice.add(panel2);
choice.add(panel3);
滚动条JScrollPane(输入的文本超出后增添滚动条)
JScrollPane roll=new JScrollPane(sth)
sth可以是文本域的对象,下拉列表的对象等等;
下拉列表框JComboBox
JComboBox combobox;
String[] place={"广州","上海","保定","石家庄"};
comboBox =new JComboBox(place);
滚动条框JList
JList list;
String [] degree={"高中","大专","本科","硕士","博士"};
list =new JList(degree);
list.setVisibleRowCount(3);//一次显示的数目
roll=new JScrollPane(list);//滚动效果
工具栏JToolBar
ToolBar tool_bar=new ToolBar();
tool_bar.add(sth);
sth为按钮
菜单JMenu:不参与布局 位置是固定的
JMenuItem是最终的 JMenu 不是最终的可以有下级菜单
JMenu menu =new JMenu("文件");
JMenuItem menu_item=new JMenuItem();
menu.add(menu_item);
菜单栏JMenuBar 存放菜单JMenu
JMenuBar menu_bar=new JMenuBar();
menu_bar.add(menu);
JPanel panel=new JPanel();
按钮JButton(可以为汉字 也可以是图片):
JButton button=new JButton("按钮");
或JButton button=new JButton(new ImageIcon(""));//""里为图片路径
复选按钮JCheckBox(可以选多个)
JCheckBox muti_choice1=new JCheckBox("选项1")
JCheckBox muti_choice2=new JCheckBox("选项2")
单选按钮JRadioButton(只能且“必须”选一个):
JRadioButton radio_button1=new JRadioButton("男");
JRadioButton radio_button2=new JRadioButton("女");
ButtonGroup choose=new ButtonGroup();
choose.add(radio_button1);choose.add(radio_button2);
//后边添加到JPanel中还是添加radio_button1。
标签JLabel(只是单纯显示 不可以操作,可以为汉字 也可以是图片)
JLabel label=new JLabel("标签");
或 JLabel label=new JLabel(new ImageIcon(""));
文本框JTextField(可以输入用户名)
JTextField text=new JTextField();
密码框JPasswordField(用来输入密码显示星号)
JPasswordField password=new JPasswordField();
文本域JTextArea(用来输入大量内容,例如记事本内容)
JTextArea text_area=new JTextArea();
容器存放JTabbedPane(呈现容器界面多选一显示)
JTabbedPane choice=new JTabbedPane();
choice.add(panel1);choice.add(panel2);
choice.add(panel3);
滚动条JScrollPane(输入的文本超出后增添滚动条)
JScrollPane roll=new JScrollPane(sth)
sth可以是文本域的对象,下拉列表的对象等等;
下拉列表框JComboBox
JComboBox combobox;
String[] place={"广州","上海","保定","石家庄"};
comboBox =new JComboBox(place);
滚动条框JList
JList list;
String [] degree={"高中","大专","本科","硕士","博士"};
list =new JList(degree);
list.setVisibleRowCount(3);//一次显示的数目
roll=new JScrollPane(list);//滚动效果
工具栏JToolBar
ToolBar tool_bar=new ToolBar();
tool_bar.add(sth);
sth为按钮
菜单JMenu:不参与布局 位置是固定的
JMenuItem是最终的 JMenu 不是最终的可以有下级菜单
JMenu menu =new JMenu("文件");
JMenuItem menu_item=new JMenuItem();
menu.add(menu_item);
菜单栏JMenuBar 存放菜单JMenu
JMenuBar menu_bar=new JMenuBar();
menu_bar.add(menu);
相关文章推荐
- JAVA GUI界面组件学习
- Java界面 SWT基本组件——Label
- (第19讲)java组件(总结)
- 黑马程序员:Java基础总结----GUI图形化界面
- java图形用户界面组件与布局管理——四则运算练习软件界面搭建(FlowLayout、GridBagLayout、Font)
- Java初学习 - Arrays.asList方法总结
- 初学Java之AAWT组件库
- Java高级部分组件重点总结
- 黑马程序员_Java第22天知识总结_创建图形化界面_事件监听机制_双击执行的jar包
- Java界面 SWT基本组件——文本框(Text)
- Java界面 SWT基本组件——组合框(Combo)
- 当java swing界面启动无法正常显示,当调整JFrame大小后才能全部显示子组件
- 黑马程序员——初学java心得小总结
- java多线程组件一:CountDownLatch使用方法的总结
- 界面组件与布局管理【总结】
- 初学Java之AAWT组件库2
- 打印java应用程序的界面.可以指定是这个界面中的任何一个组件.
- 初学Java的感受及基础总结
- JAVA操作数据库总结之组件篇-Hibernate
- Java Swing界面编程(17)---单行文本输入组件:JTextField