@@ -17,54 +17,69 @@ import javax.swing.JSplitPane
17
17
import scala .collection .immutable
18
18
import scala .swing .Swing .nullPeer
19
19
20
- /**
21
- * A container with exactly two children. Arranges them side by side, either
22
- * horizontally or vertically. Displays a draggable divider component between
23
- * them that lets the user adjust the size ratio of the children.
24
- *
25
- * @see javax.swing.JSplitPane
26
- */
27
- class SplitPane (o : Orientation .Value , left : Component , right : Component ) extends Component with Container with Orientable .Wrapper {
28
- override lazy val peer : JSplitPane =
29
- new javax.swing.JSplitPane (o.id, left.peer, right.peer) with SuperMixin
20
+ /** A container with exactly two children. Arranges them side by side, either
21
+ * horizontally or vertically. Displays a draggable divider component between
22
+ * them that lets the user adjust the size ratio of the children.
23
+ *
24
+ * @param o the orientation of the divider. Note that we are using
25
+ * `Orientation.Horizontal` and `Orientation.Vertical`, which are
26
+ * different from the underlying `JSplitPane` values.
27
+ * `Orientation.Horizontal` corresponds with `VERTICAL_SPLIT`, thus
28
+ * producing a left and right component and a "vertical divider",
29
+ * and `Orientation.Vertical` corresponds with `HORIZONTAL_SPLIT`, thus
30
+ * producing a top and bottom component and a "horizontal divider".
31
+ *
32
+ * @see javax.swing.JSplitPane
33
+ */
34
+ class SplitPane (o : Orientation .Value , left : Component , right : Component )
35
+ extends Component with Container with Orientable .Wrapper {
36
+
30
37
def this (o : Orientation .Value ) = this (o, new Component {}, new Component {})
31
38
def this () = this (Orientation .Horizontal )
32
39
40
+ override lazy val peer : JSplitPane =
41
+ new javax.swing.JSplitPane (o.id, left.peer, right.peer) with SuperMixin
42
+
33
43
def contents : immutable.Seq [Component ] = List (leftComponent, rightComponent)
44
+
34
45
def contents_= (left : Component , right : Component ): Unit = {
35
- peer.setLeftComponent(nullPeer(left))
46
+ peer.setLeftComponent (nullPeer(left))
36
47
peer.setRightComponent(nullPeer(right))
37
48
}
38
49
39
50
def topComponent : Component =
40
51
UIElement .cachedWrapper[Component ](peer.getTopComponent.asInstanceOf [javax.swing.JComponent ])
41
52
def topComponent_= (c : Component ): Unit = peer.setTopComponent(nullPeer(c))
53
+
42
54
def bottomComponent : Component =
43
55
UIElement .cachedWrapper[Component ](peer.getBottomComponent.asInstanceOf [javax.swing.JComponent ])
44
56
def bottomComponent_= (c : Component ): Unit = peer.setBottomComponent(nullPeer(c))
45
57
46
- def leftComponent : Component = topComponent
47
- def leftComponent_= (c : Component ): Unit = { topComponent = c }
48
- def rightComponent : Component = bottomComponent
49
- def rightComponent_= (c : Component ): Unit = { bottomComponent = c }
58
+ def leftComponent : Component = topComponent
59
+ def leftComponent_= (c : Component ): Unit = { topComponent = c }
50
60
51
- def dividerLocation : Int = peer.getDividerLocation
52
- def dividerLocation_= (n : Int ): Unit = peer.setDividerLocation(n)
61
+ def rightComponent : Component = bottomComponent
62
+ def rightComponent_= (c : Component ): Unit = { bottomComponent = c }
63
+
64
+ def dividerLocation : Int = peer.getDividerLocation
65
+ def dividerLocation_= (n : Int ): Unit = peer.setDividerLocation(n)
53
66
54
67
/* def proportionalDividerLocation: Double =
55
68
if (orientation == Orientation.Vertical) dividerLocation / (size.height - dividerSize)
56
69
else dividerLocation / (size.width - dividerSize)*/
57
70
def dividerLocation_= (f : Double ): Unit = peer.setDividerLocation(f)
58
71
59
- def dividerSize : Int = peer.getDividerSize
60
- def dividerSize_= (n : Int ): Unit = peer.setDividerSize(n)
61
- def resizeWeight : Double = peer.getResizeWeight
62
- def resizeWeight_= (n : Double ): Unit = peer.setResizeWeight(n)
72
+ def dividerSize : Int = peer.getDividerSize
73
+ def dividerSize_= (n : Int ): Unit = peer.setDividerSize(n)
74
+
75
+ def resizeWeight : Double = peer.getResizeWeight
76
+ def resizeWeight_= (n : Double ): Unit = peer.setResizeWeight(n)
63
77
64
78
def resetToPreferredSizes (): Unit = peer.resetToPreferredSizes()
65
79
66
- def oneTouchExpandable : Boolean = peer.isOneTouchExpandable
67
- def oneTouchExpandable_= (b : Boolean ): Unit = peer.setOneTouchExpandable(b)
68
- def continuousLayout : Boolean = peer.isContinuousLayout
69
- def continuousLayout_= (b : Boolean ): Unit = peer.setContinuousLayout(b)
80
+ def oneTouchExpandable : Boolean = peer.isOneTouchExpandable
81
+ def oneTouchExpandable_= (b : Boolean ): Unit = peer.setOneTouchExpandable(b)
82
+
83
+ def continuousLayout : Boolean = peer.isContinuousLayout
84
+ def continuousLayout_= (b : Boolean ): Unit = peer.setContinuousLayout(b)
70
85
}
0 commit comments