diff options
-rw-r--r-- | src/swing/scala/swing/Frame.scala | 1 | ||||
-rw-r--r-- | src/swing/scala/swing/test/UIDemo.scala | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/swing/scala/swing/Frame.scala b/src/swing/scala/swing/Frame.scala index 4e82ad1e58..c06e6f9538 100644 --- a/src/swing/scala/swing/Frame.scala +++ b/src/swing/scala/swing/Frame.scala @@ -35,6 +35,7 @@ class Frame extends UIElement with RootPanel with Publisher { def menuBar_=(m: MenuBar) = peer.setJMenuBar(m.peer) def setLocationRelativeTo(c: UIElement) { peer.setLocationRelativeTo(c.peer) } + def centerOnScreen() { peer.setLocationRelativeTo(null) } def location_=(p: Point) { peer.setLocation(p) } def iconImage: Image = peer.getIconImage diff --git a/src/swing/scala/swing/test/UIDemo.scala b/src/swing/scala/swing/test/UIDemo.scala index 716bdd6694..5f1cd93bb8 100644 --- a/src/swing/scala/swing/test/UIDemo.scala +++ b/src/swing/scala/swing/test/UIDemo.scala @@ -38,6 +38,7 @@ object UIDemo extends SimpleGUIApplication { import TabbedPane._ val buttons = new FlowPanel { border = Swing.EmptyBorder(5,5,5,5) + contents += new BoxPanel(Orientation.Vertical) { border = CompoundBorder(TitledBorder(EtchedBorder, "Radio Buttons"), EmptyBorder(5,5,5,10)) val a = new RadioButton("Green Vegetables") @@ -65,6 +66,11 @@ object UIDemo extends SimpleGUIApplication { reactLive = live.selected } } + contents += new Button("Center Frame") { + reactions += { + case ButtonClicked(_) => centerOnScreen() + } + } } pages += new Page("Buttons", buttons) pages += new Page("GridBag", GridBagDemo.ui) @@ -79,7 +85,6 @@ object UIDemo extends SimpleGUIApplication { val password = new FlowPanel { contents += new Label("Enter your secret password here ") val field = new PasswordField(10) - contents += field val label = new Label(field.text) contents += label |