Skip to content

Commit bd92bfa

Browse files
author
Allan Jacobs
committed
Add validate to UIElement. Remove one last reference to the peer for its validate method. Comment out references to java.swing.UIManager.
1 parent 4a6544f commit bd92bfa

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

examples/src/main/scala/scala/swing/examples/tutorials/components/ButtonDemo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ object ButtonDemo extends SimpleSwingApplication {
104104

105105
lazy val top = new MainFrame() {
106106
title = "ButtonDemo"
107-
javax.swing.UIManager.put("swing.boldMetal", false)
107+
//TD javax.swing.UIManager.put("swing.boldMetal", false)
108108

109109
contents = new ButtonDemo()
110110
}

examples/src/main/scala/scala/swing/examples/tutorials/components/LabelDemo.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ class LabelDemo extends GridPanel(3, 1) {
6969
}
7070

7171
object LabelDemo extends SimpleSwingApplication {
72-
UIManager.put("swing.boldMetal", false)
72+
//TD UIManager.put("swing.boldMetal", false)
7373
/** Returns an ImageIcon option, or None if the path was invalid. */
7474
def createImageIcon(path: String, desc:String ): Option[javax.swing.ImageIcon] =
7575
Option(resourceFromClassloader(path)).map(imgURL => Swing.Icon(imgURL))
7676

7777
lazy val top = new MainFrame() {
7878
title = "LabelDemo"
7979
//Create and set up the content pane.
80-
javax.swing.UIManager.put("swing.boldMetal", false)
80+
//TD javax.swing.UIManager.put("swing.boldMetal", false)
8181
contents = new LabelDemo()
8282
}
8383
}

examples/src/main/scala/scala/swing/examples/tutorials/components/SliderDemo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class SliderDemo(window: Window) extends BoxPanel(Orientation.Vertical) with Act
161161
}
162162

163163
object SliderDemo extends SimpleSwingApplication {
164-
UIManager.put("swing.boldMetal", false)
164+
//TD UIManager.put("swing.boldMetal", false)
165165
/** Returns an ImageIcon, or null if the path was invalid. */
166166
def createImageIcon(path: String): Option[javax.swing.ImageIcon] = {
167167
Option(resourceFromClassloader(path)).map(imgURL => Swing.Icon(imgURL))

examples/src/main/scala/scala/swing/examples/tutorials/layout/BorderLayoutDemo.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
package scala.swing.examples.tutorials.layout
3232

3333
import scala.swing._
34-
import javax.swing.{SwingUtilities, UIManager}
34+
import javax.swing.UIManager
3535
import java.awt.{ ComponentOrientation, Dimension }
3636

3737
/**
@@ -63,9 +63,9 @@ class BorderLayoutDemo extends BorderPanel {
6363
object BorderLayoutDemo extends SimpleSwingApplication {
6464
val RightToLeft = true
6565
/* Use an appropriate Look and Feel */
66-
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel")
66+
// UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel")
6767
/* Turn off metal's use bold fonts */
68-
UIManager.put("swing.boldMetal", false)
68+
//TD UIManager.put("swing.boldMetal", false)
6969
//Create and set up the window.
7070
lazy val top = new MainFrame {
7171
title = "BorderLayoutDemo"

examples/src/main/scala/scala/swing/examples/tutorials/layout/FlowLayoutDemo.scala

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ class FlowLayoutDemo extends BorderPanel {
5454
val RtoLbutton = new RadioButton(RtoL)
5555

5656
//Add buttons to the experiment layout
57-
compsToExperiment.contents += new Button("Button 1")
58-
compsToExperiment.contents += new Button("Button 2")
59-
compsToExperiment.contents += new Button("Button 3")
60-
compsToExperiment.contents += new Button("Long Named Button 4")
61-
compsToExperiment.contents += new Button("5")
57+
val buttonSeq = Seq[Button](
58+
new Button("Button 1"),
59+
new Button("Button 2"),
60+
new Button("Button 3"),
61+
new Button("Long Named Button 4"),
62+
new Button("5") )
63+
compsToExperiment.contents ++= buttonSeq
6264

6365
//Left to right component orientation is selected by default
6466
compsToExperiment.componentOrientation = ComponentOrientation.LEFT_TO_RIGHT
@@ -78,22 +80,19 @@ class FlowLayoutDemo extends BorderPanel {
7880
listenTo(applyButton)
7981
reactions += {
8082
case ButtonClicked(`applyButton`) =>
81-
if (LtoRbutton.selected) {
82-
compsToExperiment.componentOrientation = ComponentOrientation.LEFT_TO_RIGHT
83-
}
84-
else {
85-
compsToExperiment.componentOrientation = ComponentOrientation.RIGHT_TO_LEFT
86-
}
87-
compsToExperiment.peer.validate()
83+
compsToExperiment.componentOrientation =
84+
if (LtoRbutton.selected) ComponentOrientation.LEFT_TO_RIGHT
85+
else ComponentOrientation.RIGHT_TO_LEFT
86+
compsToExperiment.validate()
8887
compsToExperiment.repaint()
8988
}
9089
}
9190

9291
object FlowLayoutDemo extends SimpleSwingApplication {
9392
/* Use an appropriate Look and Feel */
94-
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel")
93+
//TD UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel")
9594
/* Turn off metal's use of bold fonts */
96-
UIManager.put("swing.boldMetal", false)
95+
//TD UIManager.put("swing.boldMetal", false)
9796
lazy val top = new MainFrame() {
9897
title = "FlowLayoutDemo"
9998
contents = new FlowLayoutDemo()

examples/src/main/scala/scala/swing/examples/tutorials/misc/FocusConceptsDemo.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ class FocusConceptsDemo extends BorderPanel {
8989
object FocusConceptsDemo extends SimpleSwingApplication {
9090

9191
/* Use an appropriate Look and Feel */
92-
try {
93-
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
94-
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
95-
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
96-
} catch {
97-
case NonFatal(ex) => ex.printStackTrace()
98-
}
92+
//TD try {
93+
// // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
94+
// //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
95+
// UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
96+
// } catch {
97+
// case NonFatal(ex) => ex.printStackTrace()
98+
// }
9999
/* Turn off metal's use of bold fonts */
100-
UIManager.put("swing.boldMetal", false);
100+
//TD UIManager.put("swing.boldMetal", false);
101101
//Create and set up the window.
102102
lazy val top = new MainFrame() {
103103
title = "FocusConceptsDemo"

src/main/scala/scala/swing/UIElement.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ trait UIElement extends Proxy with LazyPublisher {
111111
def showing: Boolean = peer.isShowing
112112
def displayable: Boolean = peer.isDisplayable
113113

114+
def validate() { peer.validate }
114115
def repaint() { peer.repaint }
115116
def repaint(rect: Rectangle) { peer.repaint(rect.x, rect.y, rect.width, rect.height) }
116117
def ignoreRepaint: Boolean = peer.getIgnoreRepaint

0 commit comments

Comments
 (0)