复制代码
- //:Tabbed.java
- //Usingtabbedpanes
- packagec13.swing;
- importjava.awt.*;
- importjavax.swing.*;
- importjavax.swing.border.*;
- publicclassTabbedextendsJPanel{
- staticObject[][]q={
- {"Felix",Borders.class},
- {"TheProfessor",Buttons.class},
- {"RockBottom",ButtonGroups.class},
- {"Theodore",Faces.class},
- {"Simon",Menus.class},
- {"Alvin",Popup.class},
- {"Tom",ListCombo.class},
- {"Jerry",Progress.class},
- {"Bugs",Trees.class},
- {"Daffy",Table.class},
- };
- staticJPanelmakePanel(Classc){
- Stringtitle=c.getName();
- title=title.substring(
- title.lastIndexOf(.)+1);
- JPanelsp=null;
- try{
- sp=(JPanel)c.newInstance();
- }catch(Exceptione){
- System.out.println(e);
- }
- sp.setBorder(newTitledBorder(title));
- returnsp;
- }
- publicTabbed(){
- setLayout(newBorderLayout());
- JTabbedPanetabbed=newJTabbedPane();
- for(inti=0;i<q.length;i++)
- tabbed.addTab((String)q[i][0],
- makePanel((Class)q[i][1]));
- add(tabbed,BorderLayout.CENTER);
- tabbed.setSelectedIndex(q.length/2);
- }
- publicstaticvoidmain(Stringargs[]){
- Show.inFrame(newTabbed(),460,350);
- }
- }///:~
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |