24 |
24 |
package org.gvsig.tools.swing.impl;
|
25 |
25 |
|
26 |
26 |
import java.awt.BorderLayout;
|
|
27 |
import java.awt.Component;
|
27 |
28 |
import java.awt.Dialog;
|
28 |
29 |
import java.awt.Dimension;
|
|
30 |
import java.awt.GraphicsConfiguration;
|
|
31 |
import java.awt.GraphicsDevice;
|
|
32 |
import java.awt.Rectangle;
|
29 |
33 |
import java.awt.Toolkit;
|
|
34 |
import java.awt.Window;
|
30 |
35 |
import java.awt.event.ActionEvent;
|
31 |
36 |
import java.awt.event.ActionListener;
|
32 |
37 |
|
... | ... | |
47 |
52 |
private String value = null;
|
48 |
53 |
private JTextArea text = null;
|
49 |
54 |
|
50 |
|
public DefaultZoomDialog(String title) {
|
51 |
|
super((Dialog) null, title, true);
|
|
55 |
public DefaultZoomDialog(Component parent, String title) {
|
|
56 |
super(getParentWindow(parent), title, ModalityType.DOCUMENT_MODAL);
|
52 |
57 |
}
|
53 |
58 |
|
54 |
|
public DefaultZoomDialog(String title, String value) {
|
55 |
|
this(title);
|
|
59 |
public DefaultZoomDialog(Component parent, String title, String value) {
|
|
60 |
this(parent, title);
|
56 |
61 |
this.value = value;
|
57 |
62 |
initComponents();
|
58 |
63 |
|
59 |
64 |
}
|
60 |
65 |
|
|
66 |
private static Window getParentWindow(Component c) {
|
|
67 |
while( c!=null ) {
|
|
68 |
if( c instanceof Window ) {
|
|
69 |
return (Window) c;
|
|
70 |
}
|
|
71 |
c = c.getParent();
|
|
72 |
}
|
|
73 |
return null;
|
|
74 |
}
|
|
75 |
|
61 |
76 |
public void setEditable(boolean editable) {
|
62 |
77 |
this.text.setEditable(editable);
|
63 |
78 |
}
|
... | ... | |
100 |
115 |
}
|
101 |
116 |
|
102 |
117 |
public void center() {
|
103 |
|
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
104 |
118 |
Dimension size = this.getPreferredSize();
|
105 |
|
int x = (int) ((dimension.getWidth() - size.getWidth()) / 2);
|
106 |
|
int y = (int) ((dimension.getHeight() - size.getHeight()) / 2);
|
|
119 |
|
|
120 |
// Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
|
121 |
// int x = (int) ((dimension.getWidth() - size.getWidth()) / 2);
|
|
122 |
// int y = (int) ((dimension.getHeight() - size.getHeight()) / 2);
|
|
123 |
|
|
124 |
Rectangle r = this.getGraphicsConfiguration().getBounds();
|
|
125 |
int x = (int) ((r.width - size.getWidth()) / 2) + r.x;
|
|
126 |
int y = (int) ((r.height - size.getHeight()) / 2) + r.y ;
|
|
127 |
|
107 |
128 |
this.setLocation(x, y);
|
108 |
129 |
}
|
109 |
130 |
|