Java图形界面——文本域、边界布局

来源:互联网 发布:mysql 删除触发器语句 编辑:程序博客网 时间:2024/05/16 01:13
/* * 聊天框 */package com.test.swing;import java.awt.*;import javax.swing.*;public class Test3 extends JFrame {//定义组件JTextArea jta = null;//文本域JPanel jp = null;//面板JScrollPane jsp =null;JComboBox jc = null;//组合框JTextField jtf = null;//文本框JButton jb = null;//按钮public static void main(String[] args) {Test3 test3 = new Test3();}//构造函数public Test3(){//创建组件jta = new JTextArea();jsp = new JScrollPane(jta);//文本域加入滚动条功能jp = new JPanel();String chatter[] = {"英    拉","普    京","奥巴马"};jc = new JComboBox(chatter);jtf = new JTextField(10);jb = new JButton("发送");//添加组件this.add(jsp);jp.add(jc);jp.add(jtf);jp.add(jb);this.add(jsp); //加入实现滚动功能文本域this.add(jp, BorderLayout.SOUTH);this.setSize(300, 200);this.setResizable(false);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}

0 0
原创粉丝点击