资源描述:
《带标题边框和选项卡》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、importjava.awt.CardLayout;importjava.awt.Color;importjava.awt.Font;importjava.awt.Toolkit;importjavax.swing.BorderFactory;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JTabbedPane;importjavax.swing.JTextField;importjavax.swin
2、g.border.Border;importjavax.swing.border.TitledBorder;publicclassCarshujibeifenyudaoruextendsJFrame{/**带标题边框*选项卡:数据备份-数据导入*@paramargs*///容器privateJPanelcontentpane;//选项卡面板privateJPanelTabbedpane_pane1,Tabbedpane_pane2;//选项卡面板1的文本框privateJTextFieldTp_pane1_textfield;//选项卡面板1的按钮privateJButtonTp_pane
3、1_button1,Tp_pane1_button2,Tp_pane1_button3;//选项卡面板2的文本框privateJTextFieldTp_pane2_textfield;//选项卡面板2的按钮privateJButtonTp_pane2_button1,Tp_pane2_button2,Tp_pane2_button3;//选项卡布局privateJTabbedPanetabbedpane;//构造方法publicCarshujibeifenyudaoru(){//边框普通边框Borderborder=BorderFactory.createEtchedBorder(Colo
4、r.BLACK,Color.blue);//边框标题Bordertitle=BorderFactory.createTitledBorder(border,"数据备份-数据导入",TitledBorder.LEADING,TitledBorder.TOP,newFont("黑体",Font.BOLD,30));//容器contentpane=newJPanel();//添加边框contentpane.setBorder(border);//添加标题contentpane.setBorder(title);//容器布局无contentpane.setLayout(null);//卡片面板1的
5、文本框Tp_pane1_textfield=newJTextField();//大小及位置Tp_pane1_textfield.setBounds(50,70,280,35);//卡片面板1的按钮Tp_pane1_button1=newJButton("浏览");//大小及位置Tp_pane1_button1.setBounds(350,69,80,40);Tp_pane1_button2=newJButton("备份");//大小及位置Tp_pane1_button2.setBounds(80,143,120,50);Tp_pane1_button3=newJButton("取消");/
6、/大小及位置Tp_pane1_button3.setBounds(260,143,120,50);//卡片面板1Tabbedpane_pane1=newJPanel();//布局无Tabbedpane_pane1.setLayout(null);//添加到卡片面板1Tabbedpane_pane1.add(Tp_pane1_textfield);Tabbedpane_pane1.add(Tp_pane1_button1);Tabbedpane_pane1.add(Tp_pane1_button2);Tabbedpane_pane1.add(Tp_pane1_button3);//卡片面板2
7、Tabbedpane_pane2=newJPanel();//卡片面板1的文本框Tp_pane2_textfield=newJTextField();//大小及位置Tp_pane2_textfield.setBounds(50,70,280,35);//卡片面板1的按钮Tp_pane2_button1=newJButton("浏览");//大小及位置Tp_pane2_button1.setBounds(350,69,80