Skip to content

Commit 4ae0185

Browse files
author
Allan Jacobs
committed
Use javax.swing.Component constants when assigning to xLayoutAlignment.
1 parent 943ef11 commit 4ae0185

File tree

6 files changed

+9
-15
lines changed

6 files changed

+9
-15
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ class MyFrame extends Frame {
246246
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS))
247247
contentPane.add(Box.createVerticalGlue()) // takes all extra space
248248
contentPane.add(button.peer)
249-
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT) //horizontally centered
250-
button.xLayoutAlignment = 0.50 // Center
249+
button.xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
251250
contentPane.add(Box.createVerticalStrut(5)) //spacer
252251
//
253252
listenTo(button)

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,13 @@ class ListDialog(frame: Frame, locationComp: Component,
7474
}
7575
selection.intervalMode = ListView.IntervalMode.SingleInterval
7676
}
77-
// Setting the selection mode of the peer does not have an effect.
7877
list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
7978
val lSelect = list.selection
8079
defaultButton = setButton
8180
//
8281
val listScroller = new ScrollPane(list) {
8382
preferredSize = new Dimension(250, 80)
84-
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
85-
xLayoutAlignment = 0.0 // Left
83+
xLayoutAlignment = java.awt.Component.LEFT_ALIGNMENT
8684
}
8785
//
8886
//Create a container so that we can add a title around
@@ -117,9 +115,6 @@ class ListDialog(frame: Frame, locationComp: Component,
117115
listenTo(cancelButton)
118116
listenTo(list.mouse.clicks)
119117
// listenTo(list.selection)
120-
//Getting the selections out of the ListView is problematic. I can't figure out a way to get
121-
//it to work. There are no demos available that use ListViews and actually consume the choices
122-
//made with the list. Maybe it is a broken component?
123118
reactions += {
124119
case ButtonClicked(`setButton`) =>
125120
setValue(list.listData(list.selection.leadIndex))

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ class ListDialogRunner(frame: Frame) extends BoxPanel(Orientation.NoOrientation)
5050

5151
//Create the labels.
5252
val intro = new Label("The chosen name:") {
53-
xLayoutAlignment = 0.50 // Center
53+
xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
5454
}
5555
val nameLabel = new Label(names(1)) {
5656
//Use a wacky font if it exists. If not, this falls
5757
//back to a font we know exists.
5858
font = getAFont()
59-
xLayoutAlignment = 0.50 // Center
59+
xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
6060
}
6161
intro.peer.setLabelFor(nameLabel.peer)
6262

6363
//Create the button.
6464
val button = new Button("Pick a new name...") {
65-
xLayoutAlignment = 0.50 // Center
65+
xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
6666
}
6767

6868
contents += intro

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class SliderDemo(window: Window) extends BoxPanel(Orientation.Vertical) with Act
6262

6363
val sliderLabel = new Label("Frames Per Second") {
6464
horizontalAlignment = Alignment.Center
65-
xLayoutAlignment = 0.50 // Center
65+
xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
6666
}
6767

6868
val framesPerSecond = new Slider {
@@ -81,7 +81,7 @@ class SliderDemo(window: Window) extends BoxPanel(Orientation.Vertical) with Act
8181

8282
val picture = new Label() {
8383
horizontalAlignment = Alignment.Center
84-
xLayoutAlignment = 0.50 // Center
84+
xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
8585
Swing.Lowered
8686
border = Swing.CompoundBorder(
8787
Swing.BeveledBorder(Swing.Lowered), Swing.EmptyBorder(10, 10, 10, 10))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class SliderDemo2(window: Window) extends BorderPanel with ActionListener {
8181

8282
val picture = new Label() {
8383
horizontalAlignment = Alignment.Center
84-
xLayoutAlignment = 0.50 // Center
84+
xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
8585
Swing.Lowered
8686
border = Swing.CompoundBorder(
8787
Swing.BeveledBorder(Swing.Lowered), Swing.EmptyBorder(10, 10, 10, 10))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class TablePrintDemo extends BoxPanel(Orientation.Vertical) {
6565
//Add a print button.
6666
val printButton = new Button("Print") {
6767
// peer.setAlignmentX(0.5f)
68-
xLayoutAlignment = 0.50 // Center
68+
xLayoutAlignment = java.awt.Component.CENTER_ALIGNMENT
6969
}
7070

7171
//Add the scroll pane to this panel.

0 commit comments

Comments
 (0)