1 /* 2 * JaLingo, http://jalingo.sourceforge.net/ 3 * 4 * Copyright (c) 2002-2006 Oleksandr Shyshko 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 package ja.centre.gui.components.enhancedwindow; 22 23 import javax.swing.*; 24 import java.awt.*; 25 import java.awt.event.WindowEvent; 26 27 public class EnhancedDialog extends JDialog implements IEnhancedWindow<JDialog> { EnhancedDialog( Frame owner )28 public EnhancedDialog( Frame owner ) { 29 this( owner, false ); 30 } EnhancedDialog( Frame owner, boolean modal )31 public EnhancedDialog( Frame owner, boolean modal ) { 32 super( owner, modal ); 33 init(); 34 } 35 EnhancedDialog( Dialog owner )36 public EnhancedDialog( Dialog owner ) { 37 this( owner, false ); 38 } EnhancedDialog( Dialog owner, boolean modal )39 public EnhancedDialog( Dialog owner, boolean modal ) { 40 super( owner, modal ); 41 init(); 42 } 43 init()44 private void init() { 45 setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); 46 } 47 createRootPane()48 protected JRootPane createRootPane() { 49 return EnhancedWindowHelper.attachCloseOnEscape( super.createRootPane(), this ); 50 } 51 setLocationRelativeTo( Component c )52 public void setLocationRelativeTo( Component c ) { 53 super.setLocationRelativeTo( EnhancedWindowHelper.filterIconifiedFrame( c ) ); 54 } 55 56 // NOTE: hack to make it public processWindowEvent( WindowEvent event )57 public void processWindowEvent( WindowEvent event ) { 58 super.processWindowEvent( event ); 59 } 60 getWindow()61 public JDialog getWindow() { 62 return this; 63 } 64 } 65