KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > panels > XMLTabbedPanel


1 /* XMLTabbedPanel.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

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 /**
21  * Creates a tabbed panel.
22  */

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.setLayout(new BoxLayout(this.tabbed,BoxLayout.Y_AXIS));
31
//tabbed.setLayout(new GridLayout(1,1));
32
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); //Harald Meister
44
//tabbed.setPreferredSize(tabbed.getMinimumSize());
45
//elementPanel.setPreferredSize(elementPanel.getMinimumSize())
46
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 /* End of DTDTabbedPanel.java */
87
Popular Tags