Implement proper modal dialogs.
- Get root pane's parent (either JFrame or JDialog) and set it as parent. - Only set dialog visible when explicitly called
This commit is contained in:
parent
4245365b39
commit
a0ea08dfbe
@ -24,19 +24,19 @@ public class PropertyDialog extends JDialog {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PropertyDialog(PropertyEditor editor, String title, int x, int y) {
|
||||
super();
|
||||
public PropertyDialog(Window parent, PropertyEditor editor, String title, int x, int y) {
|
||||
super(parent, title, ModalityType.APPLICATION_MODAL);
|
||||
setTitle(getFrameNameFromEditor(editor));
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setLayout(new BorderLayout());
|
||||
propertyEditor = editor;
|
||||
editorComponent = editor.getCustomEditor();
|
||||
add(editorComponent, BorderLayout.CENTER);
|
||||
|
||||
pack();
|
||||
setLocation(x, y);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
protected static String getFrameNameFromEditor(PropertyEditor editor) {
|
||||
|
@ -35,8 +35,9 @@ public class PropertyPanel extends JPanel {
|
||||
}
|
||||
|
||||
public void showDialog(int initX, int initY) {
|
||||
Window parent = (Window)this.getRootPane().getParent();
|
||||
if (propertyDialog == null) {
|
||||
propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()), initX, initY);
|
||||
propertyDialog = new PropertyDialog(parent, propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()), initX, initY);
|
||||
propertyDialog.setPreferredSize(new Dimension(500, 300));
|
||||
propertyDialog.setModal(true);
|
||||
propertyDialog.setVisible(true);
|
||||
@ -67,9 +68,9 @@ public class PropertyPanel extends JPanel {
|
||||
Rectangle box = new Rectangle(i.left, i.top,
|
||||
getSize().width - i.left - i.right,
|
||||
getSize().height - i.top - i.bottom);
|
||||
/*g.clearRect(i.left, i.top,
|
||||
g.clearRect(i.left, i.top,
|
||||
getSize().width - i.right - i.left,
|
||||
getSize().height - i.bottom - i.top);*/
|
||||
getSize().height - i.bottom - i.top);
|
||||
propertyEditor.paintValue(g, box);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the property sheet panel with a changed property and also passed
|
||||
* Updates the property sheet panel with a changed property and also passes
|
||||
* the event along.
|
||||
*
|
||||
* @param evt a value of type 'PropertyChangeEvent'
|
||||
@ -169,6 +169,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
propertyTable.setDefaultRenderer(Object.class, new PropertyCellRenderer());
|
||||
propertyTable.setDefaultEditor(Object.class, new PropertyCellEditor());
|
||||
propertyTable.setRowHeight(20);
|
||||
propertyTable.setDragEnabled(false);
|
||||
propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
|
||||
|
||||
// Close any child windows at this point
|
||||
|
@ -30,7 +30,7 @@ public class BigStringEditor implements PropertyEditor {
|
||||
isFinished = false;
|
||||
BigStringEditor editor = new BigStringEditor();
|
||||
|
||||
PropertyDialog dialog = new PropertyDialog(editor, file, 50, 50);
|
||||
PropertyDialog dialog = new PropertyDialog(null, editor, file, 50, 50);
|
||||
|
||||
while (isFinished == false) {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user