diff options
-rw-r--r-- | src/swing/scala/swing/Button.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/ButtonGroup.scala | 18 | ||||
-rw-r--r-- | src/swing/scala/swing/Frame.scala | 6 | ||||
-rw-r--r-- | src/swing/scala/swing/Menu.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/PushButton.scala | 2 | ||||
-rw-r--r-- | src/swing/scala/swing/ToggleButton.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/UIElement.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/Views.scala | 2 | ||||
-rw-r--r-- | src/swing/scala/swing/event/ButtonClicked.scala | 2 | ||||
-rw-r--r-- | src/swing/scala/swing/test/CelsiusConverter.scala | 2 | ||||
-rw-r--r-- | src/swing/scala/swing/test/Dialogs.scala | 10 | ||||
-rw-r--r-- | src/swing/scala/swing/test/GridBagDemo.scala | 12 | ||||
-rw-r--r-- | src/swing/scala/swing/test/SimpleApplet.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/test/SwingApp.scala | 2 |
14 files changed, 39 insertions, 37 deletions
diff --git a/src/swing/scala/swing/Button.scala b/src/swing/scala/swing/Button.scala index 11d500c41b..fcf164d9b0 100644 --- a/src/swing/scala/swing/Button.scala +++ b/src/swing/scala/swing/Button.scala @@ -9,7 +9,7 @@ import event._ * * @see javax.swing.AbstractButton */ -abstract class Button extends Component with Action.Trigger with Publisher { +abstract class AbstractButton extends Component with Action.Trigger with Publisher { override lazy val peer: JAbstractButton = new JAbstractButton {} def text: String = peer.getText @@ -26,7 +26,7 @@ abstract class Button extends Component with Action.Trigger with Publisher { peer.addActionListener(new java.awt.event.ActionListener { def actionPerformed(e: java.awt.event.ActionEvent) { - publish(ButtonClicked(Button.this)) + publish(ButtonClicked(AbstractButton.this)) } }) diff --git a/src/swing/scala/swing/ButtonGroup.scala b/src/swing/scala/swing/ButtonGroup.scala index 7000df60b7..39700540d5 100644 --- a/src/swing/scala/swing/ButtonGroup.scala +++ b/src/swing/scala/swing/ButtonGroup.scala @@ -11,23 +11,23 @@ import scala.collection.mutable.Buffer * * @see javax.swing.ButtonGroup */ -class ButtonGroup(initialButtons: Button*) { +class ButtonGroup(initialButtons: AbstractButton*) { val peer: javax.swing.ButtonGroup = new javax.swing.ButtonGroup - val buttons: mutable.Set[Button] = new mutable.Set[Button] { - def -=(b: Button) { peer.remove(b.peer) } - def +=(b: Button) { peer.add(b.peer) } - def contains(b: Button) = elements.contains(b) + val buttons: mutable.Set[AbstractButton] = new mutable.Set[AbstractButton] { + def -=(b: AbstractButton) { peer.remove(b.peer) } + def +=(b: AbstractButton) { peer.add(b.peer) } + def contains(b: AbstractButton) = elements.contains(b) def size = peer.getButtonCount - def elements: Iterator[Button] = new Iterator[Button] { + def elements: Iterator[AbstractButton] = new Iterator[AbstractButton] { val enum = peer.getElements - def next = Component.wrapperFor[Button](enum.nextElement) + def next = Component.wrapperFor[AbstractButton](enum.nextElement) def hasNext = enum.hasMoreElements } } buttons ++= initialButtons //1.6: def deselectAll() { peer.clearSelection } - def selected: Option[Button] = buttons.find(_.selected) - def select(b: Button) { peer.setSelected(b.peer.getModel, true) } + def selected: Option[AbstractButton] = buttons.find(_.selected) + def select(b: AbstractButton) { peer.setSelected(b.peer.getModel, true) } } diff --git a/src/swing/scala/swing/Frame.scala b/src/swing/scala/swing/Frame.scala index b899cc82f6..afccd28aef 100644 --- a/src/swing/scala/swing/Frame.scala +++ b/src/swing/scala/swing/Frame.scala @@ -17,12 +17,12 @@ class Frame extends UIElement with RootPanel with Publisher { super.contents_=(c) peer.pack() // pack also validates, which is generally required after an add } - def defaultButton: Option[PushButton] = + def defaultButton: Option[Button] = Swing.toOption(peer.getRootPane.getDefaultButton).map(Component.wrapperFor(_)) - def defaultButton_=(b: PushButton) { + def defaultButton_=(b: Button) { peer.getRootPane.setDefaultButton(b.peer) } - def defaultButton_=(b: Option[PushButton]) { + def defaultButton_=(b: Option[Button]) { peer.getRootPane.setDefaultButton(Swing.toNull(b.map(_.peer))) } diff --git a/src/swing/scala/swing/Menu.scala b/src/swing/scala/swing/Menu.scala index 57da050ef0..418439435d 100644 --- a/src/swing/scala/swing/Menu.scala +++ b/src/swing/scala/swing/Menu.scala @@ -25,7 +25,7 @@ class MenuBar extends Component with SequentialContainer.Wrapper { /** * @see javax.swing.JMenuItem */ -class MenuItem(title0: String) extends Button { +class MenuItem(title0: String) extends AbstractButton { override lazy val peer: JMenuItem = new JMenuItem(title0) def this(a: Action) = { this("") @@ -51,4 +51,4 @@ class RadioMenuItem(title0: String) extends MenuItem(title0) { */ class CheckMenuItem(title0: String) extends MenuItem(title0) { override lazy val peer: JCheckBoxMenuItem = new JCheckBoxMenuItem(title0) -}
\ No newline at end of file +} diff --git a/src/swing/scala/swing/PushButton.scala b/src/swing/scala/swing/PushButton.scala index 0e4d6c5f8c..c28773a9c4 100644 --- a/src/swing/scala/swing/PushButton.scala +++ b/src/swing/scala/swing/PushButton.scala @@ -8,7 +8,7 @@ import event._ * * @see javax.swing.JButton */ -class PushButton(text0: String) extends Button with Publisher { +class Button(text0: String) extends AbstractButton with Publisher { override lazy val peer: JButton = new JButton(text0) def this() = this("") def this(a: Action) = { diff --git a/src/swing/scala/swing/ToggleButton.scala b/src/swing/scala/swing/ToggleButton.scala index 4132ecae2c..0f04aa9f35 100644 --- a/src/swing/scala/swing/ToggleButton.scala +++ b/src/swing/scala/swing/ToggleButton.scala @@ -8,7 +8,7 @@ import event._ * * @see javax.swing.JToggleButton */ -class ToggleButton(text0: String) extends Button { +class ToggleButton(text0: String) extends AbstractButton { override lazy val peer: JToggleButton = new JToggleButton(text0) def this() = this("") -}
\ No newline at end of file +} diff --git a/src/swing/scala/swing/UIElement.scala b/src/swing/scala/swing/UIElement.scala index 6bfd579360..6f5b91a0b6 100644 --- a/src/swing/scala/swing/UIElement.scala +++ b/src/swing/scala/swing/UIElement.scala @@ -1,6 +1,6 @@ package scala.swing -import java.awt.{Color, Cursor, Font} +import java.awt.{Color, Cursor, Font, Dimension} /** * The base trait of all user interface elements. @@ -19,6 +19,8 @@ trait UIElement { def location = peer.getLocation def bounds = peer.getBounds def size = peer.getSize + def size_=(dim: Dimension) = peer.setSize(dim) + def size_=(xy: (Int, Int)) = peer.setSize(new Dimension(xy._1, xy._2)) def locale = peer.getLocale def toolkit = peer.getToolkit diff --git a/src/swing/scala/swing/Views.scala b/src/swing/scala/swing/Views.scala index eeea5eb721..4afe32f956 100644 --- a/src/swing/scala/swing/Views.scala +++ b/src/swing/scala/swing/Views.scala @@ -2,6 +2,6 @@ package scala.swing object Views { //implicit def action2MenuItem(a: Action): MenuItem = new MenuItem(a) - //implicit def action2PushButton(a: Action): PushButton = new PushButton(a) + //implicit def action2Button(a: Action): Button = new Button(a) //implicit def string2Label(s: String): Label = new Label(s) } diff --git a/src/swing/scala/swing/event/ButtonClicked.scala b/src/swing/scala/swing/event/ButtonClicked.scala index cf826a6ff6..c0029f27fe 100644 --- a/src/swing/scala/swing/event/ButtonClicked.scala +++ b/src/swing/scala/swing/event/ButtonClicked.scala @@ -1,4 +1,4 @@ package scala.swing.event -case class ButtonClicked(override val source: Button) extends ComponentEvent(source) +case class ButtonClicked(override val source: AbstractButton) extends ComponentEvent(source) diff --git a/src/swing/scala/swing/test/CelsiusConverter.scala b/src/swing/scala/swing/test/CelsiusConverter.scala index 3578419698..985e562d6d 100644 --- a/src/swing/scala/swing/test/CelsiusConverter.scala +++ b/src/swing/scala/swing/test/CelsiusConverter.scala @@ -14,7 +14,7 @@ object CelsiusConverter extends SimpleGUIApplication { text = "Celsius" border = Border.Empty(5, 5, 5, 5) } - object convertButton extends PushButton { + object convertButton extends Button { text = "Convert"//new javax.swing.ImageIcon("c:\\workspace\\gui\\images\\convert.gif") //border = Border.Empty(5, 5, 5, 5) } diff --git a/src/swing/scala/swing/test/Dialogs.scala b/src/swing/scala/swing/test/Dialogs.scala index ac156343f1..a126d7f9c9 100644 --- a/src/swing/scala/swing/test/Dialogs.scala +++ b/src/swing/scala/swing/test/Dialogs.scala @@ -17,17 +17,17 @@ object Dialogs extends SimpleGUIApplication { c.grid = (1,1) val chooser = new FileChooser - layout(new PushButton(Action("Open") { + layout(new Button(Action("Open") { chooser.showOpenDialog(grid) })) = c c.grid = (1,2) - layout(new PushButton(Action("Save") { + layout(new Button(Action("Save") { chooser.showSaveDialog(grid) })) = c c.grid = (1,3) - layout(new PushButton(Action("Custom") { + layout(new Button(Action("Custom") { chooser.showDialog(grid, buttonText.text) })) = c @@ -54,7 +54,7 @@ object Dialogs extends SimpleGUIApplication { contents ++= radios } layout(buttons) = Position.North - layout(new PushButton(Action("Show It!") { + layout(new Button(Action("Show It!") { import Dialog._ mutex.selected.get match { case `ok` => @@ -111,7 +111,7 @@ object Dialogs extends SimpleGUIApplication { contents ++= radios } layout(buttons) = Position.North - layout(new PushButton(Action("Show It!") { + layout(new Button(Action("Show It!") { import Dialog._ mutex.selected.get match { case `pick` => diff --git a/src/swing/scala/swing/test/GridBagDemo.scala b/src/swing/scala/swing/test/GridBagDemo.scala index b2092c934d..e47d0ae4ca 100644 --- a/src/swing/scala/swing/test/GridBagDemo.scala +++ b/src/swing/scala/swing/test/GridBagDemo.scala @@ -13,7 +13,7 @@ object GridBagDemo extends SimpleGUIApplication { c.fill = Fill.Horizontal } - val button1 = new PushButton("Button 1") + val button1 = new Button("Button 1") c.weightx = 0.5 @@ -22,21 +22,21 @@ object GridBagDemo extends SimpleGUIApplication { c.gridy = 0; layout(button1) = c - val button2 = new PushButton("Button 2") + val button2 = new Button("Button 2") c.fill = Fill.Horizontal c.weightx = 0.5; c.gridx = 1; c.gridy = 0; layout(button2) = c - val button3 = new PushButton("Button 3") + val button3 = new Button("Button 3") c.fill = Fill.Horizontal c.weightx = 0.5; c.gridx = 2; c.gridy = 0; layout(button3) = c - val button4 = new PushButton("Long-Named Button 4") + val button4 = new Button("Long-Named Button 4") c.fill = Fill.Horizontal c.ipady = 40; //make this component tall c.weightx = 0.0; @@ -45,7 +45,7 @@ object GridBagDemo extends SimpleGUIApplication { c.gridy = 1; layout(button4) = c - val button5 = new PushButton("5") + val button5 = new Button("5") c.fill = Fill.Horizontal c.ipady = 0; //reset to default c.weighty = 1.0; //request any extra vertical space @@ -61,4 +61,4 @@ object GridBagDemo extends SimpleGUIApplication { title = "GridBag Demo" contents = ui } -}
\ No newline at end of file +} diff --git a/src/swing/scala/swing/test/SimpleApplet.scala b/src/swing/scala/swing/test/SimpleApplet.scala index 510c63f3e3..3382e5c2e8 100644 --- a/src/swing/scala/swing/test/SimpleApplet.scala +++ b/src/swing/scala/swing/test/SimpleApplet.scala @@ -5,7 +5,7 @@ import event._ class SimpleApplet extends Applet { object ui extends UI with Reactor { def init() = { - val button = new PushButton("Press here!") + val button = new Button("Press here!") val text = new TextArea("Java Version: " + System.getProperty("java.version")+"\n") listenTo(button) @@ -16,4 +16,4 @@ class SimpleApplet extends Applet { contents = new BoxPanel(Orientation.Vertical) { contents.append(button, text) } } } -}
\ No newline at end of file +} diff --git a/src/swing/scala/swing/test/SwingApp.scala b/src/swing/scala/swing/test/SwingApp.scala index 328b488b5b..9773e91153 100644 --- a/src/swing/scala/swing/test/SwingApp.scala +++ b/src/swing/scala/swing/test/SwingApp.scala @@ -17,7 +17,7 @@ object SwingApp extends SimpleGUIApplication { text = prefix + numclicks } } - object button extends PushButton { + object button extends Button text = "I am a button" } contents = new FlowPanel { |