JavaSwing图形界面编程之JTablePane(一)

时间:2023-01-26 16:49:46

JavaSwing图形界面编程之JTablePane(一)

JavaSwing图形界面编程之JTablePane(一)

package three.day.frame;

import java.awt.BorderLayout;
import java.net.URL;


import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;




public class JTabbedPaneDemo01 {


/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        URL url1 = loader.getResource("not.gif");
        URL url2 = loader.getResource("cross.gif");
        JTabbedPane tabpane = new JTabbedPane();
        JPanel p1 = new JPanel();
        JPanel p2 = new JPanel();
        p1.add(new JButton("Hello,i am 1"),BorderLayout.NORTH);
        p2.add(new JLabel("Welcome 2"),BorderLayout.NORTH);
        tabpane.addTab("选项卡1", new ImageIcon(url1), p1);
        tabpane.addTab("选项卡2", new ImageIcon(url2), p2);
        tabpane.setSelectedIndex(1);
        JFrame f = new JFrame();
        f.setTitle("选项卡面板的使用示例");
        f.setBounds(200,50,400,400);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add(tabpane);
        f.setVisible(true);
        
}


}