KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > displaycomponents > table > title > TitleBarSplitPane


1 /*
2  * (C) Copyright SimulacraMedia 2003. All rights reserved.
3  *
4  * Created on 23-Nov-2003
5  *
6  */

7 package org.openharmonise.him.displaycomponents.table.title;
8
9 import java.awt.Component JavaDoc;
10 import java.awt.event.ComponentAdapter JavaDoc;
11 import java.awt.event.ComponentEvent JavaDoc;
12 import java.beans.PropertyChangeEvent JavaDoc;
13 import java.beans.PropertyChangeListener JavaDoc;
14
15 import javax.swing.JSplitPane JavaDoc;
16
17 /**
18  * Spacialisation of JSplitPane that will not allow the user to move it.
19  * This enables us to place the {@link com.simulacramedia.contentmanager.displaycomponents.table.title.TitleBar}
20  * at the top of the table view.
21  *
22  * @author Matthew Large
23  * @version $Revision: 1.1 $
24  *
25  */

26 public class TitleBarSplitPane extends JSplitPane JavaDoc {
27
28     private static int HEIGHT = 30;
29
30     /**
31      *
32      */

33     public TitleBarSplitPane() {
34         super();
35         this.setup();
36     }
37
38     /**
39      * @param newOrientation
40      */

41     public TitleBarSplitPane(int newOrientation) {
42         super(newOrientation);
43         this.setup();
44     }
45
46     /**
47      * @param newOrientation
48      * @param newContinuousLayout
49      */

50     public TitleBarSplitPane(int newOrientation, boolean newContinuousLayout) {
51         super(newOrientation, newContinuousLayout);
52         this.setup();
53     }
54
55     /**
56      * @param newOrientation
57      * @param newLeftComponent
58      * @param newRightComponent
59      */

60     public TitleBarSplitPane(
61         int newOrientation,
62         Component JavaDoc newLeftComponent,
63         Component JavaDoc newRightComponent) {
64         super(newOrientation, newLeftComponent, newRightComponent);
65         this.setup();
66     }
67
68     /**
69      * @param newOrientation
70      * @param newContinuousLayout
71      * @param newLeftComponent
72      * @param newRightComponent
73      */

74     public TitleBarSplitPane(
75         int newOrientation,
76         boolean newContinuousLayout,
77         Component JavaDoc newLeftComponent,
78         Component JavaDoc newRightComponent) {
79         super(
80             newOrientation,
81             newContinuousLayout,
82             newLeftComponent,
83             newRightComponent);
84         this.setup();
85     }
86
87     /* (non-Javadoc)
88      * @see javax.swing.JSplitPane#setDividerLocation(double)
89      */

90     public void setDividerLocation(double loc) {
91         super.setDividerLocation(new Integer JavaDoc(HEIGHT).intValue());
92     }
93
94     /* (non-Javadoc)
95      * @see com.simulacramedia.contentmanager.window.swing.ExtendedSplitPane#setExtDividerLocation(int)
96      */

97     public void setExtDividerLocation(int loc) {
98         super.setDividerLocation(new Integer JavaDoc(HEIGHT).intValue());
99     }
100
101     private void setup() {
102         this.setOneTouchExpandable(true);
103         this.setContinuousLayout(true);
104         this.setDividerSize(0);
105         this.setExtDividerLocation(HEIGHT);
106     }
107
108     public class DividerListener
109         extends ComponentAdapter JavaDoc
110         implements PropertyChangeListener JavaDoc {
111         double percentage = 1.0;
112         boolean ignore = false;
113
114         public void propertyChange(PropertyChangeEvent JavaDoc event) {
115             String JavaDoc prop = event.getPropertyName();
116             JSplitPane JavaDoc split = (JSplitPane JavaDoc) event.getSource();
117             if (prop.equals("lastDividerLocation")) {
118                 if (ignore) {
119                     ignore = false;
120                 } else {
121                     setExtDividerLocation(new Integer JavaDoc(HEIGHT).intValue());
122                 }
123             }
124         }
125
126         public void componentResized(ComponentEvent JavaDoc event) {
127             ignore = true;
128             setExtDividerLocation(new Integer JavaDoc(HEIGHT).intValue());
129             repaint();
130         }
131     }
132
133 }
134
Popular Tags