From 4ac90d308d6626d5a1bfb70e39c7445e4f7b86aa Mon Sep 17 00:00:00 2001 From: Ingo Maier Date: Tue, 14 Apr 2009 08:43:37 +0000 Subject: Fix for #1056 --- src/swing/scala/swing/Component.scala | 2 ++ src/swing/scala/swing/Frame.scala | 16 +++++++++++++++- src/swing/scala/swing/MainFrame.scala | 4 +--- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src/swing') 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); } } -- cgit v1.2.3