1 37 38 package swingwt.awt; 39 40 import org.eclipse.swt.SWT; 41 import org.eclipse.swt.widgets.Shell; 42 43 import swingwtx.swing.SwingUtilities; 44 45 public class Dialog extends Window { 46 47 protected boolean isModal = true; 48 49 public Dialog() { this((Frame) null, "", true); } 50 public Dialog(String title) { this((Frame) null, title, true); } 51 public Dialog(swingwt.awt.Dialog owner) { this(owner, "", true); } 52 public Dialog(swingwt.awt.Dialog owner, boolean modal) { this(owner, "", modal); } 53 public Dialog(swingwt.awt.Dialog owner, String title) { this(owner, title, true); } 54 public Dialog(swingwt.awt.Dialog owner, String title, boolean modal) { this(owner, title, true, null); } 55 public Dialog(swingwt.awt.Dialog owner, String title, boolean modal, GraphicsConfiguration gc) { super(owner, modal); setModal(modal); setTitle(title); } 56 public Dialog(Frame owner) { this(owner, "", true); } 57 public Dialog(Frame owner, boolean modal) { this(owner, "", modal); } 58 public Dialog(Frame owner, String title) { this(owner, title, true); } 59 public Dialog(Frame owner, String title, boolean modal) { this(owner, title, true, null); } 60 public Dialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) { super(owner, modal); setModal(modal); setTitle(title); } 61 62 public void setResizable(boolean b) { } 63 public boolean isResizable() { return true; } 64 public void setModal(boolean b) { isModal = b; } 65 public boolean isModal() { return isModal; } 66 67 68 public void setVisible(final boolean b) { 69 final Dialog me = this; 70 SwingUtilities.invokeSync(new Runnable () { 71 public void run() { 72 if (b) { 73 74 if (isModal) { 80 peer.open(); 81 repaintFix(); 82 dispatchEvents(); 83 } 84 else 85 { 86 91 Dimension size = getSize(); 93 Point location = getLocation(); 94 String title = getTitle(); 95 Image image = getIconImage(); 96 97 peer.dispose(); 99 100 peer = new Shell(display, SWT.DIALOG_TRIM); 103 composite = peer; 104 peer.setLayout(new swingwt.awt.swtcustomlayout.SWTBorderLayout()); 105 try { rootPane.setSwingWTParent(me); } catch (Exception e) { e.printStackTrace(); } 106 peer.setLayoutData(swingwt.awt.swtcustomlayout.SWTBorderLayout.CENTER); 107 registerWindowEvents(); 108 109 setSize(size); 111 setLocation(location); 112 setTitle(title); 113 setIconImage(image); 114 115 peer.open(); 117 processWindowEvent(swingwt.awt.event.WindowEvent.WINDOW_OPENED); 118 repaintFix(); 119 } 120 } 121 else { 122 if (isClosed) return; 125 peer.close(); 126 } 127 } 128 }); 129 } 130 131 } 132 | Popular Tags |