Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more code cleanup in tutorials #3

Closed
wants to merge 1 commit into from
Closed

Some more code cleanup in tutorials #3

wants to merge 1 commit into from

Conversation

andy1138
Copy link

@andy1138 andy1138 commented Oct 1, 2014

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and haven't broken anything

The two I had problems with where FormattedTextFieldDemo, FrameDemo2. I think they both have functions missing from scala-swing. What we could do is move them into a issue saying 'functions x needed' or if easier just create a separate pull request for them (assuming you can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )

@jacobsallan
Copy link
Owner

The merge should be pushed into https://github.com/jacobsallan/scala-swing branch swingtut now. The demos that use createImageIcon have already been altered, so most of the merge was easy. I also changed the scaladoc so that the urls are enclosed in double-brackets. One thing you caught this time that is not completely addressed is when xLayoutAlignment is set to a double instead of a constant from java.awt.Component.

I've checked in changes to the orientation of split panes. The orientation in scala-swing's SplitPane constructor is the orientation of the divider and is 90 degrees off from Java swing's. I've changed the tutorials so the visual display is correct.

There are some peer usages removed, too. But, I think I'm done with these. Any more is going to required either more scala-swing knowledge than I have or changes to scala-swing.

@jacobsallan jacobsallan closed this Oct 1, 2014
@jacobsallan
Copy link
Owner

The merge was not bad at all. Should the examples with peer's be moved
into another directory that won't be propagated to master?

Two of the demos with setLabelFor problems can be saved for release by
commenting out the offending lines. For instance, changing
label.peer.setLabelFor(passwordField.peer)
into
// label.setLabelFor(passwordField)

examples/tutorials/layout/FlowLayoutDemo.scala may never be fixed to go
without peers. The problem there is the validate and repaint. We will
need to make a decision. Should the use of peers be encouraged for
usages where scala-swing does not intend to provide a software interface?

$ find examples -type f -print -exec grep peer {} ;
examples/HelloWorld.scala
examples/CelsiusConverter.scala
examples/images/banana.jpg
examples/images/margarita1.jpg
examples/images/margarita2.jpg
examples/images/rose.jpg
examples/CelsiusConverter2.scala
examples/TableSelection.scala
examples/ColorChooserDemo.scala
examples/ListViewDemo.scala
examples/ButtonApp.scala
examples/UIDemo.scala
examples/CountButton.scala
examples/GridBagDemo.scala
examples/tutorials/components/SliderDemo.scala
examples/tutorials/components/ButtonHtmlDemo.scala
examples/tutorials/components/PasswordDemo.scala
label.peer.setLabelFor(passwordField.peer)
examples/tutorials/components/ListDialog.scala
frame.peer.getGraphicsConfiguration: GraphicsConfiguration) {
peer.setModal(true)
// Setting the selection mode of the peer does not have an effect.
list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
examples/tutorials/components/ScrollDemo2.scala
if (SwingUtilities.isRightMouseButton(e.peer)) {
drawingPane.peer.scrollRectToVisible(rect)
examples/tutorials/components/SimpleTableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TextSamplerDemo.scala
// Had to use the peer for this
purpose..........................................
ftf.peer.setValue(java.util.Calendar.getInstance().getTime())
// Had to reach into the peer for this...................
editorPane.peer.setPage(helpURL)
StyleConstants.setComponent(sButton, button.peer)
newline + "Its peer, JTextPane, is a subclass of JEditorPane that " +
examples/tutorials/components/SimpleTableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TopLevelDemo.scala
examples/tutorials/components/ComboBoxDemo.scala
examples/tutorials/components/TablePrintDemo.scala
table.peer.setFillsViewportHeight(true)
// peer.setAlignmentX(0.5f)
table.peer.print(javax.swing.JTable.PrintMode.FIT_WIDTH,
header, null)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/DocumentSizeFilter.scala
examples/tutorials/components/CustomComboBoxDemo.scala
peer.setMaximumRowCount(3)
examples/tutorials/components/BorderDemo.scala
examples/tutorials/components/TabbedPaneDemo.scala
panel.peer.setDoubleBuffered(false)
examples/tutorials/components/FileChooserDemo.scala
peer.setMargin(new Insets(5, 5, 5, 5))
examples/tutorials/components/MenuGlueDemo.scala
examples/tutorials/components/ListDemo.scala
// employeeName.peer.getDocument().addDocumentListener(hireListener);
examples/tutorials/components/SplitPaneDemo.scala
examples/tutorials/components/MenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/Rule.scala
examples/tutorials/components/ListDialogRunner.scala
intro.peer.setLabelFor(nameLabel.peer)
examples/tutorials/components/IntegerEditor.scala
examples/tutorials/components/ScrollDemo.scala
pictureScrollPane.peer.setViewportBorder(Swing.LineBorder(Color.black))
pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,
buttonCorner.peer)
pictureScrollPane.peer.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,
new Corner())
pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,
new Corner())
examples/tutorials/components/TumbleItem.scala
setContentPane(animator.peer)
imgs(loopslot).paintIcon(peer, g, off, 0);
examples/tutorials/components/SplitPaneDividerDemo.scala
examples/tutorials/components/ComboBoxDemo2.scala
examples/tutorials/components/IconDemoApp.scala
examples/tutorials/components/DialogDemo.scala
val dialog = new Dialog(frame,
frame.peer.getGraphicsConfiguration) {
dialog.peer.setLocationRelativeTo(frame.peer)
examples/tutorials/components/SplitPaneDemo2.scala
examples/tutorials/components/ColorChooserDemo.scala
examples/tutorials/components/ScrollablePicture.scala
peer.setAutoscrolls(true)
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
examples/tutorials/components/SliderDemo2.scala
javax.swing.SwingUtilities.updateComponentTreeUI(top.peer)
examples/tutorials/components/ButtonDemo.scala
examples/tutorials/components/LabelDemo.scala
examples/tutorials/components/MenuLookDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/HtmlDemo.scala
examples/tutorials/components/FrameDemo.scala
examples/tutorials/components/TableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/CheckboxDemo.scala
examples/tutorials/components/RadioButtonDemo.scala
examples/tutorials/components/SizeDisplayer.scala
icon.paintIcon(peer, g2d,
g2d.setColor(peer.getForeground())
val textRect: Rectangle2D = peer.getFont().getStringBounds(
val insets: Insets = peer.getInsets()
examples/tutorials/components/TableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.getSelectionModel().addListSelectionListener(new
RowListener())
table.peer.getColumnModel().getSelectionModel().
table.peer.getSelectionModel().getLeadSelectionIndex(),
table.peer.getColumnModel().getSelectionModel().
examples/tutorials/components/TextComponentDemo.scala
textPane.peer.setMargin(new Insets(5, 5, 5, 5))
val inputMap: InputMap = textPane.peer.getInputMap
miCut.peer.setAction(oldCutAction)
miCopy.peer.setAction(oldCopyAction)
miPaste.peer.setAction(oldPasteAction)
miSelectAll.peer.setAction(oldSelectAllAction)
miBold.peer.setAction(boldAction)
miItalic.peer.setAction(italicAction)
miUnderline.peer.setAction(underlineAction)
miFont12.peer.setAction(font12Action)
miFont14.peer.setAction(font14Action)
miFont18.peer.setAction(font18Action)
miFontSerif.peer.setAction(fontSerifAction)
miFontSansSerif.peer.setAction(fontSansSerifAction)
miFgRed.peer.setAction(fgRedAction)
miFgGreen.peer.setAction(fgGreenAction)
miFgBlue.peer.setAction(fgBlueAction)
miFgBlack.peer.setAction(fgBlackAction)
for (a <- textComponent.peer.getActions()) {
peer.putValue(javax.swing.Action.NAME,
undo.getUndoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Undo")
peer.putValue(javax.swing.Action.NAME,
undo.getRedoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Redo")
val caretCoords: Rectangle = textPane.peer.modelToView(dot)
examples/tutorials/components/Corner.scala
examples/tutorials/components/TextDemo.scala
textArea.caret.position = textArea.peer.getDocument().getLength()
examples/tutorials/components/PopupMenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/FormattedTextFieldDemo.scala
amountLabel.peer.setLabelFor(amountField.peer)
rateLabel.peer.setLabelFor(rateField.peer)
// numPeriodsLabel.peer.setLabelFor(numPeriodsField.peer)
paymentLabel.peer.setLabelFor(paymentField.peer)
examples/tutorials/components/MissingIcon.scala
examples/tutorials/components/FrameDemo2.scala
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
// frame.peer.setUndecorated(true);
box.add(label1.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb1.peer)
box.add(rb2.peer)
box.add(rb3.peer)
box.add(Swing.VStrut(15).peer) // spacer
box.add(label2.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb4.peer)
box.add(rb5.peer)
box.add(rb6.peer)
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
pane.peer
//Undecorated windows are not supported in scala swing. Go to the peer.
val contentPane: java.awt.Container = peer.getContentPane()
contentPane.add(button.peer)
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT)
//horizontally centered
val contentPane = peer.getContentPane()
examples/tutorials/components/TableFTFEditDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.setDefaultEditor(Class.forName("java.lang.Integer"),
val numCols = table.peer.getColumnCount()
examples/tutorials/layout/DiagonalLayout.scala
examples/tutorials/layout/GridLayoutDemo.scala
compsToExperiment.peer.getLayout().layoutContainer(compsToExperiment.peer)
examples/tutorials/layout/BoxLayoutDemo2.scala
examples/tutorials/layout/BoxLayoutDemo.scala
examples/tutorials/layout/BLDComponent.scala
examples/tutorials/layout/BoxAlignmentDemo.scala
examples/tutorials/layout/FlowLayoutDemo.scala
compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)
compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)
compsToExperiment.peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
compsToExperiment.peer.validate()
compsToExperiment.peer.repaint()
examples/tutorials/layout/GridBagLayoutDemo.scala
examples/tutorials/layout/CustomLayoutDemo.scala
override lazy val peer: javax.swing.JPanel =
private def layoutManager = peer.getLayout.asInstanceOf[DiagonalLayout]
examples/tutorials/layout/BorderLayoutDemo.scala
peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
examples/tutorials/concurrency/Flipper.scala
examples/tutorials/events/ListSelectionDemo.scala
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/events/Beeper.scala
examples/tutorials/misc/FocusConceptsDemo.scala
examples/tutorials/misc/ActionDemo.scala
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
left button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
middle button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
right button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
examples/Dialogs.scala
examples/SimpleApplet.scala
examples/LinePainting.scala
examples/ComboBoxes.scala
examples/LabelTest.scala
examples/PopupDemo.scala
examples/SwingApp.scala

On 10/01/2014 08:12 AM, Andy Hicks wrote:

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and haven't
broken anything

The two I had problems with where FormattedTextFieldDemo, FrameDemo2.
I think they both have functions missing from scala-swing. What we
could do is move them into a issue saying 'functions x needed' or if
easier just create a separate pull request for them (assuming you
can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )


    You can merge this Pull Request by running

git pull https://github.com/andy1138/scala-swing tutorial

Or view, comment on, or merge it at:

#3

    Commit Summary


Reply to this email directly or view it on GitHub
#3.

@andy1138
Copy link
Author

andy1138 commented Oct 2, 2014

Thanks,
As you can tell, I'm also learning git, I forgot to do a pull from your
branch first :-( , hopefully I'll remember next time (If its not a clean
merge please 'remind me', as I've probably forgot )

As for using peer. - scala-swing should be a wrapper for java-swing and the
use of peer is really saying we have a method missing. ie the only way to
call this method is to use an internal variable.
What I think we should be is move the example to one side and maybe create
a github issue (ok, I haven't yet but should) with that item in 'ie missing
wrapper for Label.setLabelFor' and we'll come back to them after the we've
'ok'ed the others.
The wrappers should normally be the same name without the 'get' / 'set'
part so this would be used like ' label.labelFor = c ' or just
'label.labelFor' as the getter.

This may be more of a problem with things like repaint but I'm leaving that
as a TODO for now

I think the examples/tutorials should show nice ways that people should use
scala-swing, have them show how to use the internals (ie peer) sounds a
little wrong for now (but there may be a need for a blog/faq explaining how
to do this for people who really need to do something not part of
scala-swing)

On 1 October 2014 21:03, Allan Jacobs [email protected] wrote:

The merge was not bad at all. Should the examples with peer's be moved
into another directory that won't be propagated to master?

Two of the demos with setLabelFor problems can be saved for release by
commenting out the offending lines. For instance, changing
label.peer.setLabelFor(passwordField.peer)
into
// label.setLabelFor(passwordField)

examples/tutorials/layout/FlowLayoutDemo.scala may never be fixed to go
without peers. The problem there is the validate and repaint. We will
need to make a decision. Should the use of peers be encouraged for
usages where scala-swing does not intend to provide a software interface?

$ find examples -type f -print -exec grep peer {} ;
examples/HelloWorld.scala
examples/CelsiusConverter.scala
examples/images/banana.jpg
examples/images/margarita1.jpg
examples/images/margarita2.jpg
examples/images/rose.jpg
examples/CelsiusConverter2.scala
examples/TableSelection.scala
examples/ColorChooserDemo.scala
examples/ListViewDemo.scala
examples/ButtonApp.scala
examples/UIDemo.scala
examples/CountButton.scala
examples/GridBagDemo.scala
examples/tutorials/components/SliderDemo.scala
examples/tutorials/components/ButtonHtmlDemo.scala
examples/tutorials/components/PasswordDemo.scala
label.peer.setLabelFor(passwordField.peer)
examples/tutorials/components/ListDialog.scala
frame.peer.getGraphicsConfiguration: GraphicsConfiguration) {
peer.setModal(true)
// Setting the selection mode of the peer does not have an effect.
list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
examples/tutorials/components/ScrollDemo2.scala
if (SwingUtilities.isRightMouseButton(e.peer)) {
drawingPane.peer.scrollRectToVisible(rect)
examples/tutorials/components/SimpleTableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TextSamplerDemo.scala
// Had to use the peer for this
purpose..........................................
ftf.peer.setValue(java.util.Calendar.getInstance().getTime())
// Had to reach into the peer for this...................
editorPane.peer.setPage(helpURL)
StyleConstants.setComponent(sButton, button.peer)
newline + "Its peer, JTextPane, is a subclass of JEditorPane that " +
examples/tutorials/components/SimpleTableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TopLevelDemo.scala
examples/tutorials/components/ComboBoxDemo.scala
examples/tutorials/components/TablePrintDemo.scala
table.peer.setFillsViewportHeight(true)
// peer.setAlignmentX(0.5f)
table.peer.print(javax.swing.JTable.PrintMode.FIT_WIDTH,
header, null)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/DocumentSizeFilter.scala
examples/tutorials/components/CustomComboBoxDemo.scala
peer.setMaximumRowCount(3)
examples/tutorials/components/BorderDemo.scala
examples/tutorials/components/TabbedPaneDemo.scala
panel.peer.setDoubleBuffered(false)
examples/tutorials/components/FileChooserDemo.scala
peer.setMargin(new Insets(5, 5, 5, 5))
examples/tutorials/components/MenuGlueDemo.scala
examples/tutorials/components/ListDemo.scala
// employeeName.peer.getDocument().addDocumentListener(hireListener);
examples/tutorials/components/SplitPaneDemo.scala
examples/tutorials/components/MenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/Rule.scala
examples/tutorials/components/ListDialogRunner.scala
intro.peer.setLabelFor(nameLabel.peer)
examples/tutorials/components/IntegerEditor.scala
examples/tutorials/components/ScrollDemo.scala
pictureScrollPane.peer.setViewportBorder(Swing.LineBorder(Color.black))
pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,
buttonCorner.peer)
pictureScrollPane.peer.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,
new Corner())
pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,
new Corner())
examples/tutorials/components/TumbleItem.scala
setContentPane(animator.peer)
imgs(loopslot).paintIcon(peer, g, off, 0);
examples/tutorials/components/SplitPaneDividerDemo.scala
examples/tutorials/components/ComboBoxDemo2.scala
examples/tutorials/components/IconDemoApp.scala
examples/tutorials/components/DialogDemo.scala
val dialog = new Dialog(frame,
frame.peer.getGraphicsConfiguration) {
dialog.peer.setLocationRelativeTo(frame.peer)
examples/tutorials/components/SplitPaneDemo2.scala
examples/tutorials/components/ColorChooserDemo.scala
examples/tutorials/components/ScrollablePicture.scala
peer.setAutoscrolls(true)
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
examples/tutorials/components/SliderDemo2.scala
javax.swing.SwingUtilities.updateComponentTreeUI(top.peer)
examples/tutorials/components/ButtonDemo.scala
examples/tutorials/components/LabelDemo.scala
examples/tutorials/components/MenuLookDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/HtmlDemo.scala
examples/tutorials/components/FrameDemo.scala
examples/tutorials/components/TableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/CheckboxDemo.scala
examples/tutorials/components/RadioButtonDemo.scala
examples/tutorials/components/SizeDisplayer.scala
icon.paintIcon(peer, g2d,
g2d.setColor(peer.getForeground())
val textRect: Rectangle2D = peer.getFont().getStringBounds(
val insets: Insets = peer.getInsets()
examples/tutorials/components/TableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.getSelectionModel().addListSelectionListener(new
RowListener())
table.peer.getColumnModel().getSelectionModel().
table.peer.getSelectionModel().getLeadSelectionIndex(),
table.peer.getColumnModel().getSelectionModel().
examples/tutorials/components/TextComponentDemo.scala
textPane.peer.setMargin(new Insets(5, 5, 5, 5))
val inputMap: InputMap = textPane.peer.getInputMap
miCut.peer.setAction(oldCutAction)
miCopy.peer.setAction(oldCopyAction)
miPaste.peer.setAction(oldPasteAction)
miSelectAll.peer.setAction(oldSelectAllAction)
miBold.peer.setAction(boldAction)
miItalic.peer.setAction(italicAction)
miUnderline.peer.setAction(underlineAction)
miFont12.peer.setAction(font12Action)
miFont14.peer.setAction(font14Action)
miFont18.peer.setAction(font18Action)
miFontSerif.peer.setAction(fontSerifAction)
miFontSansSerif.peer.setAction(fontSansSerifAction)
miFgRed.peer.setAction(fgRedAction)
miFgGreen.peer.setAction(fgGreenAction)
miFgBlue.peer.setAction(fgBlueAction)
miFgBlack.peer.setAction(fgBlackAction)
for (a <- textComponent.peer.getActions()) {
peer.putValue(javax.swing.Action.NAME,
undo.getUndoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Undo")
peer.putValue(javax.swing.Action.NAME,
undo.getRedoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Redo")
val caretCoords: Rectangle = textPane.peer.modelToView(dot)
examples/tutorials/components/Corner.scala
examples/tutorials/components/TextDemo.scala
textArea.caret.position = textArea.peer.getDocument().getLength()
examples/tutorials/components/PopupMenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/FormattedTextFieldDemo.scala
amountLabel.peer.setLabelFor(amountField.peer)
rateLabel.peer.setLabelFor(rateField.peer)
// numPeriodsLabel.peer.setLabelFor(numPeriodsField.peer)
paymentLabel.peer.setLabelFor(paymentField.peer)
examples/tutorials/components/MissingIcon.scala
examples/tutorials/components/FrameDemo2.scala
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
// frame.peer.setUndecorated(true);
box.add(label1.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb1.peer)
box.add(rb2.peer)
box.add(rb3.peer)
box.add(Swing.VStrut(15).peer) // spacer
box.add(label2.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb4.peer)
box.add(rb5.peer)
box.add(rb6.peer)
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
pane.peer
//Undecorated windows are not supported in scala swing. Go to the peer.
val contentPane: java.awt.Container = peer.getContentPane()
contentPane.add(button.peer)
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT)
//horizontally centered
val contentPane = peer.getContentPane()
examples/tutorials/components/TableFTFEditDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.setDefaultEditor(Class.forName("java.lang.Integer"),
val numCols = table.peer.getColumnCount()
examples/tutorials/layout/DiagonalLayout.scala
examples/tutorials/layout/GridLayoutDemo.scala
compsToExperiment.peer.getLayout().layoutContainer(compsToExperiment.peer)
examples/tutorials/layout/BoxLayoutDemo2.scala
examples/tutorials/layout/BoxLayoutDemo.scala
examples/tutorials/layout/BLDComponent.scala
examples/tutorials/layout/BoxAlignmentDemo.scala
examples/tutorials/layout/FlowLayoutDemo.scala

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
compsToExperiment.peer.validate()
compsToExperiment.peer.repaint()
examples/tutorials/layout/GridBagLayoutDemo.scala
examples/tutorials/layout/CustomLayoutDemo.scala
override lazy val peer: javax.swing.JPanel =
private def layoutManager = peer.getLayout.asInstanceOf[DiagonalLayout]
examples/tutorials/layout/BorderLayoutDemo.scala
peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
examples/tutorials/concurrency/Flipper.scala
examples/tutorials/events/ListSelectionDemo.scala
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/events/Beeper.scala
examples/tutorials/misc/FocusConceptsDemo.scala
examples/tutorials/misc/ActionDemo.scala
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
left button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
middle button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
right button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
examples/Dialogs.scala
examples/SimpleApplet.scala
examples/LinePainting.scala
examples/ComboBoxes.scala
examples/LabelTest.scala
examples/PopupDemo.scala
examples/SwingApp.scala

On 10/01/2014 08:12 AM, Andy Hicks wrote:

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and haven't
broken anything

The two I had problems with where FormattedTextFieldDemo, FrameDemo2.
I think they both have functions missing from scala-swing. What we
could do is move them into a issue saying 'functions x needed' or if
easier just create a separate pull request for them (assuming you
can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )


You can merge this Pull Request by running

git pull https://github.com/andy1138/scala-swing tutorial

Or view, comment on, or merge it at:

#3

Commit Summary

  • Some code cleanup in tutorials

File Changes

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/ButtonDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-0 (45)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/ButtonHtmlDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-1 (6)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/CheckboxDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-2 (93)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/ColorChooserDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-3 (8)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/ComboBoxDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-4 (38)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/ComboBoxDemo2.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-5 (41)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/CustomComboBoxDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-6 (65)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/DialogDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-7
(497)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/DocumentSizeFilter.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-8 (8)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/FileChooserDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-9 (95)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/HtmlDemo.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-10 (9)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/IconDemoApp.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-11
(144)

  • M

examples/src/main/scala/scala/swing/examples/tutorials/components/MissingIcon.scala
https://github.com/jacobsallan/scala-swing/pull/3/files#diff-12 (9)

Patch Links:


Reply to this email directly or view it on GitHub
#3.


Reply to this email directly or view it on GitHub
#3 (comment).

@jacobsallan
Copy link
Owner

Let's fix the labelFor in a separate branch off of java7. The fix
should be trivial and localized to Label.scala.

Allan

On 10/02/2014 02:19 AM, Andy Hicks wrote:

Thanks,
As you can tell, I'm also learning git, I forgot to do a pull from your
branch first :-( , hopefully I'll remember next time (If its not a clean
merge please 'remind me', as I've probably forgot )

As for using peer. - scala-swing should be a wrapper for java-swing
and the
use of peer is really saying we have a method missing. ie the only way to
call this method is to use an internal variable.
What I think we should be is move the example to one side and maybe
create
a github issue (ok, I haven't yet but should) with that item in 'ie
missing
wrapper for Label.setLabelFor' and we'll come back to them after the
we've
'ok'ed the others.
The wrappers should normally be the same name without the 'get' / 'set'
part so this would be used like ' label.labelFor = c ' or just
'label.labelFor' as the getter.

This may be more of a problem with things like repaint but I'm leaving
that
as a TODO for now

I think the examples/tutorials should show nice ways that people
should use
scala-swing, have them show how to use the internals (ie peer) sounds a
little wrong for now (but there may be a need for a blog/faq
explaining how
to do this for people who really need to do something not part of
scala-swing)

On 1 October 2014 21:03, Allan Jacobs [email protected] wrote:

The merge was not bad at all. Should the examples with peer's be moved
into another directory that won't be propagated to master?

Two of the demos with setLabelFor problems can be saved for release by
commenting out the offending lines. For instance, changing
label.peer.setLabelFor(passwordField.peer)
into
// label.setLabelFor(passwordField)

examples/tutorials/layout/FlowLayoutDemo.scala may never be fixed to go
without peers. The problem there is the validate and repaint. We will
need to make a decision. Should the use of peers be encouraged for
usages where scala-swing does not intend to provide a software
interface?

$ find examples -type f -print -exec grep peer {} ;
examples/HelloWorld.scala
examples/CelsiusConverter.scala
examples/images/banana.jpg
examples/images/margarita1.jpg
examples/images/margarita2.jpg
examples/images/rose.jpg
examples/CelsiusConverter2.scala
examples/TableSelection.scala
examples/ColorChooserDemo.scala
examples/ListViewDemo.scala
examples/ButtonApp.scala
examples/UIDemo.scala
examples/CountButton.scala
examples/GridBagDemo.scala
examples/tutorials/components/SliderDemo.scala
examples/tutorials/components/ButtonHtmlDemo.scala
examples/tutorials/components/PasswordDemo.scala
label.peer.setLabelFor(passwordField.peer)
examples/tutorials/components/ListDialog.scala
frame.peer.getGraphicsConfiguration: GraphicsConfiguration) {
peer.setModal(true)
// Setting the selection mode of the peer does not have an effect.
list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
examples/tutorials/components/ScrollDemo2.scala
if (SwingUtilities.isRightMouseButton(e.peer)) {
drawingPane.peer.scrollRectToVisible(rect)
examples/tutorials/components/SimpleTableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TextSamplerDemo.scala
// Had to use the peer for this
purpose..........................................
ftf.peer.setValue(java.util.Calendar.getInstance().getTime())
// Had to reach into the peer for this...................
editorPane.peer.setPage(helpURL)
StyleConstants.setComponent(sButton, button.peer)
newline + "Its peer, JTextPane, is a subclass of JEditorPane that " +
examples/tutorials/components/SimpleTableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TopLevelDemo.scala
examples/tutorials/components/ComboBoxDemo.scala
examples/tutorials/components/TablePrintDemo.scala
table.peer.setFillsViewportHeight(true)
// peer.setAlignmentX(0.5f)
table.peer.print(javax.swing.JTable.PrintMode.FIT_WIDTH,
header, null)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/DocumentSizeFilter.scala
examples/tutorials/components/CustomComboBoxDemo.scala
peer.setMaximumRowCount(3)
examples/tutorials/components/BorderDemo.scala
examples/tutorials/components/TabbedPaneDemo.scala
panel.peer.setDoubleBuffered(false)
examples/tutorials/components/FileChooserDemo.scala
peer.setMargin(new Insets(5, 5, 5, 5))
examples/tutorials/components/MenuGlueDemo.scala
examples/tutorials/components/ListDemo.scala
// employeeName.peer.getDocument().addDocumentListener(hireListener);
examples/tutorials/components/SplitPaneDemo.scala
examples/tutorials/components/MenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/Rule.scala
examples/tutorials/components/ListDialogRunner.scala
intro.peer.setLabelFor(nameLabel.peer)
examples/tutorials/components/IntegerEditor.scala
examples/tutorials/components/ScrollDemo.scala
pictureScrollPane.peer.setViewportBorder(Swing.LineBorder(Color.black))

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,
buttonCorner.peer)

pictureScrollPane.peer.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,
new Corner())

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,
new Corner())
examples/tutorials/components/TumbleItem.scala
setContentPane(animator.peer)
imgs(loopslot).paintIcon(peer, g, off, 0);
examples/tutorials/components/SplitPaneDividerDemo.scala
examples/tutorials/components/ComboBoxDemo2.scala
examples/tutorials/components/IconDemoApp.scala
examples/tutorials/components/DialogDemo.scala
val dialog = new Dialog(frame,
frame.peer.getGraphicsConfiguration) {
dialog.peer.setLocationRelativeTo(frame.peer)
examples/tutorials/components/SplitPaneDemo2.scala
examples/tutorials/components/ColorChooserDemo.scala
examples/tutorials/components/ScrollablePicture.scala
peer.setAutoscrolls(true)
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
examples/tutorials/components/SliderDemo2.scala
javax.swing.SwingUtilities.updateComponentTreeUI(top.peer)
examples/tutorials/components/ButtonDemo.scala
examples/tutorials/components/LabelDemo.scala
examples/tutorials/components/MenuLookDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/HtmlDemo.scala
examples/tutorials/components/FrameDemo.scala
examples/tutorials/components/TableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/CheckboxDemo.scala
examples/tutorials/components/RadioButtonDemo.scala
examples/tutorials/components/SizeDisplayer.scala
icon.paintIcon(peer, g2d,
g2d.setColor(peer.getForeground())
val textRect: Rectangle2D = peer.getFont().getStringBounds(
val insets: Insets = peer.getInsets()
examples/tutorials/components/TableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.getSelectionModel().addListSelectionListener(new
RowListener())
table.peer.getColumnModel().getSelectionModel().
table.peer.getSelectionModel().getLeadSelectionIndex(),
table.peer.getColumnModel().getSelectionModel().
examples/tutorials/components/TextComponentDemo.scala
textPane.peer.setMargin(new Insets(5, 5, 5, 5))
val inputMap: InputMap = textPane.peer.getInputMap
miCut.peer.setAction(oldCutAction)
miCopy.peer.setAction(oldCopyAction)
miPaste.peer.setAction(oldPasteAction)
miSelectAll.peer.setAction(oldSelectAllAction)
miBold.peer.setAction(boldAction)
miItalic.peer.setAction(italicAction)
miUnderline.peer.setAction(underlineAction)
miFont12.peer.setAction(font12Action)
miFont14.peer.setAction(font14Action)
miFont18.peer.setAction(font18Action)
miFontSerif.peer.setAction(fontSerifAction)
miFontSansSerif.peer.setAction(fontSansSerifAction)
miFgRed.peer.setAction(fgRedAction)
miFgGreen.peer.setAction(fgGreenAction)
miFgBlue.peer.setAction(fgBlueAction)
miFgBlack.peer.setAction(fgBlackAction)
for (a <- textComponent.peer.getActions()) {
peer.putValue(javax.swing.Action.NAME,
undo.getUndoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Undo")
peer.putValue(javax.swing.Action.NAME,
undo.getRedoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Redo")
val caretCoords: Rectangle = textPane.peer.modelToView(dot)
examples/tutorials/components/Corner.scala
examples/tutorials/components/TextDemo.scala
textArea.caret.position = textArea.peer.getDocument().getLength()
examples/tutorials/components/PopupMenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/FormattedTextFieldDemo.scala
amountLabel.peer.setLabelFor(amountField.peer)
rateLabel.peer.setLabelFor(rateField.peer)
// numPeriodsLabel.peer.setLabelFor(numPeriodsField.peer)
paymentLabel.peer.setLabelFor(paymentField.peer)
examples/tutorials/components/MissingIcon.scala
examples/tutorials/components/FrameDemo2.scala
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
// frame.peer.setUndecorated(true);
box.add(label1.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb1.peer)
box.add(rb2.peer)
box.add(rb3.peer)
box.add(Swing.VStrut(15).peer) // spacer
box.add(label2.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb4.peer)
box.add(rb5.peer)
box.add(rb6.peer)
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
pane.peer
//Undecorated windows are not supported in scala swing. Go to the peer.
val contentPane: java.awt.Container = peer.getContentPane()
contentPane.add(button.peer)
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT)
//horizontally centered
val contentPane = peer.getContentPane()
examples/tutorials/components/TableFTFEditDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.setDefaultEditor(Class.forName("java.lang.Integer"),
val numCols = table.peer.getColumnCount()
examples/tutorials/layout/DiagonalLayout.scala
examples/tutorials/layout/GridLayoutDemo.scala

compsToExperiment.peer.getLayout().layoutContainer(compsToExperiment.peer)
examples/tutorials/layout/BoxLayoutDemo2.scala
examples/tutorials/layout/BoxLayoutDemo.scala
examples/tutorials/layout/BLDComponent.scala
examples/tutorials/layout/BoxAlignmentDemo.scala
examples/tutorials/layout/FlowLayoutDemo.scala

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
compsToExperiment.peer.validate()
compsToExperiment.peer.repaint()
examples/tutorials/layout/GridBagLayoutDemo.scala
examples/tutorials/layout/CustomLayoutDemo.scala
override lazy val peer: javax.swing.JPanel =
private def layoutManager = peer.getLayout.asInstanceOf[DiagonalLayout]
examples/tutorials/layout/BorderLayoutDemo.scala
peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
examples/tutorials/concurrency/Flipper.scala
examples/tutorials/events/ListSelectionDemo.scala
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/events/Beeper.scala
examples/tutorials/misc/FocusConceptsDemo.scala
examples/tutorials/misc/ActionDemo.scala
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
left button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
middle button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
right button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
examples/Dialogs.scala
examples/SimpleApplet.scala
examples/LinePainting.scala
examples/ComboBoxes.scala
examples/LabelTest.scala
examples/PopupDemo.scala
examples/SwingApp.scala

On 10/01/2014 08:12 AM, Andy Hicks wrote:

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and haven't
broken anything

The two I had problems with where FormattedTextFieldDemo, FrameDemo2.
I think they both have functions missing from scala-swing. What we
could do is move them into a issue saying 'functions x needed' or if
easier just create a separate pull request for them (assuming you
can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )


You can merge this Pull Request by running

git pull https://github.com/andy1138/scala-swing tutorial

Or view, comment on, or merge it at:

#3

Commit Summary

  • Some code cleanup in tutorials

File Changes

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-0 (45)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-1 (6)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-2 (93)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-3 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-4 (38)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-5 (41)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-6 (65)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-7
(497)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-8 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-9 (95)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-10 (9)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-11
(144)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-12 (9)

Patch Links:


Reply to this email directly or view it on GitHub
#3.


Reply to this email directly or view it on GitHub

#3 (comment).


Reply to this email directly or view it on GitHub
#3 (comment).

@andy1138
Copy link
Author

andy1138 commented Oct 3, 2014

Doing a separate branch and pull request for the labelFor (and other
missing scala-swing apis) sounds like a good idea. And I can merge it in.

On 2 October 2014 21:04, Allan Jacobs [email protected] wrote:

Let's fix the labelFor in a separate branch off of java7. The fix
should be trivial and localized to Label.scala.

Allan

On 10/02/2014 02:19 AM, Andy Hicks wrote:

Thanks,
As you can tell, I'm also learning git, I forgot to do a pull from your
branch first :-( , hopefully I'll remember next time (If its not a clean
merge please 'remind me', as I've probably forgot )

As for using peer. - scala-swing should be a wrapper for java-swing
and the
use of peer is really saying we have a method missing. ie the only way to
call this method is to use an internal variable.
What I think we should be is move the example to one side and maybe
create
a github issue (ok, I haven't yet but should) with that item in 'ie
missing
wrapper for Label.setLabelFor' and we'll come back to them after the
we've
'ok'ed the others.
The wrappers should normally be the same name without the 'get' / 'set'
part so this would be used like ' label.labelFor = c ' or just
'label.labelFor' as the getter.

This may be more of a problem with things like repaint but I'm leaving
that
as a TODO for now

I think the examples/tutorials should show nice ways that people
should use
scala-swing, have them show how to use the internals (ie peer) sounds a
little wrong for now (but there may be a need for a blog/faq
explaining how
to do this for people who really need to do something not part of
scala-swing)

On 1 October 2014 21:03, Allan Jacobs [email protected] wrote:

The merge was not bad at all. Should the examples with peer's be moved
into another directory that won't be propagated to master?

Two of the demos with setLabelFor problems can be saved for release by
commenting out the offending lines. For instance, changing
label.peer.setLabelFor(passwordField.peer)
into
// label.setLabelFor(passwordField)

examples/tutorials/layout/FlowLayoutDemo.scala may never be fixed to go
without peers. The problem there is the validate and repaint. We will
need to make a decision. Should the use of peers be encouraged for
usages where scala-swing does not intend to provide a software
interface?

$ find examples -type f -print -exec grep peer {} ;
examples/HelloWorld.scala
examples/CelsiusConverter.scala
examples/images/banana.jpg
examples/images/margarita1.jpg
examples/images/margarita2.jpg
examples/images/rose.jpg
examples/CelsiusConverter2.scala
examples/TableSelection.scala
examples/ColorChooserDemo.scala
examples/ListViewDemo.scala
examples/ButtonApp.scala
examples/UIDemo.scala
examples/CountButton.scala
examples/GridBagDemo.scala
examples/tutorials/components/SliderDemo.scala
examples/tutorials/components/ButtonHtmlDemo.scala
examples/tutorials/components/PasswordDemo.scala
label.peer.setLabelFor(passwordField.peer)
examples/tutorials/components/ListDialog.scala
frame.peer.getGraphicsConfiguration: GraphicsConfiguration) {
peer.setModal(true)
// Setting the selection mode of the peer does not have an effect.
list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
examples/tutorials/components/ScrollDemo2.scala
if (SwingUtilities.isRightMouseButton(e.peer)) {
drawingPane.peer.scrollRectToVisible(rect)
examples/tutorials/components/SimpleTableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TextSamplerDemo.scala
// Had to use the peer for this
purpose..........................................
ftf.peer.setValue(java.util.Calendar.getInstance().getTime())
// Had to reach into the peer for this...................
editorPane.peer.setPage(helpURL)
StyleConstants.setComponent(sButton, button.peer)
newline + "Its peer, JTextPane, is a subclass of JEditorPane that " +
examples/tutorials/components/SimpleTableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TopLevelDemo.scala
examples/tutorials/components/ComboBoxDemo.scala
examples/tutorials/components/TablePrintDemo.scala
table.peer.setFillsViewportHeight(true)
// peer.setAlignmentX(0.5f)
table.peer.print(javax.swing.JTable.PrintMode.FIT_WIDTH,
header, null)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/DocumentSizeFilter.scala
examples/tutorials/components/CustomComboBoxDemo.scala
peer.setMaximumRowCount(3)
examples/tutorials/components/BorderDemo.scala
examples/tutorials/components/TabbedPaneDemo.scala
panel.peer.setDoubleBuffered(false)
examples/tutorials/components/FileChooserDemo.scala
peer.setMargin(new Insets(5, 5, 5, 5))
examples/tutorials/components/MenuGlueDemo.scala
examples/tutorials/components/ListDemo.scala
// employeeName.peer.getDocument().addDocumentListener(hireListener);
examples/tutorials/components/SplitPaneDemo.scala
examples/tutorials/components/MenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/Rule.scala
examples/tutorials/components/ListDialogRunner.scala
intro.peer.setLabelFor(nameLabel.peer)
examples/tutorials/components/IntegerEditor.scala
examples/tutorials/components/ScrollDemo.scala
pictureScrollPane.peer.setViewportBorder(Swing.LineBorder(Color.black))

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,

buttonCorner.peer)

pictureScrollPane.peer.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,

new Corner())

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,
new Corner())
examples/tutorials/components/TumbleItem.scala
setContentPane(animator.peer)
imgs(loopslot).paintIcon(peer, g, off, 0);
examples/tutorials/components/SplitPaneDividerDemo.scala
examples/tutorials/components/ComboBoxDemo2.scala
examples/tutorials/components/IconDemoApp.scala
examples/tutorials/components/DialogDemo.scala
val dialog = new Dialog(frame,
frame.peer.getGraphicsConfiguration) {
dialog.peer.setLocationRelativeTo(frame.peer)
examples/tutorials/components/SplitPaneDemo2.scala
examples/tutorials/components/ColorChooserDemo.scala
examples/tutorials/components/ScrollablePicture.scala
peer.setAutoscrolls(true)
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
examples/tutorials/components/SliderDemo2.scala
javax.swing.SwingUtilities.updateComponentTreeUI(top.peer)
examples/tutorials/components/ButtonDemo.scala
examples/tutorials/components/LabelDemo.scala
examples/tutorials/components/MenuLookDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/HtmlDemo.scala
examples/tutorials/components/FrameDemo.scala
examples/tutorials/components/TableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/CheckboxDemo.scala
examples/tutorials/components/RadioButtonDemo.scala
examples/tutorials/components/SizeDisplayer.scala
icon.paintIcon(peer, g2d,
g2d.setColor(peer.getForeground())
val textRect: Rectangle2D = peer.getFont().getStringBounds(
val insets: Insets = peer.getInsets()
examples/tutorials/components/TableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.getSelectionModel().addListSelectionListener(new
RowListener())
table.peer.getColumnModel().getSelectionModel().
table.peer.getSelectionModel().getLeadSelectionIndex(),
table.peer.getColumnModel().getSelectionModel().
examples/tutorials/components/TextComponentDemo.scala
textPane.peer.setMargin(new Insets(5, 5, 5, 5))
val inputMap: InputMap = textPane.peer.getInputMap
miCut.peer.setAction(oldCutAction)
miCopy.peer.setAction(oldCopyAction)
miPaste.peer.setAction(oldPasteAction)
miSelectAll.peer.setAction(oldSelectAllAction)
miBold.peer.setAction(boldAction)
miItalic.peer.setAction(italicAction)
miUnderline.peer.setAction(underlineAction)
miFont12.peer.setAction(font12Action)
miFont14.peer.setAction(font14Action)
miFont18.peer.setAction(font18Action)
miFontSerif.peer.setAction(fontSerifAction)
miFontSansSerif.peer.setAction(fontSansSerifAction)
miFgRed.peer.setAction(fgRedAction)
miFgGreen.peer.setAction(fgGreenAction)
miFgBlue.peer.setAction(fgBlueAction)
miFgBlack.peer.setAction(fgBlackAction)
for (a <- textComponent.peer.getActions()) {
peer.putValue(javax.swing.Action.NAME,
undo.getUndoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Undo")
peer.putValue(javax.swing.Action.NAME,
undo.getRedoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Redo")
val caretCoords: Rectangle = textPane.peer.modelToView(dot)
examples/tutorials/components/Corner.scala
examples/tutorials/components/TextDemo.scala
textArea.caret.position = textArea.peer.getDocument().getLength()
examples/tutorials/components/PopupMenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/FormattedTextFieldDemo.scala
amountLabel.peer.setLabelFor(amountField.peer)
rateLabel.peer.setLabelFor(rateField.peer)
// numPeriodsLabel.peer.setLabelFor(numPeriodsField.peer)
paymentLabel.peer.setLabelFor(paymentField.peer)
examples/tutorials/components/MissingIcon.scala
examples/tutorials/components/FrameDemo2.scala
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
// frame.peer.setUndecorated(true);
box.add(label1.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb1.peer)
box.add(rb2.peer)
box.add(rb3.peer)
box.add(Swing.VStrut(15).peer) // spacer
box.add(label2.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb4.peer)
box.add(rb5.peer)
box.add(rb6.peer)
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
pane.peer
//Undecorated windows are not supported in scala swing. Go to the peer.
val contentPane: java.awt.Container = peer.getContentPane()
contentPane.add(button.peer)
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT)
//horizontally centered
val contentPane = peer.getContentPane()
examples/tutorials/components/TableFTFEditDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.setDefaultEditor(Class.forName("java.lang.Integer"),
val numCols = table.peer.getColumnCount()
examples/tutorials/layout/DiagonalLayout.scala
examples/tutorials/layout/GridLayoutDemo.scala

compsToExperiment.peer.getLayout().layoutContainer(compsToExperiment.peer)

examples/tutorials/layout/BoxLayoutDemo2.scala
examples/tutorials/layout/BoxLayoutDemo.scala
examples/tutorials/layout/BLDComponent.scala
examples/tutorials/layout/BoxAlignmentDemo.scala
examples/tutorials/layout/FlowLayoutDemo.scala

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)

compsToExperiment.peer.validate()
compsToExperiment.peer.repaint()
examples/tutorials/layout/GridBagLayoutDemo.scala
examples/tutorials/layout/CustomLayoutDemo.scala
override lazy val peer: javax.swing.JPanel =
private def layoutManager = peer.getLayout.asInstanceOf[DiagonalLayout]
examples/tutorials/layout/BorderLayoutDemo.scala
peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
examples/tutorials/concurrency/Flipper.scala
examples/tutorials/events/ListSelectionDemo.scala
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/events/Beeper.scala
examples/tutorials/misc/FocusConceptsDemo.scala
examples/tutorials/misc/ActionDemo.scala
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
left button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
middle button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
right button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
examples/Dialogs.scala
examples/SimpleApplet.scala
examples/LinePainting.scala
examples/ComboBoxes.scala
examples/LabelTest.scala
examples/PopupDemo.scala
examples/SwingApp.scala

On 10/01/2014 08:12 AM, Andy Hicks wrote:

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and haven't
broken anything

The two I had problems with where FormattedTextFieldDemo, FrameDemo2.
I think they both have functions missing from scala-swing. What we
could do is move them into a issue saying 'functions x needed' or if
easier just create a separate pull request for them (assuming you
can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )


You can merge this Pull Request by running

git pull https://github.com/andy1138/scala-swing tutorial

Or view, comment on, or merge it at:

#3

Commit Summary

  • Some code cleanup in tutorials

File Changes

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-0
(45)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-1 (6)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-2
(93)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-3 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-4
(38)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-5
(41)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-6
(65)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-7
(497)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-8 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-9
(95)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-10
(9)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-11
(144)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-12
(9)

Patch Links:


Reply to this email directly or view it on GitHub
#3.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub
<#3 (comment)
.


Reply to this email directly or view it on GitHub
#3 (comment).

@jacobsallan
Copy link
Owner

Hi Andy,

I went through the demos looking at all the uses of peer components.
There was
more of a scatter of issues than I expected. Most look like relatively
simple
additions to members of the scala.swing package that already exist.

Some of the demos require new components analogous to
javax.swing.Box
javax.swing.TextPane
javax.swing.ToolBar
Primitive versions of TextPane and ToolBar are in the swingtut branch
already.
Box is not implemented yet, as it's interface is likely to be very different
in Scala from the simple method call in Java.

The TextComponentDemo will require more work and require special
handling for
the actions in java.awt.DefaultEditorKit. Maybe there should be some
additions
to scala.swing.Swing instead of a DefaultEditorKit class.

The other issue raised by the demo for which a fix is non-trivial is the
method
call getAccessibleContext(). Accessibility cross-cuts all of the swing
apis,
so it is not something to rush into.

Enhancement #1

Add member functions to scala.swing.Action that get and set
short_description.

Enhancement #2

Add a new component Box to wrap javax.swing.Box. It should be possible
to add a
scala.swing.Component to a scala.swing.Box.

Enhancement #3

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent methods
boolean isDoubleBuffered()
and
void setDoubleBuffered(boolean aFlag)

Enhancement #4

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent methods
void setComponentOrientation(java.awt.ComponentOrientation o)
void applyComponentOrientation(java.awt.ComponentOrientation o)
and
java.awt.ComponentOrientation getComponentOrientation()

Enhancement scala#5

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent method
void scrollRectToVisible(java.awt.Rectangel r)

Enhancement scala#6

Add to scala.swing.UIElement replacements for the javax.swing.JComponent
methods
void setInputMap(int condition, javax.swing.InputMap map)
javax.swing.InputMap getInputMap(int condition)

Enhancement scala#7

In scala.swing.AbstractButton, scala.swing.TextComponent, and
scala.swing.MenuBar
provide replacement for
public void setMargin(java.awt.Insets insets)
In scala.swing.AbstractButton, scala.swing.TextComponenta provide a
wrapper for
public java.awt.Insets getMargin()

Enhancement scala#8

Add to scala.swing.TextComponent wrappers for
javax.swing.text.JTextComponent methods
javax.swing.text.Document getDocument()
and
void setDocument(javax.swing.text.Document doc)

Enhancement scala#9

In scala.swing.RichWindow, in the class Dialog
void setModal(boolean b)
or add a ModalDialog class to scala.swing.

Enhancement scala#10

In scala.swing.RichWindow for the class Frame, add an analogue to
java.awt.Component.getGraphicsConfiguration()
so that Dialog's can be constructed. Or change the constructor for
Dialog so that
the graphics configuration can be obtained from the first, Frame, argument.

Enhancement scala#11

In scala.swing.ListView, add an analogue for the JList methods
int getLayoutOrientation()
and
void setLayoutOrientation(int layoutOrientation)
Add constants for the orientations or reuse the constants from
javax.swing.JList: VERTICAL, VERTICAL_WRAP, HORIZONTAL_WRAP.

Enhancement scala#12

Add a mechanism to determine whether or not a mouse event is associated
with left, right, or middle mouse buttons. In Swing this is done with
boolean
javax.swing.SwingUtilities.isLeftMouseButton(java.awt.event.MouseEvent e)
boolean
javax.swing.SwingUtilities.isMiddleMouseButton(java.awt.event.MouseEvent e)
boolean
javax.swing.SwingUtilities.isRightMouseButton(java.awt.event.MouseEvent e)

Enhancement scala#13

In scala.swing.Label, add analogues for JLabel instance methods
java.awt.Component getLabelFor()
and
void setLabelFor(java.awt.Component c)

Enhancement scala#14

Add to scala.swing.ScrollPane a wrapper for the javax.swing.JScrollPane
methods
javax.swing.Border getViewportBorder()
and
void setViewportBorder(javax.swing.Border b)

Enhancement scala#15

Add to scala.swing.ScrollPane a wrapper for the javax.swing.JScrollPane
methods
java.awt.Component getCorner(String key)
and
void setCorner(String key, java.awt.Component corner)

Enhancement scala#16

In scala.swing.ComboBox add wrappers for
public int getMaximumRowCount()
and
public void setMaximumRowCount(int maxRowCount)

Enhancement scala#17

In scala.swing.Table add a wrapper for
int getColumnCount()

Enhancement scala#18

In scala.swing.Table add wrappers for
public boolean print(javax.swing.JTale.PrintMode printMode,
java.text.MessageFormat headerFormat,
java.text.MessageFormat footerFormat)
and
public boolean print(javax.swing.JTable.PrintMode printMode)

Enhancement scala#19

In scala.swing.Table wrappers for
javax.swing.SelectionModel getSelectionModel()
javax.swing.table.TableColumnModel getColumnModel()
void setSelectionModel(javax.swing.SelectionModel sm)
void setColumnModel(javax.swing.table.TableColumnModel cm)

On 10/03/2014 02:13 AM, Andy Hicks wrote:

Doing a separate branch and pull request for the labelFor (and other
missing scala-swing apis) sounds like a good idea. And I can merge it in.

On 2 October 2014 21:04, Allan Jacobs [email protected] wrote:

Let's fix the labelFor in a separate branch off of java7. The fix
should be trivial and localized to Label.scala.

Allan

On 10/02/2014 02:19 AM, Andy Hicks wrote:

Thanks,
As you can tell, I'm also learning git, I forgot to do a pull from
your
branch first :-( , hopefully I'll remember next time (If its not a
clean
merge please 'remind me', as I've probably forgot )

As for using peer. - scala-swing should be a wrapper for java-swing
and the
use of peer is really saying we have a method missing. ie the only
way to
call this method is to use an internal variable.
What I think we should be is move the example to one side and maybe
create
a github issue (ok, I haven't yet but should) with that item in 'ie
missing
wrapper for Label.setLabelFor' and we'll come back to them after the
we've
'ok'ed the others.
The wrappers should normally be the same name without the 'get' /
'set'
part so this would be used like ' label.labelFor = c ' or just
'label.labelFor' as the getter.

This may be more of a problem with things like repaint but I'm
leaving
that
as a TODO for now

I think the examples/tutorials should show nice ways that people
should use
scala-swing, have them show how to use the internals (ie peer)
sounds a
little wrong for now (but there may be a need for a blog/faq
explaining how
to do this for people who really need to do something not part of
scala-swing)

On 1 October 2014 21:03, Allan Jacobs [email protected]
wrote:

The merge was not bad at all. Should the examples with peer's be
moved
into another directory that won't be propagated to master?

Two of the demos with setLabelFor problems can be saved for
release by
commenting out the offending lines. For instance, changing
label.peer.setLabelFor(passwordField.peer)
into
// label.setLabelFor(passwordField)

examples/tutorials/layout/FlowLayoutDemo.scala may never be
fixed to go
without peers. The problem there is the validate and repaint. We
will
need to make a decision. Should the use of peers be encouraged for
usages where scala-swing does not intend to provide a software
interface?

$ find examples -type f -print -exec grep peer {} ;
examples/HelloWorld.scala
examples/CelsiusConverter.scala
examples/images/banana.jpg
examples/images/margarita1.jpg
examples/images/margarita2.jpg
examples/images/rose.jpg
examples/CelsiusConverter2.scala
examples/TableSelection.scala
examples/ColorChooserDemo.scala
examples/ListViewDemo.scala
examples/ButtonApp.scala
examples/UIDemo.scala
examples/CountButton.scala
examples/GridBagDemo.scala
examples/tutorials/components/SliderDemo.scala
examples/tutorials/components/ButtonHtmlDemo.scala
examples/tutorials/components/PasswordDemo.scala
label.peer.setLabelFor(passwordField.peer)
examples/tutorials/components/ListDialog.scala
frame.peer.getGraphicsConfiguration: GraphicsConfiguration) {
peer.setModal(true)
// Setting the selection mode of the peer does not have an effect.
list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
examples/tutorials/components/ScrollDemo2.scala
if (SwingUtilities.isRightMouseButton(e.peer)) {
drawingPane.peer.scrollRectToVisible(rect)
examples/tutorials/components/SimpleTableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TextSamplerDemo.scala
// Had to use the peer for this
purpose..........................................
ftf.peer.setValue(java.util.Calendar.getInstance().getTime())
// Had to reach into the peer for this...................
editorPane.peer.setPage(helpURL)
StyleConstants.setComponent(sButton, button.peer)
newline + "Its peer, JTextPane, is a subclass of JEditorPane
that " +
examples/tutorials/components/SimpleTableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TopLevelDemo.scala
examples/tutorials/components/ComboBoxDemo.scala
examples/tutorials/components/TablePrintDemo.scala
table.peer.setFillsViewportHeight(true)
// peer.setAlignmentX(0.5f)
table.peer.print(javax.swing.JTable.PrintMode.FIT_WIDTH,
header, null)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/DocumentSizeFilter.scala
examples/tutorials/components/CustomComboBoxDemo.scala
peer.setMaximumRowCount(3)
examples/tutorials/components/BorderDemo.scala
examples/tutorials/components/TabbedPaneDemo.scala
panel.peer.setDoubleBuffered(false)
examples/tutorials/components/FileChooserDemo.scala
peer.setMargin(new Insets(5, 5, 5, 5))
examples/tutorials/components/MenuGlueDemo.scala
examples/tutorials/components/ListDemo.scala
//
employeeName.peer.getDocument().addDocumentListener(hireListener);
examples/tutorials/components/SplitPaneDemo.scala
examples/tutorials/components/MenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/Rule.scala
examples/tutorials/components/ListDialogRunner.scala
intro.peer.setLabelFor(nameLabel.peer)
examples/tutorials/components/IntegerEditor.scala
examples/tutorials/components/ScrollDemo.scala

pictureScrollPane.peer.setViewportBorder(Swing.LineBorder(Color.black))

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,

buttonCorner.peer)

pictureScrollPane.peer.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,

new Corner())

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,

new Corner())
examples/tutorials/components/TumbleItem.scala
setContentPane(animator.peer)
imgs(loopslot).paintIcon(peer, g, off, 0);
examples/tutorials/components/SplitPaneDividerDemo.scala
examples/tutorials/components/ComboBoxDemo2.scala
examples/tutorials/components/IconDemoApp.scala
examples/tutorials/components/DialogDemo.scala
val dialog = new Dialog(frame,
frame.peer.getGraphicsConfiguration) {
dialog.peer.setLocationRelativeTo(frame.peer)
examples/tutorials/components/SplitPaneDemo2.scala
examples/tutorials/components/ColorChooserDemo.scala
examples/tutorials/components/ScrollablePicture.scala
peer.setAutoscrolls(true)
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
examples/tutorials/components/SliderDemo2.scala
javax.swing.SwingUtilities.updateComponentTreeUI(top.peer)
examples/tutorials/components/ButtonDemo.scala
examples/tutorials/components/LabelDemo.scala
examples/tutorials/components/MenuLookDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/HtmlDemo.scala
examples/tutorials/components/FrameDemo.scala
examples/tutorials/components/TableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/CheckboxDemo.scala
examples/tutorials/components/RadioButtonDemo.scala
examples/tutorials/components/SizeDisplayer.scala
icon.paintIcon(peer, g2d,
g2d.setColor(peer.getForeground())
val textRect: Rectangle2D = peer.getFont().getStringBounds(
val insets: Insets = peer.getInsets()
examples/tutorials/components/TableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.getSelectionModel().addListSelectionListener(new
RowListener())
table.peer.getColumnModel().getSelectionModel().
table.peer.getSelectionModel().getLeadSelectionIndex(),
table.peer.getColumnModel().getSelectionModel().
examples/tutorials/components/TextComponentDemo.scala
textPane.peer.setMargin(new Insets(5, 5, 5, 5))
val inputMap: InputMap = textPane.peer.getInputMap
miCut.peer.setAction(oldCutAction)
miCopy.peer.setAction(oldCopyAction)
miPaste.peer.setAction(oldPasteAction)
miSelectAll.peer.setAction(oldSelectAllAction)
miBold.peer.setAction(boldAction)
miItalic.peer.setAction(italicAction)
miUnderline.peer.setAction(underlineAction)
miFont12.peer.setAction(font12Action)
miFont14.peer.setAction(font14Action)
miFont18.peer.setAction(font18Action)
miFontSerif.peer.setAction(fontSerifAction)
miFontSansSerif.peer.setAction(fontSansSerifAction)
miFgRed.peer.setAction(fgRedAction)
miFgGreen.peer.setAction(fgGreenAction)
miFgBlue.peer.setAction(fgBlueAction)
miFgBlack.peer.setAction(fgBlackAction)
for (a <- textComponent.peer.getActions()) {
peer.putValue(javax.swing.Action.NAME,
undo.getUndoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Undo")
peer.putValue(javax.swing.Action.NAME,
undo.getRedoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Redo")
val caretCoords: Rectangle = textPane.peer.modelToView(dot)
examples/tutorials/components/Corner.scala
examples/tutorials/components/TextDemo.scala
textArea.caret.position = textArea.peer.getDocument().getLength()
examples/tutorials/components/PopupMenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/FormattedTextFieldDemo.scala
amountLabel.peer.setLabelFor(amountField.peer)
rateLabel.peer.setLabelFor(rateField.peer)
// numPeriodsLabel.peer.setLabelFor(numPeriodsField.peer)
paymentLabel.peer.setLabelFor(paymentField.peer)
examples/tutorials/components/MissingIcon.scala
examples/tutorials/components/FrameDemo2.scala
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
// frame.peer.setUndecorated(true);
box.add(label1.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb1.peer)
box.add(rb2.peer)
box.add(rb3.peer)
box.add(Swing.VStrut(15).peer) // spacer
box.add(label2.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb4.peer)
box.add(rb5.peer)
box.add(rb6.peer)
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
pane.peer
//Undecorated windows are not supported in scala swing. Go to
the peer.
val contentPane: java.awt.Container = peer.getContentPane()
contentPane.add(button.peer)
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT)
//horizontally centered
val contentPane = peer.getContentPane()
examples/tutorials/components/TableFTFEditDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.setDefaultEditor(Class.forName("java.lang.Integer"),
val numCols = table.peer.getColumnCount()
examples/tutorials/layout/DiagonalLayout.scala
examples/tutorials/layout/GridLayoutDemo.scala

compsToExperiment.peer.getLayout().layoutContainer(compsToExperiment.peer)

examples/tutorials/layout/BoxLayoutDemo2.scala
examples/tutorials/layout/BoxLayoutDemo.scala
examples/tutorials/layout/BLDComponent.scala
examples/tutorials/layout/BoxAlignmentDemo.scala
examples/tutorials/layout/FlowLayoutDemo.scala

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)

compsToExperiment.peer.validate()
compsToExperiment.peer.repaint()
examples/tutorials/layout/GridBagLayoutDemo.scala
examples/tutorials/layout/CustomLayoutDemo.scala
override lazy val peer: javax.swing.JPanel =
private def layoutManager =
peer.getLayout.asInstanceOf[DiagonalLayout]
examples/tutorials/layout/BorderLayoutDemo.scala
peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
examples/tutorials/concurrency/Flipper.scala
examples/tutorials/events/ListSelectionDemo.scala
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/events/Beeper.scala
examples/tutorials/misc/FocusConceptsDemo.scala
examples/tutorials/misc/ActionDemo.scala
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
left button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
middle button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
right button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
examples/Dialogs.scala
examples/SimpleApplet.scala
examples/LinePainting.scala
examples/ComboBoxes.scala
examples/LabelTest.scala
examples/PopupDemo.scala
examples/SwingApp.scala

On 10/01/2014 08:12 AM, Andy Hicks wrote:

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and haven't
broken anything

The two I had problems with where FormattedTextFieldDemo,
FrameDemo2.
I think they both have functions missing from scala-swing.
What we
could do is move them into a issue saying 'functions x needed'
or if
easier just create a separate pull request for them (assuming you
can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )


You can merge this Pull Request by running

git pull https://github.com/andy1138/scala-swing tutorial

Or view, comment on, or merge it at:

#3

Commit Summary

  • Some code cleanup in tutorials

File Changes

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-0
(45)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-1 (6)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-2
(93)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-3 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-4
(38)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-5
(41)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-6
(65)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-7
(497)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-8 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-9
(95)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-10
(9)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-11
(144)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-12
(9)

Patch Links:


Reply to this email directly or view it on GitHub
#3.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub

#3 (comment).


Reply to this email directly or view it on GitHub
#3 (comment).

@andy1138
Copy link
Author

andy1138 commented Oct 5, 2014

Hi

I've just done a pull request for the last of the tutorials that are not
using peers.

Thanks for the list of enhancements,
I think the best plan is to look at each of the places its using .peer and

  • if its a simple one line add to scala-swing then we create a separate
    branch and add it with the updated tutorial examples
  • if its a bit more complicated, then create a github issue about it and
    include the tutorial example there (attach as a github gist if we can't
    find anything better)

It may be possible to add Accessibility to Component either directly or as
a trait.

When you've removed the tutorials using .peer from the pull request then
I'll pull it into the main scala/scala-swing repo (assuming you're happy
with all the changes)

On 4 October 2014 06:21, Allan Jacobs [email protected] wrote:

Hi Andy,

I went through the demos looking at all the uses of peer components.
There was
more of a scatter of issues than I expected. Most look like relatively
simple
additions to members of the scala.swing package that already exist.

Some of the demos require new components analogous to
javax.swing.Box
javax.swing.TextPane
javax.swing.ToolBar
Primitive versions of TextPane and ToolBar are in the swingtut branch
already.
Box is not implemented yet, as it's interface is likely to be very
different
in Scala from the simple method call in Java.

The TextComponentDemo will require more work and require special
handling for
the actions in java.awt.DefaultEditorKit. Maybe there should be some
additions
to scala.swing.Swing instead of a DefaultEditorKit class.

The other issue raised by the demo for which a fix is non-trivial is the
method
call getAccessibleContext(). Accessibility cross-cuts all of the swing
apis,
so it is not something to rush into.

Enhancement #1

Add member functions to scala.swing.Action that get and set
short_description.

Enhancement #2

Add a new component Box to wrap javax.swing.Box. It should be possible
to add a
scala.swing.Component to a scala.swing.Box.

Enhancement #3

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent
methods
boolean isDoubleBuffered()
and
void setDoubleBuffered(boolean aFlag)

Enhancement #4

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent
methods
void setComponentOrientation(java.awt.ComponentOrientation o)
void applyComponentOrientation(java.awt.ComponentOrientation o)
and
java.awt.ComponentOrientation getComponentOrientation()

Enhancement scala#5

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent method
void scrollRectToVisible(java.awt.Rectangel r)

Enhancement scala#6

Add to scala.swing.UIElement replacements for the javax.swing.JComponent
methods
void setInputMap(int condition, javax.swing.InputMap map)
javax.swing.InputMap getInputMap(int condition)

Enhancement scala#7

In scala.swing.AbstractButton, scala.swing.TextComponent, and
scala.swing.MenuBar
provide replacement for
public void setMargin(java.awt.Insets insets)
In scala.swing.AbstractButton, scala.swing.TextComponenta provide a
wrapper for
public java.awt.Insets getMargin()

Enhancement scala#8

Add to scala.swing.TextComponent wrappers for
javax.swing.text.JTextComponent methods
javax.swing.text.Document getDocument()
and
void setDocument(javax.swing.text.Document doc)

Enhancement scala#9

In scala.swing.RichWindow, in the class Dialog
void setModal(boolean b)
or add a ModalDialog class to scala.swing.

Enhancement scala#10

In scala.swing.RichWindow for the class Frame, add an analogue to
java.awt.Component.getGraphicsConfiguration()
so that Dialog's can be constructed. Or change the constructor for
Dialog so that
the graphics configuration can be obtained from the first, Frame, argument.

Enhancement scala#11

In scala.swing.ListView, add an analogue for the JList methods
int getLayoutOrientation()
and
void setLayoutOrientation(int layoutOrientation)
Add constants for the orientations or reuse the constants from
javax.swing.JList: VERTICAL, VERTICAL_WRAP, HORIZONTAL_WRAP.

Enhancement scala#12

Add a mechanism to determine whether or not a mouse event is associated
with left, right, or middle mouse buttons. In Swing this is done with
boolean
javax.swing.SwingUtilities.isLeftMouseButton(java.awt.event.MouseEvent e)
boolean
javax.swing.SwingUtilities.isMiddleMouseButton(java.awt.event.MouseEvent e)
boolean
javax.swing.SwingUtilities.isRightMouseButton(java.awt.event.MouseEvent e)

Enhancement scala#13

In scala.swing.Label, add analogues for JLabel instance methods
java.awt.Component getLabelFor()
and
void setLabelFor(java.awt.Component c)

Enhancement scala#14

Add to scala.swing.ScrollPane a wrapper for the javax.swing.JScrollPane
methods
javax.swing.Border getViewportBorder()
and
void setViewportBorder(javax.swing.Border b)

Enhancement scala#15

Add to scala.swing.ScrollPane a wrapper for the javax.swing.JScrollPane
methods
java.awt.Component getCorner(String key)
and
void setCorner(String key, java.awt.Component corner)

Enhancement scala#16

In scala.swing.ComboBox add wrappers for
public int getMaximumRowCount()
and
public void setMaximumRowCount(int maxRowCount)

Enhancement scala#17

In scala.swing.Table add a wrapper for
int getColumnCount()

Enhancement scala#18

In scala.swing.Table add wrappers for
public boolean print(javax.swing.JTale.PrintMode printMode,
java.text.MessageFormat headerFormat,
java.text.MessageFormat footerFormat)
and
public boolean print(javax.swing.JTable.PrintMode printMode)

Enhancement scala#19

In scala.swing.Table wrappers for
javax.swing.SelectionModel getSelectionModel()
javax.swing.table.TableColumnModel getColumnModel()
void setSelectionModel(javax.swing.SelectionModel sm)
void setColumnModel(javax.swing.table.TableColumnModel cm)

On 10/03/2014 02:13 AM, Andy Hicks wrote:

Doing a separate branch and pull request for the labelFor (and other
missing scala-swing apis) sounds like a good idea. And I can merge it in.

On 2 October 2014 21:04, Allan Jacobs [email protected] wrote:

Let's fix the labelFor in a separate branch off of java7. The fix
should be trivial and localized to Label.scala.

Allan

On 10/02/2014 02:19 AM, Andy Hicks wrote:

Thanks,
As you can tell, I'm also learning git, I forgot to do a pull from
your
branch first :-( , hopefully I'll remember next time (If its not a
clean
merge please 'remind me', as I've probably forgot )

As for using peer. - scala-swing should be a wrapper for java-swing
and the
use of peer is really saying we have a method missing. ie the only
way to
call this method is to use an internal variable.
What I think we should be is move the example to one side and maybe
create
a github issue (ok, I haven't yet but should) with that item in 'ie
missing
wrapper for Label.setLabelFor' and we'll come back to them after the
we've
'ok'ed the others.
The wrappers should normally be the same name without the 'get' /
'set'
part so this would be used like ' label.labelFor = c ' or just
'label.labelFor' as the getter.

This may be more of a problem with things like repaint but I'm
leaving
that
as a TODO for now

I think the examples/tutorials should show nice ways that people
should use
scala-swing, have them show how to use the internals (ie peer)
sounds a
little wrong for now (but there may be a need for a blog/faq
explaining how
to do this for people who really need to do something not part of
scala-swing)

On 1 October 2014 21:03, Allan Jacobs [email protected]
wrote:

The merge was not bad at all. Should the examples with peer's be
moved
into another directory that won't be propagated to master?

Two of the demos with setLabelFor problems can be saved for
release by
commenting out the offending lines. For instance, changing
label.peer.setLabelFor(passwordField.peer)
into
// label.setLabelFor(passwordField)

examples/tutorials/layout/FlowLayoutDemo.scala may never be
fixed to go
without peers. The problem there is the validate and repaint. We
will
need to make a decision. Should the use of peers be encouraged for
usages where scala-swing does not intend to provide a software
interface?

$ find examples -type f -print -exec grep peer {} ;
examples/HelloWorld.scala
examples/CelsiusConverter.scala
examples/images/banana.jpg
examples/images/margarita1.jpg
examples/images/margarita2.jpg
examples/images/rose.jpg
examples/CelsiusConverter2.scala
examples/TableSelection.scala
examples/ColorChooserDemo.scala
examples/ListViewDemo.scala
examples/ButtonApp.scala
examples/UIDemo.scala
examples/CountButton.scala
examples/GridBagDemo.scala
examples/tutorials/components/SliderDemo.scala
examples/tutorials/components/ButtonHtmlDemo.scala
examples/tutorials/components/PasswordDemo.scala
label.peer.setLabelFor(passwordField.peer)
examples/tutorials/components/ListDialog.scala
frame.peer.getGraphicsConfiguration: GraphicsConfiguration) {
peer.setModal(true)
// Setting the selection mode of the peer does not have an effect.
list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
examples/tutorials/components/ScrollDemo2.scala
if (SwingUtilities.isRightMouseButton(e.peer)) {
drawingPane.peer.scrollRectToVisible(rect)
examples/tutorials/components/SimpleTableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TextSamplerDemo.scala
// Had to use the peer for this
purpose..........................................
ftf.peer.setValue(java.util.Calendar.getInstance().getTime())
// Had to reach into the peer for this...................
editorPane.peer.setPage(helpURL)
StyleConstants.setComponent(sButton, button.peer)
newline + "Its peer, JTextPane, is a subclass of JEditorPane
that " +
examples/tutorials/components/SimpleTableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TopLevelDemo.scala
examples/tutorials/components/ComboBoxDemo.scala
examples/tutorials/components/TablePrintDemo.scala
table.peer.setFillsViewportHeight(true)
// peer.setAlignmentX(0.5f)
table.peer.print(javax.swing.JTable.PrintMode.FIT_WIDTH,
header, null)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/DocumentSizeFilter.scala
examples/tutorials/components/CustomComboBoxDemo.scala
peer.setMaximumRowCount(3)
examples/tutorials/components/BorderDemo.scala
examples/tutorials/components/TabbedPaneDemo.scala
panel.peer.setDoubleBuffered(false)
examples/tutorials/components/FileChooserDemo.scala
peer.setMargin(new Insets(5, 5, 5, 5))
examples/tutorials/components/MenuGlueDemo.scala
examples/tutorials/components/ListDemo.scala
//
employeeName.peer.getDocument().addDocumentListener(hireListener);
examples/tutorials/components/SplitPaneDemo.scala
examples/tutorials/components/MenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/Rule.scala
examples/tutorials/components/ListDialogRunner.scala
intro.peer.setLabelFor(nameLabel.peer)
examples/tutorials/components/IntegerEditor.scala
examples/tutorials/components/ScrollDemo.scala

pictureScrollPane.peer.setViewportBorder(Swing.LineBorder(Color.black))

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,

buttonCorner.peer)

pictureScrollPane.peer.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,

new Corner())

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,

new Corner())
examples/tutorials/components/TumbleItem.scala
setContentPane(animator.peer)
imgs(loopslot).paintIcon(peer, g, off, 0);
examples/tutorials/components/SplitPaneDividerDemo.scala
examples/tutorials/components/ComboBoxDemo2.scala
examples/tutorials/components/IconDemoApp.scala
examples/tutorials/components/DialogDemo.scala
val dialog = new Dialog(frame,
frame.peer.getGraphicsConfiguration) {
dialog.peer.setLocationRelativeTo(frame.peer)
examples/tutorials/components/SplitPaneDemo2.scala
examples/tutorials/components/ColorChooserDemo.scala
examples/tutorials/components/ScrollablePicture.scala
peer.setAutoscrolls(true)
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
examples/tutorials/components/SliderDemo2.scala
javax.swing.SwingUtilities.updateComponentTreeUI(top.peer)
examples/tutorials/components/ButtonDemo.scala
examples/tutorials/components/LabelDemo.scala
examples/tutorials/components/MenuLookDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/HtmlDemo.scala
examples/tutorials/components/FrameDemo.scala
examples/tutorials/components/TableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/CheckboxDemo.scala
examples/tutorials/components/RadioButtonDemo.scala
examples/tutorials/components/SizeDisplayer.scala
icon.paintIcon(peer, g2d,
g2d.setColor(peer.getForeground())
val textRect: Rectangle2D = peer.getFont().getStringBounds(
val insets: Insets = peer.getInsets()
examples/tutorials/components/TableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.getSelectionModel().addListSelectionListener(new
RowListener())
table.peer.getColumnModel().getSelectionModel().
table.peer.getSelectionModel().getLeadSelectionIndex(),
table.peer.getColumnModel().getSelectionModel().
examples/tutorials/components/TextComponentDemo.scala
textPane.peer.setMargin(new Insets(5, 5, 5, 5))
val inputMap: InputMap = textPane.peer.getInputMap
miCut.peer.setAction(oldCutAction)
miCopy.peer.setAction(oldCopyAction)
miPaste.peer.setAction(oldPasteAction)
miSelectAll.peer.setAction(oldSelectAllAction)
miBold.peer.setAction(boldAction)
miItalic.peer.setAction(italicAction)
miUnderline.peer.setAction(underlineAction)
miFont12.peer.setAction(font12Action)
miFont14.peer.setAction(font14Action)
miFont18.peer.setAction(font18Action)
miFontSerif.peer.setAction(fontSerifAction)
miFontSansSerif.peer.setAction(fontSansSerifAction)
miFgRed.peer.setAction(fgRedAction)
miFgGreen.peer.setAction(fgGreenAction)
miFgBlue.peer.setAction(fgBlueAction)
miFgBlack.peer.setAction(fgBlackAction)
for (a <- textComponent.peer.getActions()) {
peer.putValue(javax.swing.Action.NAME,
undo.getUndoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Undo")
peer.putValue(javax.swing.Action.NAME,
undo.getRedoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Redo")
val caretCoords: Rectangle = textPane.peer.modelToView(dot)
examples/tutorials/components/Corner.scala
examples/tutorials/components/TextDemo.scala
textArea.caret.position = textArea.peer.getDocument().getLength()
examples/tutorials/components/PopupMenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/FormattedTextFieldDemo.scala
amountLabel.peer.setLabelFor(amountField.peer)
rateLabel.peer.setLabelFor(rateField.peer)
// numPeriodsLabel.peer.setLabelFor(numPeriodsField.peer)
paymentLabel.peer.setLabelFor(paymentField.peer)
examples/tutorials/components/MissingIcon.scala
examples/tutorials/components/FrameDemo2.scala
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
// frame.peer.setUndecorated(true);
box.add(label1.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb1.peer)
box.add(rb2.peer)
box.add(rb3.peer)
box.add(Swing.VStrut(15).peer) // spacer
box.add(label2.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb4.peer)
box.add(rb5.peer)
box.add(rb6.peer)
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
pane.peer
//Undecorated windows are not supported in scala swing. Go to
the peer.
val contentPane: java.awt.Container = peer.getContentPane()
contentPane.add(button.peer)
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT)
//horizontally centered
val contentPane = peer.getContentPane()
examples/tutorials/components/TableFTFEditDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.setDefaultEditor(Class.forName("java.lang.Integer"),
val numCols = table.peer.getColumnCount()
examples/tutorials/layout/DiagonalLayout.scala
examples/tutorials/layout/GridLayoutDemo.scala

compsToExperiment.peer.getLayout().layoutContainer(compsToExperiment.peer)

examples/tutorials/layout/BoxLayoutDemo2.scala
examples/tutorials/layout/BoxLayoutDemo.scala
examples/tutorials/layout/BLDComponent.scala
examples/tutorials/layout/BoxAlignmentDemo.scala
examples/tutorials/layout/FlowLayoutDemo.scala

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)

compsToExperiment.peer.validate()
compsToExperiment.peer.repaint()
examples/tutorials/layout/GridBagLayoutDemo.scala
examples/tutorials/layout/CustomLayoutDemo.scala
override lazy val peer: javax.swing.JPanel =
private def layoutManager =
peer.getLayout.asInstanceOf[DiagonalLayout]
examples/tutorials/layout/BorderLayoutDemo.scala
peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
examples/tutorials/concurrency/Flipper.scala
examples/tutorials/events/ListSelectionDemo.scala
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/events/Beeper.scala
examples/tutorials/misc/FocusConceptsDemo.scala
examples/tutorials/misc/ActionDemo.scala
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
left button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
middle button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is the
right button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
examples/Dialogs.scala
examples/SimpleApplet.scala
examples/LinePainting.scala
examples/ComboBoxes.scala
examples/LabelTest.scala
examples/PopupDemo.scala
examples/SwingApp.scala

On 10/01/2014 08:12 AM, Andy Hicks wrote:

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and haven't
broken anything

The two I had problems with where FormattedTextFieldDemo,
FrameDemo2.
I think they both have functions missing from scala-swing.
What we
could do is move them into a issue saying 'functions x needed'
or if
easier just create a separate pull request for them (assuming you
can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )


You can merge this Pull Request by running

git pull https://github.com/andy1138/scala-swing tutorial

Or view, comment on, or merge it at:

#3

Commit Summary

  • Some code cleanup in tutorials

File Changes

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-0
(45)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-1 (6)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-2
(93)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-3 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-4
(38)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-5
(41)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-6
(65)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-7
(497)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-8 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-9
(95)

  • M

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

<https://github.com/jacobsallan/scala-swing/pull/3/files#diff-10

(9)

  • M

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

<https://github.com/jacobsallan/scala-swing/pull/3/files#diff-11

(144)

  • M

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

<https://github.com/jacobsallan/scala-swing/pull/3/files#diff-12

(9)

Patch Links:


Reply to this email directly or view it on GitHub
#3.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub
<#3 (comment)
.


Reply to this email directly or view it on GitHub
#3 (comment).

@jacobsallan
Copy link
Owner

Hello,

All references to peer are removed from my swingtut branch. Pull into
the main repo when you wish.

The deleted code is saved away in a local branch. Where do you plan to
get the source code for the peer usages? Git hub issues?

Allan

On 10/05/2014 03:11 AM, Andy Hicks wrote:

Hi

I've just done a pull request for the last of the tutorials that are not
using peers.

Thanks for the list of enhancements,
I think the best plan is to look at each of the places its using .peer
and

  • if its a simple one line add to scala-swing then we create a separate
    branch and add it with the updated tutorial examples
  • if its a bit more complicated, then create a github issue about it and
    include the tutorial example there (attach as a github gist if we can't
    find anything better)

It may be possible to add Accessibility to Component either directly
or as
a trait.

When you've removed the tutorials using .peer from the pull request then
I'll pull it into the main scala/scala-swing repo (assuming you're happy
with all the changes)

On 4 October 2014 06:21, Allan Jacobs [email protected] wrote:

Hi Andy,

I went through the demos looking at all the uses of peer components.
There was
more of a scatter of issues than I expected. Most look like relatively
simple
additions to members of the scala.swing package that already exist.

Some of the demos require new components analogous to
javax.swing.Box
javax.swing.TextPane
javax.swing.ToolBar
Primitive versions of TextPane and ToolBar are in the swingtut branch
already.
Box is not implemented yet, as it's interface is likely to be very
different
in Scala from the simple method call in Java.

The TextComponentDemo will require more work and require special
handling for
the actions in java.awt.DefaultEditorKit. Maybe there should be some
additions
to scala.swing.Swing instead of a DefaultEditorKit class.

The other issue raised by the demo for which a fix is non-trivial is
the
method
call getAccessibleContext(). Accessibility cross-cuts all of the swing
apis,
so it is not something to rush into.

Enhancement #1

Add member functions to scala.swing.Action that get and set
short_description.

Enhancement #2

Add a new component Box to wrap javax.swing.Box. It should be possible
to add a
scala.swing.Component to a scala.swing.Box.

Enhancement #3

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent
methods
boolean isDoubleBuffered()
and
void setDoubleBuffered(boolean aFlag)

Enhancement #4

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent
methods
void setComponentOrientation(java.awt.ComponentOrientation o)
void applyComponentOrientation(java.awt.ComponentOrientation o)
and
java.awt.ComponentOrientation getComponentOrientation()

Enhancement scala#5

Add to scala.swing.UIElement wrappers for the javax.swing.JComponent
method
void scrollRectToVisible(java.awt.Rectangel r)

Enhancement scala#6

Add to scala.swing.UIElement replacements for the
javax.swing.JComponent
methods
void setInputMap(int condition, javax.swing.InputMap map)
javax.swing.InputMap getInputMap(int condition)

Enhancement scala#7

In scala.swing.AbstractButton, scala.swing.TextComponent, and
scala.swing.MenuBar
provide replacement for
public void setMargin(java.awt.Insets insets)
In scala.swing.AbstractButton, scala.swing.TextComponenta provide a
wrapper for
public java.awt.Insets getMargin()

Enhancement scala#8

Add to scala.swing.TextComponent wrappers for
javax.swing.text.JTextComponent methods
javax.swing.text.Document getDocument()
and
void setDocument(javax.swing.text.Document doc)

Enhancement scala#9

In scala.swing.RichWindow, in the class Dialog
void setModal(boolean b)
or add a ModalDialog class to scala.swing.

Enhancement scala#10

In scala.swing.RichWindow for the class Frame, add an analogue to
java.awt.Component.getGraphicsConfiguration()
so that Dialog's can be constructed. Or change the constructor for
Dialog so that
the graphics configuration can be obtained from the first, Frame,
argument.

Enhancement scala#11

In scala.swing.ListView, add an analogue for the JList methods
int getLayoutOrientation()
and
void setLayoutOrientation(int layoutOrientation)
Add constants for the orientations or reuse the constants from
javax.swing.JList: VERTICAL, VERTICAL_WRAP, HORIZONTAL_WRAP.

Enhancement scala#12

Add a mechanism to determine whether or not a mouse event is associated
with left, right, or middle mouse buttons. In Swing this is done with
boolean

javax.swing.SwingUtilities.isLeftMouseButton(java.awt.event.MouseEvent e)
boolean

javax.swing.SwingUtilities.isMiddleMouseButton(java.awt.event.MouseEvent
e)
boolean

javax.swing.SwingUtilities.isRightMouseButton(java.awt.event.MouseEvent e)

Enhancement scala#13

In scala.swing.Label, add analogues for JLabel instance methods
java.awt.Component getLabelFor()
and
void setLabelFor(java.awt.Component c)

Enhancement scala#14

Add to scala.swing.ScrollPane a wrapper for the javax.swing.JScrollPane
methods
javax.swing.Border getViewportBorder()
and
void setViewportBorder(javax.swing.Border b)

Enhancement scala#15

Add to scala.swing.ScrollPane a wrapper for the javax.swing.JScrollPane
methods
java.awt.Component getCorner(String key)
and
void setCorner(String key, java.awt.Component corner)

Enhancement scala#16

In scala.swing.ComboBox add wrappers for
public int getMaximumRowCount()
and
public void setMaximumRowCount(int maxRowCount)

Enhancement scala#17

In scala.swing.Table add a wrapper for
int getColumnCount()

Enhancement scala#18

In scala.swing.Table add wrappers for
public boolean print(javax.swing.JTale.PrintMode printMode,
java.text.MessageFormat headerFormat,
java.text.MessageFormat footerFormat)
and
public boolean print(javax.swing.JTable.PrintMode printMode)

Enhancement scala#19

In scala.swing.Table wrappers for
javax.swing.SelectionModel getSelectionModel()
javax.swing.table.TableColumnModel getColumnModel()
void setSelectionModel(javax.swing.SelectionModel sm)
void setColumnModel(javax.swing.table.TableColumnModel cm)

On 10/03/2014 02:13 AM, Andy Hicks wrote:

Doing a separate branch and pull request for the labelFor (and other
missing scala-swing apis) sounds like a good idea. And I can merge
it in.

On 2 October 2014 21:04, Allan Jacobs [email protected]
wrote:

Let's fix the labelFor in a separate branch off of java7. The fix
should be trivial and localized to Label.scala.

Allan

On 10/02/2014 02:19 AM, Andy Hicks wrote:

Thanks,
As you can tell, I'm also learning git, I forgot to do a pull
from
your
branch first :-( , hopefully I'll remember next time (If its
not a
clean
merge please 'remind me', as I've probably forgot )

As for using peer. - scala-swing should be a wrapper for
java-swing
and the
use of peer is really saying we have a method missing. ie the
only
way to
call this method is to use an internal variable.
What I think we should be is move the example to one side and
maybe
create
a github issue (ok, I haven't yet but should) with that item
in 'ie
missing
wrapper for Label.setLabelFor' and we'll come back to them
after the
we've
'ok'ed the others.
The wrappers should normally be the same name without the 'get' /
'set'
part so this would be used like ' label.labelFor = c ' or just
'label.labelFor' as the getter.

This may be more of a problem with things like repaint but I'm
leaving
that
as a TODO for now

I think the examples/tutorials should show nice ways that people
should use
scala-swing, have them show how to use the internals (ie peer)
sounds a
little wrong for now (but there may be a need for a blog/faq
explaining how
to do this for people who really need to do something not part of
scala-swing)

On 1 October 2014 21:03, Allan Jacobs [email protected]
wrote:

The merge was not bad at all. Should the examples with
peer's be
moved
into another directory that won't be propagated to master?

Two of the demos with setLabelFor problems can be saved for
release by
commenting out the offending lines. For instance, changing
label.peer.setLabelFor(passwordField.peer)
into
// label.setLabelFor(passwordField)

examples/tutorials/layout/FlowLayoutDemo.scala may never be
fixed to go
without peers. The problem there is the validate and
repaint. We
will
need to make a decision. Should the use of peers be
encouraged for
usages where scala-swing does not intend to provide a software
interface?

$ find examples -type f -print -exec grep peer {} ;
examples/HelloWorld.scala
examples/CelsiusConverter.scala
examples/images/banana.jpg
examples/images/margarita1.jpg
examples/images/margarita2.jpg
examples/images/rose.jpg
examples/CelsiusConverter2.scala
examples/TableSelection.scala
examples/ColorChooserDemo.scala
examples/ListViewDemo.scala
examples/ButtonApp.scala
examples/UIDemo.scala
examples/CountButton.scala
examples/GridBagDemo.scala
examples/tutorials/components/SliderDemo.scala
examples/tutorials/components/ButtonHtmlDemo.scala
examples/tutorials/components/PasswordDemo.scala
label.peer.setLabelFor(passwordField.peer)
examples/tutorials/components/ListDialog.scala
frame.peer.getGraphicsConfiguration: GraphicsConfiguration) {
peer.setModal(true)
// Setting the selection mode of the peer does not have an
effect.

list.peer.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP)
// peer.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT)
examples/tutorials/components/ScrollDemo2.scala
if (SwingUtilities.isRightMouseButton(e.peer)) {
drawingPane.peer.scrollRectToVisible(rect)
examples/tutorials/components/SimpleTableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TextSamplerDemo.scala
// Had to use the peer for this
purpose..........................................
ftf.peer.setValue(java.util.Calendar.getInstance().getTime())
// Had to reach into the peer for this...................
editorPane.peer.setPage(helpURL)
StyleConstants.setComponent(sButton, button.peer)
newline + "Its peer, JTextPane, is a subclass of JEditorPane
that " +
examples/tutorials/components/SimpleTableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/TopLevelDemo.scala
examples/tutorials/components/ComboBoxDemo.scala
examples/tutorials/components/TablePrintDemo.scala
table.peer.setFillsViewportHeight(true)
// peer.setAlignmentX(0.5f)
table.peer.print(javax.swing.JTable.PrintMode.FIT_WIDTH,
header, null)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/DocumentSizeFilter.scala
examples/tutorials/components/CustomComboBoxDemo.scala
peer.setMaximumRowCount(3)
examples/tutorials/components/BorderDemo.scala
examples/tutorials/components/TabbedPaneDemo.scala
panel.peer.setDoubleBuffered(false)
examples/tutorials/components/FileChooserDemo.scala
peer.setMargin(new Insets(5, 5, 5, 5))
examples/tutorials/components/MenuGlueDemo.scala
examples/tutorials/components/ListDemo.scala
//
employeeName.peer.getDocument().addDocumentListener(hireListener);
examples/tutorials/components/SplitPaneDemo.scala
examples/tutorials/components/MenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/Rule.scala
examples/tutorials/components/ListDialogRunner.scala
intro.peer.setLabelFor(nameLabel.peer)
examples/tutorials/components/IntegerEditor.scala
examples/tutorials/components/ScrollDemo.scala

pictureScrollPane.peer.setViewportBorder(Swing.LineBorder(Color.black))

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_LEADING_CORNER,

buttonCorner.peer)

pictureScrollPane.peer.setCorner(ScrollPaneConstants.LOWER_LEADING_CORNER,

new Corner())

pictureScrollPane.peer.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,

new Corner())
examples/tutorials/components/TumbleItem.scala
setContentPane(animator.peer)
imgs(loopslot).paintIcon(peer, g, off, 0);
examples/tutorials/components/SplitPaneDividerDemo.scala
examples/tutorials/components/ComboBoxDemo2.scala
examples/tutorials/components/IconDemoApp.scala
examples/tutorials/components/DialogDemo.scala
val dialog = new Dialog(frame,
frame.peer.getGraphicsConfiguration) {
dialog.peer.setLocationRelativeTo(frame.peer)
examples/tutorials/components/SplitPaneDemo2.scala
examples/tutorials/components/ColorChooserDemo.scala
examples/tutorials/components/ScrollablePicture.scala
peer.setAutoscrolls(true)
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
peer.scrollRectToVisible(new Rectangle(point.x, point.y))
examples/tutorials/components/SliderDemo2.scala
javax.swing.SwingUtilities.updateComponentTreeUI(top.peer)
examples/tutorials/components/ButtonDemo.scala
examples/tutorials/components/LabelDemo.scala
examples/tutorials/components/MenuLookDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/HtmlDemo.scala
examples/tutorials/components/FrameDemo.scala
examples/tutorials/components/TableDemo.scala
table.peer.setFillsViewportHeight(true)
val numCols = table.peer.getColumnCount()
examples/tutorials/components/CheckboxDemo.scala
examples/tutorials/components/RadioButtonDemo.scala
examples/tutorials/components/SizeDisplayer.scala
icon.paintIcon(peer, g2d,
g2d.setColor(peer.getForeground())
val textRect: Rectangle2D = peer.getFont().getStringBounds(
val insets: Insets = peer.getInsets()
examples/tutorials/components/TableSelectionDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.getSelectionModel().addListSelectionListener(new
RowListener())
table.peer.getColumnModel().getSelectionModel().
table.peer.getSelectionModel().getLeadSelectionIndex(),
table.peer.getColumnModel().getSelectionModel().
examples/tutorials/components/TextComponentDemo.scala
textPane.peer.setMargin(new Insets(5, 5, 5, 5))
val inputMap: InputMap = textPane.peer.getInputMap
miCut.peer.setAction(oldCutAction)
miCopy.peer.setAction(oldCopyAction)
miPaste.peer.setAction(oldPasteAction)
miSelectAll.peer.setAction(oldSelectAllAction)
miBold.peer.setAction(boldAction)
miItalic.peer.setAction(italicAction)
miUnderline.peer.setAction(underlineAction)
miFont12.peer.setAction(font12Action)
miFont14.peer.setAction(font14Action)
miFont18.peer.setAction(font18Action)
miFontSerif.peer.setAction(fontSerifAction)
miFontSansSerif.peer.setAction(fontSansSerifAction)
miFgRed.peer.setAction(fgRedAction)
miFgGreen.peer.setAction(fgGreenAction)
miFgBlue.peer.setAction(fgBlueAction)
miFgBlack.peer.setAction(fgBlackAction)
for (a <- textComponent.peer.getActions()) {
peer.putValue(javax.swing.Action.NAME,
undo.getUndoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Undo")
peer.putValue(javax.swing.Action.NAME,
undo.getRedoPresentationName())
peer.putValue(javax.swing.Action.NAME, "Redo")
val caretCoords: Rectangle = textPane.peer.modelToView(dot)
examples/tutorials/components/Corner.scala
examples/tutorials/components/TextDemo.scala
textArea.caret.position =
textArea.peer.getDocument().getLength()
examples/tutorials/components/PopupMenuDemo.scala
menu.peer.getAccessibleContext().setAccessibleDescription(
menu2.peer.getAccessibleContext().setAccessibleDescription(
output.caret.position = output.peer.getDocument().getLength()
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/components/FormattedTextFieldDemo.scala
amountLabel.peer.setLabelFor(amountField.peer)
rateLabel.peer.setLabelFor(rateField.peer)
// numPeriodsLabel.peer.setLabelFor(numPeriodsField.peer)
paymentLabel.peer.setLabelFor(paymentField.peer)
examples/tutorials/components/MissingIcon.scala
examples/tutorials/components/FrameDemo2.scala
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
// frame.peer.setUndecorated(true);
box.add(label1.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb1.peer)
box.add(rb2.peer)
box.add(rb3.peer)
box.add(Swing.VStrut(15).peer) // spacer
box.add(label2.peer)
box.add(Swing.VStrut(5).peer) // spacer
box.add(rb4.peer)
box.add(rb5.peer)
box.add(rb6.peer)
//JFrame peer to be undecorated causes Swing to throw a
java.awt.IllegalComponentStateException
pane.peer
//Undecorated windows are not supported in scala swing. Go to
the peer.
val contentPane: java.awt.Container = peer.getContentPane()
contentPane.add(button.peer)
// button.peer.setAlignmentX(Component.CENTER_ALIGNMENT)
//horizontally centered
val contentPane = peer.getContentPane()
examples/tutorials/components/TableFTFEditDemo.scala
table.peer.setFillsViewportHeight(true)
table.peer.setDefaultEditor(Class.forName("java.lang.Integer"),
val numCols = table.peer.getColumnCount()
examples/tutorials/layout/DiagonalLayout.scala
examples/tutorials/layout/GridLayoutDemo.scala

compsToExperiment.peer.getLayout().layoutContainer(compsToExperiment.peer)

examples/tutorials/layout/BoxLayoutDemo2.scala
examples/tutorials/layout/BoxLayoutDemo.scala
examples/tutorials/layout/BLDComponent.scala
examples/tutorials/layout/BoxAlignmentDemo.scala
examples/tutorials/layout/FlowLayoutDemo.scala

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT)

compsToExperiment.peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)

compsToExperiment.peer.validate()
compsToExperiment.peer.repaint()
examples/tutorials/layout/GridBagLayoutDemo.scala
examples/tutorials/layout/CustomLayoutDemo.scala
override lazy val peer: javax.swing.JPanel =
private def layoutManager =
peer.getLayout.asInstanceOf[DiagonalLayout]
examples/tutorials/layout/BorderLayoutDemo.scala

peer.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
examples/tutorials/concurrency/Flipper.scala
examples/tutorials/events/ListSelectionDemo.scala
output.caret.position = output.peer.getDocument().getLength()
examples/tutorials/events/Beeper.scala
examples/tutorials/misc/FocusConceptsDemo.scala
examples/tutorials/misc/ActionDemo.scala
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is
the
left button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is
the
middle button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, "This is
the
right button.")
// peer.putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic)
examples/Dialogs.scala
examples/SimpleApplet.scala
examples/LinePainting.scala
examples/ComboBoxes.scala
examples/LabelTest.scala
examples/PopupDemo.scala
examples/SwingApp.scala

On 10/01/2014 08:12 AM, Andy Hicks wrote:

Hi, some more :-)
I've done all examples down to 'I', hope they are ok, and
haven't
broken anything

The two I had problems with where FormattedTextFieldDemo,
FrameDemo2.
I think they both have functions missing from scala-swing.
What we
could do is move them into a issue saying 'functions x
needed'
or if
easier just create a separate pull request for them
(assuming you
can't get them working without 'peer.xx' etc)
(even found some errors in the original java code :-) )


You can merge this Pull Request by running

git pull https://github.com/andy1138/scala-swing tutorial

Or view, comment on, or merge it at:

#3

Commit Summary

  • Some code cleanup in tutorials

File Changes

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-0
(45)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-1 (6)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-2
(93)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-3 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-4
(38)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-5
(41)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-6
(65)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-7
(497)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-8 (8)

  • M

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

https://github.com/jacobsallan/scala-swing/pull/3/files#diff-9
(95)

  • M

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

<https://github.com/jacobsallan/scala-swing/pull/3/files#diff-10

(9)

  • M

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

<https://github.com/jacobsallan/scala-swing/pull/3/files#diff-11

(144)

  • M

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

<https://github.com/jacobsallan/scala-swing/pull/3/files#diff-12

(9)

Patch Links:


Reply to this email directly or view it on GitHub
#3.


Reply to this email directly or view it on GitHub

<#3 (comment)

.


Reply to this email directly or view it on GitHub

<#3 (comment)

.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub

<#3 (comment)
.


Reply to this email directly or view it on GitHub

#3 (comment).


Reply to this email directly or view it on GitHub
#3 (comment).

@andy1138
Copy link
Author

andy1138 commented Oct 7, 2014

All pulled :-) thanks

For the others, I'm hoping it will be like this:
https://github.com/scala/scala-swing/pull/21/files
with the tutorial file and the scala-swing change to make it work. We can then do smaller pull requests as we go.

This may be the simple case but hope that gives the idea.

PS: I'm still working on trying to setup some kind of unit testing, so that may also get added at some point.

jacobsallan pushed a commit that referenced this pull request Oct 7, 2014
closing issue #3 for tutorials that currently work. (see issue for comments/chat)

As discussed in issue #3 all tutorial examples that currently don't have a scala-swing api will be submitted via its own pull request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants