* 拆分窗格,JSplitPane,容器类组件
* 练习
* 金山词霸界面
*/
package com.test1;
//package com.GUI;
import java.awt.*;
import javax.swing.*;
public class Demo8_9 extends JFrame//继承JFrame
{
JSplitPane jsp;//拆分窗格
JList jList;//列表
JLabel jl1;//标签
public static void main(String[] args)
{
Demo8_9 demo8_9=new Demo8_9();//实例化,对象化
}
public Demo8_9()//构造函数
{
String []words={"bird","girl","stupid","happy"};//字符数组
jList=new JList(words);//列表框显示数组字符
// jl1=new JLabel("abc");
jl1=new JLabel(new ImageIcon("images/ciba.gif"));//标签背景
//拆分窗格
jsp=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jList,jl1);//拆分窗格(从左到右排列,列表框,标签)
//可以变化大小
jsp.setOneTouchExpandable(true);
this.add(jsp);//拆分窗格加入到对象窗口
this.setSize(200, 300);//窗口大小
this.setVisible(true);//显示窗口
this.setDefaultCloseOperation(EXIT_ON_CLOSE);//关闭窗口时退出程序
}