01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.components;
20:
21: import java.awt.Graphics;
22:
23: import javax.swing.JSplitPane;
24:
25: /**
26: *
27: * @author Jeff Tassin
28: */
29: public class CustomSplitPane extends JSplitPane {
30: private boolean m_firsttime = true;
31: private double m_divlocation = 0.5f;
32: /**
33: * an integer value for the divider location. If not -1, then takes
34: * pecendence of the proportional value
35: */
36: private int m_idivlocation = -1;
37:
38: /**
39: * Creates an instance of a CustomSplitPane
40: */
41: public CustomSplitPane(int newOrientation) {
42: super (newOrientation);
43: }
44:
45: public void setDividerLocation(int divlocation) {
46: if (m_firsttime) {
47: m_idivlocation = divlocation;
48: }
49: super .setDividerLocation(divlocation);
50: }
51:
52: public void setDividerLocation(double propLocation) {
53: if (m_firsttime) {
54: m_divlocation = propLocation;
55: m_idivlocation = -1;
56: }
57: super .setDividerLocation(propLocation);
58: }
59:
60: public void paint(Graphics g) {
61: if (m_firsttime) {
62: m_firsttime = false;
63:
64: if (m_idivlocation < 0)
65: setDividerLocation(m_divlocation);
66: else
67: setDividerLocation(m_idivlocation);
68:
69: }
70: super.paint(g);
71: }
72:
73: }
|