1 package Layout; 2 import java.awt.*; 3 import javax.swing.*; 4 public class SplitWindow extends JFrame { 5 private String str[] = {"软件开发","平面设计","动画制作","室内设计"}; 6 private JList lb = new JList(str); 7 private JLabel bq = new JLabel(new ImageIcon("photo/psb.jpg")); 8 private JSplitPane cf = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,lb,bq);// 左右拆分 9 //private JSplitPane cf = new JSplitPane(JSplitPane.VERTICAL_SPLIT,lb,bq);// 上下拆分 10 public SplitWindow(){ 11 12 cf.setOneTouchExpandable(true); 13 this.add(cf); 14 this.setTitle("用户界面"); 15 this.setSize(600, 500); 16 this.setLocation(100, 100); 17 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 18 this.setVisible(true); 19 } 20 public static void main(String[] args) { 21 22 SplitWindow l = new SplitWindow(); 23 } 24 25 }
时间: 2024-11-13 14:01:43