KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > frame > util > SplitPane


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.frame.util;
17
18 import javax.swing.JComponent JavaDoc;
19 import javax.swing.JSplitPane JavaDoc;
20
21
22 public class SplitPane extends JSplitPane JavaDoc {
23     public JSplitPane JavaDoc splitPane = new JSplitPane JavaDoc();
24     JComponent JavaDoc header;
25     JComponent JavaDoc message;
26     JComponent JavaDoc attachment;
27     boolean hide = false;
28     int last = 0;
29     int lastAttach = 0;
30
31     public SplitPane() {
32         super();
33     }
34
35     public SplitPane(JComponent JavaDoc header, JComponent JavaDoc message,
36         JComponent JavaDoc attachment) {
37         super();
38         this.header = header;
39         this.message = message;
40         this.attachment = attachment;
41
42         setBorder(null);
43         splitPane.setBorder(null);
44
45         //splitPane.setDividerSize(1);
46
//setDividerSize(5);
47
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
48         setOrientation(JSplitPane.VERTICAL_SPLIT);
49
50         setDividerLocation(0.75);
51
52         // this has to be set by themes
53
//setDividerSize( 5 );
54
setResizeWeight(0.25);
55
56         splitPane.setDividerLocation(0.9);
57         splitPane.setResizeWeight(0.9);
58
59         // this has to be set by themes
60
//splitPane.setDividerSize( 5 );
61
add(header, JSplitPane.TOP);
62         add(splitPane, JSplitPane.BOTTOM);
63         splitPane.add(message, JSplitPane.TOP);
64         splitPane.add(attachment, JSplitPane.BOTTOM);
65
66         //splitPane.resetToPreferredSizes();
67
//hideAttachmentViewer();
68
}
69
70     public void hideAttachmentViewer() {
71         if (hide == true) {
72             return;
73         }
74
75         last = getDividerLocation();
76         lastAttach = splitPane.getDividerLocation();
77
78         remove(splitPane);
79         remove(header);
80
81         add(header, JSplitPane.TOP);
82         add(message, JSplitPane.BOTTOM);
83
84         hide = true;
85
86         setDividerLocation(last);
87     }
88
89     public void showAttachmentViewer() {
90         if (hide == false) {
91             return;
92         }
93
94         last = getDividerLocation();
95
96         remove(header);
97         remove(message);
98
99         splitPane.add(message, JSplitPane.TOP);
100         splitPane.add(attachment, JSplitPane.BOTTOM);
101
102         add(header, JSplitPane.TOP);
103         add(splitPane, JSplitPane.BOTTOM);
104
105         setDividerLocation(last);
106         splitPane.setDividerLocation(lastAttach);
107
108         hide = false;
109     }
110 }
111
Popular Tags