diff options
Diffstat (limited to 'src')
20 files changed, 1 insertions, 866 deletions
diff --git a/src/library/scala/xml/include/sax/Main.scala b/src/library/scala/xml/include/sax/Main.scala index 6b6f6c1593..f58097bcb9 100644 --- a/src/library/scala/xml/include/sax/Main.scala +++ b/src/library/scala/xml/include/sax/Main.scala @@ -10,11 +10,11 @@ package scala.xml package include.sax -import scala.xml.include._ import scala.util.control.Exception.{ catching, ignoring } import org.xml.sax.XMLReader import org.xml.sax.helpers.XMLReaderFactory +@deprecated("Code example will be moved to documentation.", "2.10.0") object Main { private val namespacePrefixes = "http://xml.org/sax/features/namespace-prefixes" private val lexicalHandler = "http://xml.org/sax/properties/lexical-handler" diff --git a/src/swing/scala/swing/test/ButtonApp.scala b/src/swing/scala/swing/test/ButtonApp.scala deleted file mode 100644 index dcf567d365..0000000000 --- a/src/swing/scala/swing/test/ButtonApp.scala +++ /dev/null @@ -1,25 +0,0 @@ -package scala.swing -package test - -import java.awt.Dimension - -import swing._ -import swing.event._ - -object ButtonApp extends SimpleSwingApplication { - def top = new MainFrame { - title = "My Frame" - contents = new GridPanel(2, 2) { - hGap = 3 - vGap = 3 - contents += new Button { - text = "Press Me!" - reactions += { - case ButtonClicked(_) => text = "Hello Scala" - } - } - } - size = new Dimension(300, 80) - } -} - diff --git a/src/swing/scala/swing/test/CelsiusConverter.scala b/src/swing/scala/swing/test/CelsiusConverter.scala deleted file mode 100644 index 4ead632d7a..0000000000 --- a/src/swing/scala/swing/test/CelsiusConverter.scala +++ /dev/null @@ -1,43 +0,0 @@ -package scala.swing -package test - -import swing._ -import event._ - -/** A GUI app to convert celsius to centigrade - */ -object CelsiusConverter extends SimpleSwingApplication { - def top = new MainFrame { - title = "Convert Celsius to Fahrenheit" - val tempCelsius = new TextField - val celsiusLabel = new Label { - text = "Celsius" - border = Swing.EmptyBorder(5, 5, 5, 5) - } - val convertButton = new Button { - text = "Convert"//new javax.swing.ImageIcon("c:\\workspace\\gui\\images\\convert.gif") - //border = Border.Empty(5, 5, 5, 5) - } - val fahrenheitLabel = new Label { - text = "Fahrenheit " - border = Swing.EmptyBorder(5, 5, 5, 5) - listenTo(convertButton, tempCelsius) - - def convert() { - val c = Integer.parseInt(tempCelsius.text) - val f = c * 9 / 5 + 32 - text = "<html><font color = red>"+f+"</font> Fahrenheit</html>" - } - - reactions += { - case ButtonClicked(_) | EditDone(_) => convert() - } - } - contents = new GridPanel(2,2) { - contents.append(tempCelsius, celsiusLabel, convertButton, fahrenheitLabel) - border = Swing.EmptyBorder(10, 10, 10, 10) - } - //defaultButton = Some(convertButton) - } -} - diff --git a/src/swing/scala/swing/test/CelsiusConverter2.scala b/src/swing/scala/swing/test/CelsiusConverter2.scala deleted file mode 100644 index 5ce1b157fe..0000000000 --- a/src/swing/scala/swing/test/CelsiusConverter2.scala +++ /dev/null @@ -1,37 +0,0 @@ -package scala.swing -package test - -import swing._ -import event._ - -object CelsiusConverter2 extends SimpleSwingApplication { - def newField = new TextField { - text = "0" - columns = 5 - horizontalAlignment = Alignment.Right - } - val celsius = newField - val fahrenheit = newField - - listenTo(fahrenheit, celsius) - reactions += { - case EditDone(`fahrenheit`) => - val f = Integer.parseInt(fahrenheit.text) - val c = (f - 32) * 5 / 9 - celsius.text = c.toString - case EditDone(`celsius`) => - val c = Integer.parseInt(celsius.text) - val f = c * 9 / 5 + 32 - fahrenheit.text = f.toString - } - - lazy val ui = new FlowPanel(celsius, new Label(" Celsius = "), - fahrenheit, new Label(" Fahrenheit")) { - border = Swing.EmptyBorder(15, 10, 10, 10) - } - def top = new MainFrame { - title = "Convert Celsius / Fahrenheit" - contents = ui - } -} - diff --git a/src/swing/scala/swing/test/ComboBoxes.scala b/src/swing/scala/swing/test/ComboBoxes.scala deleted file mode 100644 index cf1a70d97b..0000000000 --- a/src/swing/scala/swing/test/ComboBoxes.scala +++ /dev/null @@ -1,87 +0,0 @@ -package scala.swing -package test - -import swing._ -import event._ -import java.util.Date -import java.awt.Color -import java.text.SimpleDateFormat -import javax.swing.{Icon, ImageIcon} - -/** - * Demonstrates how to use combo boxes and custom item renderers. - * - * TODO: clean up layout - */ -object ComboBoxes extends SimpleSwingApplication { - import ComboBox._ - lazy val ui = new FlowPanel { - contents += new ComboBox(List(1,2,3,4)) - - val patterns = List("dd MMMMM yyyy", - "dd.MM.yy", - "MM/dd/yy", - "yyyy.MM.dd G 'at' hh:mm:ss z", - "EEE, MMM d, ''yy", - "h:mm a", - "H:mm:ss:SSS", - "K:mm a,z", - "yyyy.MMMMM.dd GGG hh:mm aaa") - val dateBox = new ComboBox(patterns) { makeEditable() } - contents += dateBox - val field = new TextField(20) { editable = false } - contents += field - - reactions += { - case SelectionChanged(`dateBox`) => reformat() - } - listenTo(dateBox.selection) - - def reformat() { - try { - val today = new Date - val formatter = new SimpleDateFormat(dateBox.selection.item) - val dateString = formatter.format(today) - field.foreground = Color.black - field.text = dateString - } catch { - case e: IllegalArgumentException => - field.foreground = Color.red - field.text = "Error: " + e.getMessage - } - } - - - val icons = try { - List(new ImageIcon(resourceFromClassloader("images/margarita1.jpg")), - new ImageIcon(resourceFromClassloader("images/margarita2.jpg")), - new ImageIcon(resourceFromClassloader("images/rose.jpg")), - new ImageIcon(resourceFromClassloader("images/banana.jpg"))) - } catch { - case _ => - println("Couldn't load images for combo box") - List(Swing.EmptyIcon) - } - - val iconBox = new ComboBox(icons) { - renderer = new ListView.AbstractRenderer[Icon, Label](new Label) { - def configure(list: ListView[_], isSelected: Boolean, focused: Boolean, icon: Icon, index: Int) { - component.icon = icon - component.xAlignment = Alignment.Center - if(isSelected) { - component.border = Swing.LineBorder(list.selectionBackground, 3) - } else { - component.border = Swing.EmptyBorder(3) - } - } - } - } - contents += iconBox - } - - def top = new MainFrame { - title = "ComboBoxes Demo" - contents = ui - } -} - diff --git a/src/swing/scala/swing/test/CountButton.scala b/src/swing/scala/swing/test/CountButton.scala deleted file mode 100644 index 373db785ba..0000000000 --- a/src/swing/scala/swing/test/CountButton.scala +++ /dev/null @@ -1,31 +0,0 @@ -package scala.swing -package test - -import scala.swing._ -import scala.swing.event._ - -object CountButton extends SimpleSwingApplication { - def top = new MainFrame { - title = "My Frame" - contents = new GridPanel(2, 2) { - hGap = 3 - vGap = 3 - val button = new Button { - text = "Press Me!" - } - contents += button - val label = new Label { - text = "No button clicks registered" - } - contents += label - - listenTo(button) - var nclicks = 0 - reactions += { - case ButtonClicked(b) => - nclicks += 1 - label.text = "Number of button clicks: "+nclicks - } - } - } -} diff --git a/src/swing/scala/swing/test/Dialogs.scala b/src/swing/scala/swing/test/Dialogs.scala deleted file mode 100644 index 14fa2febf2..0000000000 --- a/src/swing/scala/swing/test/Dialogs.scala +++ /dev/null @@ -1,177 +0,0 @@ -package scala.swing -package test - -import swing._ -import swing.event._ - -object Dialogs extends SimpleSwingApplication { - import TabbedPane._ - - lazy val label = new Label("No Result yet") - lazy val tabs = new TabbedPane { - pages += new Page("File", new GridBagPanel { grid => - import GridBagPanel._ - val buttonText = new TextField("Click Me") - - val c = new Constraints - c.fill = Fill.Horizontal - c.grid = (1,1) - - val chooser = new FileChooser - layout(new Button(Action("Open") { - chooser.showOpenDialog(grid) - })) = c - - c.grid = (1,2) - layout(new Button(Action("Save") { - chooser.showSaveDialog(grid) - })) = c - - c.grid = (1,3) - layout(new Button(Action("Custom") { - chooser.showDialog(grid, buttonText.text) - })) = c - - c.grid = (2,3) - layout(new Label(" with Text ")) = c - - c.grid = (3,3) - c.ipadx = 50 - layout(buttonText) = c - - border = Swing.EmptyBorder(5, 5, 5, 5) - }) - pages += new Page("Simple Modal Dialogs", new BorderPanel { - import BorderPanel._ - val mutex = new ButtonGroup - val ok = new RadioButton("OK (in the L&F's words)") - val ynlf = new RadioButton("Yes/No (in the L&F's words)") - val ynp = new RadioButton("Yes/No (in the programmer's words)") - val yncp = new RadioButton("Yes/No/Cancel (in the programmer's words)") - val radios = List(ok, ynlf, ynp, yncp) - mutex.buttons ++= radios - mutex.select(ok) - val buttons = new BoxPanel(Orientation.Vertical) { - contents ++= radios - } - layout(buttons) = Position.North - layout(new Button(Action("Show It!") { - import Dialog._ - mutex.selected.get match { - case `ok` => - showMessage(buttons, "Eggs aren't supposed to be green.") - case `ynlf` => - label.text = showConfirmation(buttons, - "Would you like green eggs and ham?", - "An Inane Question") match { - case Result.Yes => "Ewww!" - case Result.No => "Me neither!" - case _ => "Come on -- tell me!" - } - case `ynp` => - val options = List("Yes, please", - "No, thanks", - "No eggs, no ham!") - label.text = showOptions(buttons, - "Would you like some green eggs to go with that ham?", - "A Silly Question", - entries = options, - initial = 2) match { - case Result.Yes => "You're kidding!" - case Result.No => "I don't like them, either." - case _ => "Come on -- 'fess up!" - } - case `yncp` => - val options = List("Yes, please", - "No, thanks", - "No eggs, no ham!") - label.text = showOptions(buttons, - message = "Would you like some green eggs to go with that ham?", - title = "A Silly Question", - entries = options, - initial = 2) match { - case Result.Yes => "Here you go: green eggs and ham!" - case Result.No => "OK, just the ham, then." - case Result.Cancel => "Well, I'm certainly not going to eat them!" - case _ => "Please tell me what you want!" - } - } - })) = Position.South - }) - pages += new Page("More Dialogs", new BorderPanel { - import BorderPanel._ - val mutex = new ButtonGroup - val pick = new RadioButton("Pick one of several choices") - val enter = new RadioButton("Enter some text") - val custom = new RadioButton("Custom") - val customUndec = new RadioButton("Custom undecorated") - val custom2 = new RadioButton("2 custom dialogs") - val radios = List(pick, enter, custom, customUndec, custom2) - mutex.buttons ++= radios - mutex.select(pick) - val buttons = new BoxPanel(Orientation.Vertical) { - contents ++= radios - } - layout(buttons) = Position.North - layout(new Button(Action("Show It!") { - import Dialog._ - mutex.selected.get match { - case `pick` => - val possibilities = List("ham", "spam", "yam") - val s = showInput(buttons, - "Complete the sentence:\n\"Green eggs and...\"", - "Customized Dialog", - Message.Plain, - Swing.EmptyIcon, - possibilities, "ham") - - //If a string was returned, say so. - label.text = if ((s != None) && (s.get.length > 0)) - "Green eggs and... " + s.get + "!" - else - "Come on, finish the sentence!" - case `enter` => - val s = showInput(buttons, - "Complete the sentence:\n\"Green eggs and...\"", - "Customized Dialog", - Message.Plain, - Swing.EmptyIcon, - Nil, "ham") - - //If a string was returned, say so. - label.text = if ((s != None) && (s.get.length > 0)) - "Green eggs and... " + s.get + "!" - else - "Come on, finish the sentence!" - case `custom` => - val dialog = new Dialog(top) - dialog.open() - dialog.contents = Button("Close Me!") { dialog.close() } - case `customUndec` => - val dialog = new Dialog with RichWindow.Undecorated - dialog.open() - dialog.contents = Button("Close Me!") { dialog.close() } - case `custom2` => - val d1 = new Dialog - val d2 = new Dialog(d1) - d1.open() - d2.open() - d1.contents = Button("Close Me! I am the owner and will automatically close the other one") { d1.close() } - d2.contents = Button("Close Me!") { d2.close() } - } - })) = Position.South - }) - } - - lazy val ui: Panel = new BorderPanel { - layout(tabs) = BorderPanel.Position.Center - layout(label) = BorderPanel.Position.South - } - - - lazy val top = new MainFrame { - title = "Dialog Demo" - contents = ui - } -} - diff --git a/src/swing/scala/swing/test/GridBagDemo.scala b/src/swing/scala/swing/test/GridBagDemo.scala deleted file mode 100644 index ebb538f1c0..0000000000 --- a/src/swing/scala/swing/test/GridBagDemo.scala +++ /dev/null @@ -1,65 +0,0 @@ -package scala.swing -package test - -import swing._ -import swing.event._ -import GridBagPanel._ -import java.awt.Insets - -object GridBagDemo extends SimpleSwingApplication { - lazy val ui = new GridBagPanel { - val c = new Constraints - val shouldFill = true - if (shouldFill) { - c.fill = Fill.Horizontal - } - - val button1 = new Button("Button 1") - - c.weightx = 0.5 - - c.fill = Fill.Horizontal - c.gridx = 0; - c.gridy = 0; - layout(button1) = c - - val button2 = new Button("Button 2") - c.fill = Fill.Horizontal - c.weightx = 0.5; - c.gridx = 1; - c.gridy = 0; - layout(button2) = c - - val button3 = new Button("Button 3") - c.fill = Fill.Horizontal - c.weightx = 0.5; - c.gridx = 2; - c.gridy = 0; - layout(button3) = c - - val button4 = new Button("Long-Named Button 4") - c.fill = Fill.Horizontal - c.ipady = 40; //make this component tall - c.weightx = 0.0; - c.gridwidth = 3; - c.gridx = 0; - c.gridy = 1; - layout(button4) = c - - val button5 = new Button("5") - c.fill = Fill.Horizontal - c.ipady = 0; //reset to default - c.weighty = 1.0; //request any extra vertical space - c.anchor = Anchor.PageEnd - c.insets = new Insets(10,0,0,0); //top padding - c.gridx = 1; //aligned with button 2 - c.gridwidth = 2; //2 columns wide - c.gridy = 2; //third row - layout(button5) = c - } - - def top = new MainFrame { - title = "GridBag Demo" - contents = ui - } -} diff --git a/src/swing/scala/swing/test/HelloWorld.scala b/src/swing/scala/swing/test/HelloWorld.scala deleted file mode 100644 index 6014a14b2d..0000000000 --- a/src/swing/scala/swing/test/HelloWorld.scala +++ /dev/null @@ -1,14 +0,0 @@ -package scala.swing -package test - -import swing._ - -/** - * A simple swing demo. - */ -object HelloWorld extends SimpleSwingApplication { - def top = new MainFrame { - title = "Hello, World!" - contents = new Button("Click Me!") - } -}
\ No newline at end of file diff --git a/src/swing/scala/swing/test/LabelTest.scala b/src/swing/scala/swing/test/LabelTest.scala deleted file mode 100644 index 47eedb84ac..0000000000 --- a/src/swing/scala/swing/test/LabelTest.scala +++ /dev/null @@ -1,20 +0,0 @@ -package scala.swing -package test - -import scala.swing._ -import scala.swing.event._ - -object LabelTest extends SimpleSwingApplication { - def top = new MainFrame{ - contents = new Label { - text = "Hello" - import java.awt.event._ - listenTo(mouse.clicks) - reactions += { - case MousePressed(_,_,_,_,_) => - println("Mouse pressed2") - } - } - } -} - diff --git a/src/swing/scala/swing/test/LinePainting.scala b/src/swing/scala/swing/test/LinePainting.scala deleted file mode 100644 index 8588665ddc..0000000000 --- a/src/swing/scala/swing/test/LinePainting.scala +++ /dev/null @@ -1,54 +0,0 @@ -package scala.swing -package test - -import scala.swing.Swing._ -import scala.swing.{MainFrame, Panel} -import scala.swing.event._ -import java.awt.{Color, Graphics2D, Point, geom} - -/** - * Dragging the mouse draws a simple graph - * - * @author Frank Teubler, Ingo Maier - */ -object LinePainting extends SimpleSwingApplication { - lazy val ui = new Panel { - background = Color.white - preferredSize = (200,200) - - focusable = true - listenTo(mouse.clicks, mouse.moves, keys) - - reactions += { - case e: MousePressed => - moveTo(e.point) - requestFocusInWindow() - case e: MouseDragged => lineTo(e.point) - case e: MouseReleased => lineTo(e.point) - case KeyTyped(_,'c',_,_) => - path = new geom.GeneralPath - repaint() - case _: FocusLost => repaint() - } - - /* records the dragging */ - var path = new geom.GeneralPath - - def lineTo(p: Point) { path.lineTo(p.x, p.y); repaint() } - def moveTo(p: Point) { path.moveTo(p.x, p.y); repaint() } - - override def paintComponent(g: Graphics2D) = { - super.paintComponent(g) - g.setColor(new Color(100,100,100)) - g.drawString("Press left mouse button and drag to paint." + - (if(hasFocus) " Press 'c' to clear." else ""), 10, size.height-10) - g.setColor(Color.black) - g.draw(path) - } - } - - def top = new MainFrame { - title = "Simple Line Painting Demo" - contents = ui - } -} diff --git a/src/swing/scala/swing/test/ListViewDemo.scala b/src/swing/scala/swing/test/ListViewDemo.scala deleted file mode 100644 index 2b8c8c0719..0000000000 --- a/src/swing/scala/swing/test/ListViewDemo.scala +++ /dev/null @@ -1,18 +0,0 @@ -package scala.swing -package test - -object ListViewDemo extends SimpleSwingApplication { - def top = new MainFrame { - case class City(name: String, country: String, population: Int, capital: Boolean) - val items = List(City("Lausanne", "Switzerland", 129273, false), - City("Paris", "France", 2203817, true), - City("New York", "USA", 8363710 , false), - City("Berlin", "Germany", 3416300, true), - City("Tokio", "Japan", 12787981, true)) - import ListView._ - contents = new FlowPanel(new ScrollPane(new ListView(items) { - renderer = Renderer(_.name) - })) - //new ScrollPane(new Table(items))) - } -} diff --git a/src/swing/scala/swing/test/SimpleApplet.scala b/src/swing/scala/swing/test/SimpleApplet.scala deleted file mode 100644 index d5f17f8a40..0000000000 --- a/src/swing/scala/swing/test/SimpleApplet.scala +++ /dev/null @@ -1,19 +0,0 @@ -package scala.swing -package test - -import event._ - -class SimpleApplet extends Applet { - object ui extends UI with Reactor { - def init() = { - val button = new Button("Press here!") - val text = new TextArea("Java Version: " + util.Properties.javaVersion + "\n") - listenTo(button) - reactions += { - case ButtonClicked(_) => text.text += "Button Pressed!\n" - case _ => - } - contents = new BoxPanel(Orientation.Vertical) { contents.append(button, text) } - } - } -} diff --git a/src/swing/scala/swing/test/SwingApp.scala b/src/swing/scala/swing/test/SwingApp.scala deleted file mode 100644 index b47d778d3a..0000000000 --- a/src/swing/scala/swing/test/SwingApp.scala +++ /dev/null @@ -1,30 +0,0 @@ -package scala.swing -package test - -import swing._ -import swing.event._ - -object SwingApp extends SimpleSwingApplication { - def top = new MainFrame { - title = "SwingApp" - var numclicks = 0 - object label extends Label { - val prefix = "Number of button clicks: " - text = prefix + "0 " - listenTo(button) - reactions += { - case ButtonClicked(button) => - numclicks = numclicks + 1 - text = prefix + numclicks - } - } - object button extends Button { - text = "I am a button" - } - contents = new FlowPanel { - contents.append(button, label) - border = Swing.EmptyBorder(5, 5, 5, 5) - } - } -} - diff --git a/src/swing/scala/swing/test/TableSelection.scala b/src/swing/scala/swing/test/TableSelection.scala deleted file mode 100644 index bbfef80277..0000000000 --- a/src/swing/scala/swing/test/TableSelection.scala +++ /dev/null @@ -1,97 +0,0 @@ -package scala.swing -package test - -import java.awt.Dimension -import swing.event._ - -object TableSelection extends SimpleSwingApplication { - val model = Array(List("Mary", "Campione", "Snowboarding", 5, false).toArray, - List("Alison", "Huml", "Rowing", 5, false).toArray, - List("Kathy", "Walrath", "Knitting", 5, false).toArray, - List("Sharon", "Zakhour", "Speed reading", 5, false).toArray, - List("Philip", "Milne", "Pool", 5, false).toArray) - /*val model = Array.tabulate(10000) { i => - List("Mary", "Campione", "Snowboarding", i, false).toArray - }*/ - - lazy val ui = new BoxPanel(Orientation.Vertical) { - val table = new Table(model, Array("First Name", "Last Name", "Sport", "# of Years", "Vegetarian")) { - preferredViewportSize = new Dimension(500, 70) - } - //1.6:table.fillsViewportHeight = true - listenTo(table.selection) - - contents += new ScrollPane(table) - contents += new Label("Selection Mode") - - def radio(mutex: ButtonGroup, text: String): RadioButton = { - val b = new RadioButton(text) - listenTo(b) - mutex.buttons += b - contents += b - b - } - - val intervalMutex = new ButtonGroup - val multiInterval = radio(intervalMutex, "Multiple Interval Selection") - val elementInterval = radio(intervalMutex, "Single Selection") - val singleInterval = radio(intervalMutex, "Single Interval Selection") - intervalMutex.select(multiInterval) - - contents += new Label("Selection Options") - val elemMutex = new ButtonGroup - val rowSelection = radio(elemMutex, "Row Selection") - val columnSelection = radio(elemMutex, "Column Selection") - val cellSelection = radio(elemMutex, "Cell Selection") - elemMutex.select(rowSelection) - - val output = new TextArea(5, 40) { editable = false } - contents += new ScrollPane(output) - - def outputSelection() { - output.append("Lead: " + table.selection.rows.leadIndex + "," + - table.selection.columns.leadIndex + ". ") - output.append("Rows:") - for (c <- table.selection.rows) output.append(" " + c) - output.append(". Columns:") - for (c <- table.selection.columns) output.append(" " + c) - output.append(".\n") - } - - reactions += { - case ButtonClicked(`multiInterval`) => - table.selection.intervalMode = Table.IntervalMode.MultiInterval - if (cellSelection.selected) { - elemMutex.select(rowSelection) - table.selection.elementMode = Table.ElementMode.None - } - cellSelection.enabled = false - case ButtonClicked(`elementInterval`) => - table.selection.intervalMode = Table.IntervalMode.Single - cellSelection.enabled = true - case ButtonClicked(`singleInterval`) => - table.selection.intervalMode = Table.IntervalMode.SingleInterval - cellSelection.enabled = true - case ButtonClicked(`rowSelection`) => - if (rowSelection.selected) - table.selection.elementMode = Table.ElementMode.Row - case ButtonClicked(`columnSelection`) => - if (columnSelection.selected) - table.selection.elementMode = Table.ElementMode.Column - case ButtonClicked(`cellSelection`) => - if (cellSelection.selected) - table.selection.elementMode = Table.ElementMode.Cell - case TableRowsSelected(_, range, false) => - output.append("Rows selected, changes: " + range + "\n") - outputSelection() - case TableColumnsSelected(_, range, false) => - output.append("Columns selected, changes " + range + "\n") - outputSelection() - } - } - - def top = new MainFrame { - title = "Table Selection" - contents = ui - } -} diff --git a/src/swing/scala/swing/test/UIDemo.scala b/src/swing/scala/swing/test/UIDemo.scala deleted file mode 100644 index 9207c82948..0000000000 --- a/src/swing/scala/swing/test/UIDemo.scala +++ /dev/null @@ -1,148 +0,0 @@ -package scala.swing -package test - -import swing._ -import event._ -import Swing._ -import ListView._ - -object UIDemo extends SimpleSwingApplication { - def top = new MainFrame { - title = "Scala Swing Demo" - - /* - * Create a menu bar with a couple of menus and menu items and - * set the result as this frame's menu bar. - */ - menuBar = new MenuBar { - contents += new Menu("A Menu") { - contents += new MenuItem("An item") - contents += new MenuItem(Action("An action item") { - println("Action '"+ title +"' invoked") - }) - contents += new Separator - contents += new CheckMenuItem("Check me") - contents += new CheckMenuItem("Me too!") - contents += new Separator - val a = new RadioMenuItem("a") - val b = new RadioMenuItem("b") - val c = new RadioMenuItem("c") - val mutex = new ButtonGroup(a,b,c) - contents ++= mutex.buttons - } - contents += new Menu("Empty Menu") - } - - /* - * The root component in this frame is a panel with a border layout. - */ - contents = new BorderPanel { - import BorderPanel.Position._ - - var reactLive = false - - val tabs = new TabbedPane { - import TabbedPane._ - val buttons = new FlowPanel { - border = Swing.EmptyBorder(5,5,5,5) - - contents += new BoxPanel(Orientation.Vertical) { - border = CompoundBorder(TitledBorder(EtchedBorder, "Radio Buttons"), EmptyBorder(5,5,5,10)) - val a = new RadioButton("Green Vegetables") - val b = new RadioButton("Red Meat") - val c = new RadioButton("White Tofu") - val mutex = new ButtonGroup(a,b,c) - contents ++= mutex.buttons - } - contents += new BoxPanel(Orientation.Vertical) { - border = CompoundBorder(TitledBorder(EtchedBorder, "Check Boxes"), EmptyBorder(5,5,5,10)) - val paintLabels = new CheckBox("Paint Labels") - val paintTicks = new CheckBox("Paint Ticks") - val snapTicks = new CheckBox("Snap To Ticks") - val live = new CheckBox("Live") - contents.append(paintLabels, paintTicks, snapTicks, live) - listenTo(paintLabels, paintTicks, snapTicks, live) - reactions += { - case ButtonClicked(`paintLabels`) => - slider.paintLabels = paintLabels.selected - case ButtonClicked(`paintTicks`) => - slider.paintTicks = paintTicks.selected - case ButtonClicked(`snapTicks`) => - slider.snapToTicks = snapTicks.selected - case ButtonClicked(`live`) => - reactLive = live.selected - } - } - contents += new Button(Action("Center Frame") { centerOnScreen() }) - } - pages += new Page("Buttons", buttons) - pages += new Page("GridBag", GridBagDemo.ui) - pages += new Page("Converter", CelsiusConverter2.ui) - pages += new Page("Tables", TableSelection.ui) - pages += new Page("Dialogs", Dialogs.ui) - pages += new Page("Combo Boxes", ComboBoxes.ui) - pages += new Page("Split Panes", - new SplitPane(Orientation.Vertical, new Button("Hello"), new Button("World")) { - continuousLayout = true - }) - - val password = new FlowPanel { - contents += new Label("Enter your secret password here ") - val field = new PasswordField(10) - contents += field - val label = new Label(field.text) - contents += label - listenTo(field) - reactions += { - case EditDone(`field`) => label.text = field.password.mkString - } - } - - pages += new Page("Password", password) - pages += new Page("Painting", LinePainting.ui) - //pages += new Page("Text Editor", TextEditor.ui) - } - - val list = new ListView(tabs.pages) { - selectIndices(0) - selection.intervalMode = ListView.IntervalMode.Single - renderer = ListView.Renderer(_.title) - } - val center = new SplitPane(Orientation.Vertical, new ScrollPane(list), tabs) { - oneTouchExpandable = true - continuousLayout = true - } - layout(center) = Center - - /* - * This slider is used above, so we need lazy initialization semantics. - * Objects or lazy vals are the way to go, but objects give us better - * type inference at times. - */ - object slider extends Slider { - min = 0 - value = tabs.selection.index - max = tabs.pages.size-1 - majorTickSpacing = 1 - } - layout(slider) = South - - /* - * Establish connection between the tab pane, slider, and list view. - */ - listenTo(slider) - listenTo(tabs.selection) - listenTo(list.selection) - reactions += { - case ValueChanged(`slider`) => - if(!slider.adjusting || reactLive) tabs.selection.index = slider.value - case SelectionChanged(`tabs`) => - slider.value = tabs.selection.index - list.selectIndices(tabs.selection.index) - case SelectionChanged(`list`) => - if (list.selection.items.length == 1) - tabs.selection.page = list.selection.items(0) - } - } - } -}
\ No newline at end of file diff --git a/src/swing/scala/swing/test/images/banana.jpg b/src/swing/scala/swing/test/images/banana.jpg Binary files differdeleted file mode 100644 index 62267a4325..0000000000 --- a/src/swing/scala/swing/test/images/banana.jpg +++ /dev/null diff --git a/src/swing/scala/swing/test/images/margarita1.jpg b/src/swing/scala/swing/test/images/margarita1.jpg Binary files differdeleted file mode 100644 index d315f7c79f..0000000000 --- a/src/swing/scala/swing/test/images/margarita1.jpg +++ /dev/null diff --git a/src/swing/scala/swing/test/images/margarita2.jpg b/src/swing/scala/swing/test/images/margarita2.jpg Binary files differdeleted file mode 100644 index c8b076e5f9..0000000000 --- a/src/swing/scala/swing/test/images/margarita2.jpg +++ /dev/null diff --git a/src/swing/scala/swing/test/images/rose.jpg b/src/swing/scala/swing/test/images/rose.jpg Binary files differdeleted file mode 100644 index d4a2b58062..0000000000 --- a/src/swing/scala/swing/test/images/rose.jpg +++ /dev/null |