summaryrefslogtreecommitdiff
path: root/src/swing
diff options
context:
space:
mode:
authorIngo Maier <ingo.maier@epfl.ch>2009-04-14 08:43:37 +0000
committerIngo Maier <ingo.maier@epfl.ch>2009-04-14 08:43:37 +0000
commit4ac90d308d6626d5a1bfb70e39c7445e4f7b86aa (patch)
tree4bbcf2464fa0e13cbb07390e7c6298e3dcf92c94 /src/swing
parent2fd666669012fafdc6acbdbd06a36cd91c3a74e2 (diff)
downloadscala-4ac90d308d6626d5a1bfb70e39c7445e4f7b86aa.tar.gz
scala-4ac90d308d6626d5a1bfb70e39c7445e4f7b86aa.tar.bz2
scala-4ac90d308d6626d5a1bfb70e39c7445e4f7b86aa.zip
Fix for #1056
Diffstat (limited to 'src/swing')
-rw-r--r--src/swing/scala/swing/Component.scala2
-rw-r--r--src/swing/scala/swing/Frame.scala16
-rw-r--r--src/swing/scala/swing/MainFrame.scala4
3 files changed, 18 insertions, 4 deletions
diff --git a/src/swing/scala/swing/Component.scala b/src/swing/scala/swing/Component.scala
index e2974edb21..36600e9e19 100644
--- a/src/swing/scala/swing/Component.scala
+++ b/src/swing/scala/swing/Component.scala
@@ -36,6 +36,8 @@ object Component {
* @note [Java Swing] Unlike in Java Swing, not all components are also containers.
*
* @see javax.swing.JComponent
+ * @see http://java.sun.com/products/jfc/tsc/articles/painting/ for the component
+ * painting mechanism
*/
abstract class Component extends UIElement with Publisher {
override lazy val peer: javax.swing.JComponent = new javax.swing.JComponent with SuperMixin {}
diff --git a/src/swing/scala/swing/Frame.scala b/src/swing/scala/swing/Frame.scala
index c06e6f9538..af80fceebd 100644
--- a/src/swing/scala/swing/Frame.scala
+++ b/src/swing/scala/swing/Frame.scala
@@ -10,10 +10,24 @@ import event._
* @see javax.swing.JFrame
*/
class Frame extends UIElement with RootPanel with Publisher {
- override lazy val peer: JFrame = new JFrame
+ override lazy val peer: JFrame = new JFrame with SuperMixin
def title: String = peer.getTitle
def title_=(s: String) = peer.setTitle(s)
+ protected trait SuperMixin extends JFrame {
+ override protected def processWindowEvent(e: java.awt.event.WindowEvent) {
+ super.processWindowEvent(e)
+ if (e.getID() == java.awt.event.WindowEvent.WINDOW_CLOSING)
+ closeOperation()
+ }
+ }
+
+ /**
+ * This method is called when the window is closing, after all other window
+ * event listeners have been processed.
+ */
+ def closeOperation() {}
+
override def contents_=(c: Component) {
super.contents_=(c)
peer.pack() // pack also validates, which is generally required after an add
diff --git a/src/swing/scala/swing/MainFrame.scala b/src/swing/scala/swing/MainFrame.scala
index ae594448ef..725c88dd7c 100644
--- a/src/swing/scala/swing/MainFrame.scala
+++ b/src/swing/scala/swing/MainFrame.scala
@@ -7,7 +7,5 @@ import event._
* framework and quits the application when closed.
*/
class MainFrame extends Frame {
- reactions += {
- case WindowClosing(_) => System.exit(1)
- }
+ override def closeOperation { System.exit(0); }
}