summaryrefslogtreecommitdiff
path: root/docs/examples/swing/GridBagDemo.scala
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2011-12-07 21:52:20 +0100
committerSimon Ochsenreither <simon@ochsenreither.de>2011-12-07 22:09:04 +0100
commitf3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc (patch)
tree6d77a6dbbb3de69bc38a7e2d55a37596960675a0 /docs/examples/swing/GridBagDemo.scala
parent332fec96e31840878bed41dd7b5314b97d8da7c2 (diff)
downloadscala-f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc.tar.gz
scala-f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc.tar.bz2
scala-f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc.zip
Clean up standard/swing library by deprecating/moving code examples
Deprecate scala/xml/include/sax/Main.scala. Move scala/swing/test/* to docs/examples. Saves 160KB in scala-swing.jar. Fixes SI-4627.
Diffstat (limited to 'docs/examples/swing/GridBagDemo.scala')
-rw-r--r--docs/examples/swing/GridBagDemo.scala64
1 files changed, 64 insertions, 0 deletions
diff --git a/docs/examples/swing/GridBagDemo.scala b/docs/examples/swing/GridBagDemo.scala
new file mode 100644
index 0000000000..60cfc13acb
--- /dev/null
+++ b/docs/examples/swing/GridBagDemo.scala
@@ -0,0 +1,64 @@
+package examples.swing
+
+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
+ }
+}