Skip to content

Commit 8b1a028

Browse files
committed
remove warnings, unused imports and reformat
1 parent dc2bda1 commit 8b1a028

16 files changed

+190
-140
lines changed

examples/src/main/scala/scala/swing/examples/ButtonApp.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
package scala.swing.examples
1010

11-
import java.awt.Dimension
12-
1311
import scala.swing._
1412
import scala.swing.event._
1513

examples/src/main/scala/scala/swing/examples/CelsiusConverter.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ package scala.swing.examples
1111
import scala.swing._
1212
import scala.swing.event._
1313

14-
/** A GUI app to convert celsius to centigrade
14+
/**
15+
* A GUI app to convert celsius to centigrade
1516
*/
1617
object CelsiusConverter extends SimpleSwingApplication {
1718
def top = new MainFrame {
@@ -22,7 +23,7 @@ object CelsiusConverter extends SimpleSwingApplication {
2223
border = Swing.EmptyBorder(5, 5, 5, 5)
2324
}
2425
val convertButton = new Button {
25-
text = "Convert"//new javax.swing.ImageIcon("c:\\workspace\\gui\\images\\convert.gif")
26+
text = "Convert" //new javax.swing.ImageIcon("c:\\workspace\\gui\\images\\convert.gif")
2627
//border = Border.Empty(5, 5, 5, 5)
2728
}
2829
val fahrenheitLabel = new Label {
@@ -33,14 +34,14 @@ object CelsiusConverter extends SimpleSwingApplication {
3334
def convert() {
3435
val c = Integer.parseInt(tempCelsius.text)
3536
val f = c * 9 / 5 + 32
36-
text = "<html><font color = red>"+f+"</font> Fahrenheit</html>"
37+
text = "<html><font color = red>" + f + "</font> Fahrenheit</html>"
3738
}
3839

3940
reactions += {
4041
case ButtonClicked(_) | EditDone(_) => convert()
4142
}
4243
}
43-
contents = new GridPanel(2,2) {
44+
contents = new GridPanel(2, 2) {
4445
contents.append(tempCelsius, celsiusLabel, convertButton, fahrenheitLabel)
4546
border = Swing.EmptyBorder(10, 10, 10, 10)
4647
}

examples/src/main/scala/scala/swing/examples/CelsiusConverter2.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ object CelsiusConverter2 extends SimpleSwingApplication {
1717
columns = 5
1818
horizontalAlignment = Alignment.Right
1919
}
20+
2021
val celsius = newField
2122
val fahrenheit = newField
2223

@@ -33,12 +34,13 @@ object CelsiusConverter2 extends SimpleSwingApplication {
3334
}
3435

3536
lazy val ui = new FlowPanel(celsius, new Label(" Celsius = "),
36-
fahrenheit, new Label(" Fahrenheit")) {
37+
fahrenheit, new Label(" Fahrenheit")) {
3738
border = Swing.EmptyBorder(15, 10, 10, 10)
3839
}
40+
3941
def top = new MainFrame {
4042
title = "Convert Celsius / Fahrenheit"
41-
contents = ui
43+
contents = ui
4244
}
4345
}
4446

examples/src/main/scala/scala/swing/examples/ColorChooserDemo.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package scala.swing.examples
1010

11-
import java.awt.{Color, Font, Dimension}
11+
import java.awt.{Color, Font}
1212
import scala.swing._
1313
import scala.swing.event._
1414
import scala.swing.Swing._
@@ -17,17 +17,25 @@ import scala.swing.BorderPanel._
1717
/**
1818
* Demo for ColorChooser.
1919
* Based on http://download.oracle.com/javase/tutorial/uiswing/components/colorchooser.html
20-
*
20+
*
2121
2222
*/
2323
object ColorChooserDemo extends SimpleSwingApplication {
2424
def top = new MainFrame {
2525
title = "ColorChooser Demo"
2626
size = new Dimension(400, 400)
27-
27+
2828
contents = ui
2929
}
3030

31+
val banner = new Label("Welcome to Scala Swing") {
32+
horizontalAlignment = Alignment.Center
33+
foreground = Color.yellow
34+
background = Color.blue
35+
opaque = true
36+
font = new Font("SansSerif", Font.BOLD, 24)
37+
}
38+
3139
def ui = new BorderPanel {
3240
val colorChooser = new ColorChooser {
3341
reactions += {
@@ -37,20 +45,12 @@ object ColorChooserDemo extends SimpleSwingApplication {
3745
}
3846

3947
colorChooser.border = TitledBorder(EtchedBorder, "Choose Text Color")
40-
41-
val banner = new Label("Welcome to Scala Swing") {
42-
horizontalAlignment = Alignment.Center
43-
foreground = Color.yellow
44-
background = Color.blue
45-
opaque = true
46-
font = new Font("SansSerif", Font.BOLD, 24)
47-
}
48-
48+
4949
val bannerArea = new BorderPanel {
5050
layout(banner) = Position.Center
5151
border = TitledBorder(EtchedBorder, "Banner")
5252
}
53-
53+
5454
// Display a color selection dialog when button pressed
5555
val selectColor = new Button("Choose Background Color") {
5656
reactions += {

examples/src/main/scala/scala/swing/examples/ComboBoxes.scala

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,39 @@ import javax.swing.{Icon, ImageIcon}
2121
* TODO: clean up layout
2222
*/
2323
object ComboBoxes extends SimpleSwingApplication {
24+
2425
import ComboBox._
26+
2527
lazy val ui = new FlowPanel {
26-
contents += new ComboBox(List(1,2,3,4))
27-
28-
val patterns = List("dd MMMMM yyyy",
29-
"dd.MM.yy",
30-
"MM/dd/yy",
31-
"yyyy.MM.dd G 'at' hh:mm:ss z",
32-
"EEE, MMM d, ''yy",
33-
"h:mm a",
34-
"H:mm:ss:SSS",
35-
"K:mm a,z",
36-
"yyyy.MMMMM.dd GGG hh:mm aaa")
37-
val dateBox = new ComboBox(patterns) { makeEditable() }
28+
contents += new ComboBox(List(1, 2, 3, 4))
29+
30+
val patterns = List(
31+
"dd MMMMM yyyy",
32+
"dd.MM.yy",
33+
"MM/dd/yy",
34+
"yyyy.MM.dd G 'at' hh:mm:ss z",
35+
"EEE, MMM d, ''yy",
36+
"h:mm a",
37+
"H:mm:ss:SSS",
38+
"K:mm a,z",
39+
"yyyy.MMMMM.dd GGG hh:mm aaa"
40+
)
41+
42+
val dateBox = new ComboBox(patterns) {
43+
makeEditable()
44+
}
45+
3846
contents += dateBox
39-
val field = new TextField(20) { editable = false }
47+
val field = new TextField(20) {
48+
editable = false
49+
}
50+
4051
contents += field
4152

4253
reactions += {
4354
case SelectionChanged(`dateBox`) => reformat()
4455
}
56+
4557
listenTo(dateBox.selection)
4658

4759
def reformat() {
@@ -60,22 +72,24 @@ object ComboBoxes extends SimpleSwingApplication {
6072

6173

6274
val icons = try {
63-
List(new ImageIcon(resourceFromClassloader("images/margarita1.jpg")),
64-
new ImageIcon(resourceFromClassloader("images/margarita2.jpg")),
65-
new ImageIcon(resourceFromClassloader("images/rose.jpg")),
66-
new ImageIcon(resourceFromClassloader("images/banana.jpg")))
75+
List(
76+
new ImageIcon(resourceFromClassloader("images/margarita1.jpg")),
77+
new ImageIcon(resourceFromClassloader("images/margarita2.jpg")),
78+
new ImageIcon(resourceFromClassloader("images/rose.jpg")),
79+
new ImageIcon(resourceFromClassloader("images/banana.jpg"))
80+
)
6781
} catch {
68-
case _ =>
82+
case _: Exception =>
6983
println("Couldn't load images for combo box")
7084
List(Swing.EmptyIcon)
7185
}
7286

7387
val iconBox = new ComboBox(icons) {
7488
renderer = new ListView.AbstractRenderer[Icon, Label](new Label) {
7589
def configure(list: ListView[_], isSelected: Boolean, focused: Boolean, icon: Icon, index: Int) {
76-
component.icon = icon
90+
component.icon = icon
7791
component.xAlignment = Alignment.Center
78-
if(isSelected) {
92+
if (isSelected) {
7993
component.border = Swing.LineBorder(list.selectionBackground, 3)
8094
} else {
8195
component.border = Swing.EmptyBorder(3)
@@ -88,7 +102,8 @@ object ComboBoxes extends SimpleSwingApplication {
88102

89103
def top = new MainFrame {
90104
title = "ComboBoxes Demo"
91-
contents = ui
105+
contents = ui
92106
}
107+
93108
}
94109

examples/src/main/scala/scala/swing/examples/CountButton.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object CountButton extends SimpleSwingApplication {
3131
reactions += {
3232
case ButtonClicked(b) =>
3333
nclicks += 1
34-
label.text = "Number of button clicks: "+nclicks
34+
label.text = "Number of button clicks: " + nclicks
3535
}
3636
}
3737
}

0 commit comments

Comments
 (0)