1 10 11 12 package org.enhydra.jawe.xml.panels; 13 14 import org.enhydra.jawe.xml.*; 15 16 import java.util.*; 17 import javax.swing.*; 18 import java.awt.*; 19 20 23 public class XMLTabbedPanel extends XMLPanel { 24 private JTabbedPane tabbed; 25 26 public XMLTabbedPanel (XMLElement myOwner,XMLPanel[] panels) { 27 super(myOwner,1,"",XMLPanel.BOX_LAYOUT,true,false); 28 29 tabbed=new JTabbedPane(JTabbedPane.TOP); 30 tabbed.setAlignmentX(Component.LEFT_ALIGNMENT); 33 tabbed.setAlignmentY(Component.TOP_ALIGNMENT); 34 35 for (int i=0; i<panels.length; i++) { 36 if (panels[i].getTitle()!=null && panels[i].getTitle()!="") { 37 tabbed.addTab(panels[i].getTitle(),panels[i]); 38 } 39 else { 40 tabbed.addTab(panels[i].getOwner().toLabel(),panels[i]); 41 } 42 } 43 tabbed.setSelectedIndex(0); add(tabbed); 47 } 48 49 public XMLPanel getTabbedPanel (int no) { 50 if (no>=tabbed.getTabCount()) { 51 return null; 52 } 53 return (XMLPanel)tabbed.getComponentAt(no); 54 } 55 56 public boolean checkRequired () { 57 boolean isOK=true; 58 for (int i=0; i<tabbed.getComponentCount();i++) { 59 Component c=tabbed.getComponent(i); 60 if (c instanceof XMLPanel) { 61 isOK=isOK && ((XMLPanel)c).checkRequired(); 62 } 63 } 64 return isOK; 65 } 66 67 public void setElements () { 68 for (int i=0; i<tabbed.getComponentCount();i++) { 69 Component c=tabbed.getComponent(i); 70 if (c instanceof XMLPanel) { 71 ((XMLPanel)c).setElements(); 72 } 73 } 74 } 75 76 public int getSelectedTab () { 77 return tabbed.getSelectedIndex(); 78 } 79 80 public void setSelectedTab (int selIndex) { 81 tabbed.setSelectedIndex(selIndex); 82 } 83 84 } 85 86 87 | Popular Tags |