摘自并整理http://blog.csdn.net/liu_zhen_wei/article/details/6445345
1 package com.wst.bj; 2 3 import java.awt.BorderLayout; 4 import java.awt.Container; 5 import java.awt.event.WindowAdapter; 6 import java.awt.event.WindowEvent; 7 8 import javax.swing.JFrame; 9 import javax.swing.JLabel; 10 import javax.swing.JPanel; 11 import javax.swing.JTabbedPane; 12 13 public class JTabbedPaneDemo { 14 public static void main(String[] args) { 15 UIManager ui = new UIManager(); 16 ui.initUI(); 17 } 18 } 19 20 class UIManager extends JFrame { 21 22 public UIManager() { 23 super("学生信息管理系统"); 24 } 25 26 public void initUI() { 27 this.setBounds(300, 300, 500, 400); 28 this.addWindowListener(new WindowAdapter() { 29 public void windowClosing(WindowEvent e) { 30 super.windowClosing(e); 31 System.exit(0); 32 } 33 }); 34 layoutUI(); 35 this.setVisible(true); 36 } 37 38 private void layoutUI() { 39 40 // 对象实例化 41 JTabbedPane tab = new JTabbedPane(JTabbedPane.TOP); 42 // 容器 43 Container container = this.getLayeredPane(); 44 // 对象化面板 45 JPanel combop = new JPanel(); 46 JPanel p1 = new JPanel(); 47 JPanel p2 = new JPanel(); 48 JPanel p3 = new JPanel(); 49 JPanel p4 = new JPanel(); 50 51 tab.add(p1, "Select"); 52 tab.add(p2, "Updata"); 53 tab.add(p3, "Inserte"); 54 tab.add(p4, "Delete"); 55 56 combop.add(new JLabel("学生信息管理系统")); 57 58 container.setLayout(new BorderLayout()); 59 container.add(combop, BorderLayout.NORTH); 60 container.add(tab, BorderLayout.CENTER); 61 62 } 63 }
时间: 2024-10-20 17:57:25