1 22 23 package org.aspectj.util.gui; 24 25 import java.awt.*; 26 import java.awt.event.*; 27 import javax.swing.*; 28 29 36 public class CenteredJDialog extends JDialog { 37 38 45 public CenteredJDialog(Frame f, String title, boolean modal) { 46 super(f, title, modal); 47 } 48 49 54 public void pack() { 55 super.pack(); 56 CenterHelper.center(this); 57 } 58 59 62 protected JRootPane createRootPane() { 63 JRootPane rootPane = new JRootPane(); 64 ActionListener listener = new ActionListener() { 65 public void actionPerformed(ActionEvent e) { 66 setVisible(false); 67 dispose(); 68 }}; 69 KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); 70 rootPane.registerKeyboardAction 71 (listener, stroke,JComponent.WHEN_IN_FOCUSED_WINDOW); 72 return rootPane; 73 } 74 75 78 public void show() { 79 pack(); 80 super.show(); 81 } 82 } 83 | Popular Tags |