package com.gui2;
import java.awt.*;
import javax.swing.*;
public class Demo1 extends JFrame{
JSplitPane jsp;
JList jlist;
JLabel jl;
public static void main(String[] args) {
// TODO Auto-generated method stub
Demo1 demo1=new Demo1();
}
public Demo1()
{
String words[]={"boy","girl","hello","people"};
jlist=new JList(words);
//插入图片
jl=new JLabel(new ImageIcon("picture.jpg"));
//拆分窗格
jsp=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jlist,jl);
//可以移动
jsp.setOneTouchExpandable(true);
this.add(jsp);
this.setSize(400, 300);
this.setLocation(200, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
} |
|