mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
UI: added debug tool to test modal/non-modal dialog system (available from debug menu);
This commit is contained in:
parent
79c6626085
commit
14f90bfc77
4 changed files with 723 additions and 0 deletions
|
@ -0,0 +1,194 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
|
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Group type="102" attributes="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="buttonShowConstModal123" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowConstModal321" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="buttonShowDynModal123" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowDynModal321" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="buttonShowConstNonModal123" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowConstNonModal321" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="buttonShowDynNonModal123" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowDynNonModal321" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Component id="buttonPrintFramesList" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace min="0" pref="44" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="buttonShowConstModal123" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowConstModal321" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="buttonShowDynModal123" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowDynModal321" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="buttonShowConstNonModal123" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowConstNonModal321" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="buttonShowDynNonModal123" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonShowDynNonModal321" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="buttonPrintFramesList" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="129" max="32767" attributes="0"/>
|
||||||
|
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonCancel">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Close"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Test modal dialog system:"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowConstModal123">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="const modal 123"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstModal123ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowConstModal321">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="const modal 321"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstModal321ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowDynModal123">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="dyn modal 123"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynModal123ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowDynModal321">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="dyn modal 321"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynModal321ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Test mon modal dialog system:"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowConstNonModal123">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="const non modal 123"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstNonModal123ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowConstNonModal321">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="const non modal 321"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstNonModal321ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowDynNonModal321">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="dyn non modal 321"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynNonModal321ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonShowDynNonModal123">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="dyn non modal 123"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynNonModal123ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonPrintFramesList">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="print frames list"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPrintFramesListActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
|
@ -0,0 +1,345 @@
|
||||||
|
package mage.client.dialog;
|
||||||
|
|
||||||
|
import mage.client.MageFrame;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JayDi85
|
||||||
|
*/
|
||||||
|
public class TestModalDialog extends MageDialog {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(TestModalDialog.class);
|
||||||
|
|
||||||
|
private final TestModalSampleDialog constModalDialog1;
|
||||||
|
private final TestModalSampleDialog constModalDialog2;
|
||||||
|
private final TestModalSampleDialog constModalDialog3;
|
||||||
|
|
||||||
|
private final TestModalSampleDialog constNonModalDialog1;
|
||||||
|
private final TestModalSampleDialog constNonModalDialog2;
|
||||||
|
private final TestModalSampleDialog constNonModalDialog3;
|
||||||
|
|
||||||
|
public TestModalDialog() {
|
||||||
|
initComponents();
|
||||||
|
|
||||||
|
constModalDialog1 = new TestModalSampleDialog("const modal dialog 1", true, true, -50, -50);
|
||||||
|
constModalDialog2 = new TestModalSampleDialog("const modal dialog 2", true, true, -100, -100);
|
||||||
|
constModalDialog3 = new TestModalSampleDialog("const modal dialog 3", true, true, -150, -150);
|
||||||
|
|
||||||
|
constNonModalDialog1 = new TestModalSampleDialog("const non modal dialog 1", false, true, -50, -50);
|
||||||
|
constNonModalDialog2 = new TestModalSampleDialog("const non modal dialog 2", false, true, -100, -100);
|
||||||
|
constNonModalDialog3 = new TestModalSampleDialog("const non modal dialog 3", false, true, -150, -150);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog() {
|
||||||
|
this.setModal(false);
|
||||||
|
getRootPane().setDefaultButton(buttonCancel);
|
||||||
|
|
||||||
|
// windows settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
|
if (this.isModal()) {
|
||||||
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
|
} else {
|
||||||
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
|
}
|
||||||
|
this.makeWindowCentered();
|
||||||
|
|
||||||
|
// Close on "ESC"
|
||||||
|
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
|
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCancel() {
|
||||||
|
this.removeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showLater(TestModalSampleDialog dialog) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
logger.info(dialog.getTitle());
|
||||||
|
dialog.showDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showConstModalDialogs(boolean isReverse) {
|
||||||
|
if (isReverse) {
|
||||||
|
showLater(constModalDialog3);
|
||||||
|
showLater(constModalDialog2);
|
||||||
|
showLater(constModalDialog1);
|
||||||
|
} else {
|
||||||
|
showLater(constModalDialog1);
|
||||||
|
showLater(constModalDialog2);
|
||||||
|
showLater(constModalDialog3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showConstNonModalDialogs(boolean isReverse) {
|
||||||
|
if (isReverse) {
|
||||||
|
showLater(constNonModalDialog3);
|
||||||
|
showLater(constNonModalDialog2);
|
||||||
|
showLater(constNonModalDialog1);
|
||||||
|
} else {
|
||||||
|
showLater(constNonModalDialog1);
|
||||||
|
showLater(constNonModalDialog2);
|
||||||
|
showLater(constNonModalDialog3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDynModalDialogs(boolean isReverse) {
|
||||||
|
TestModalSampleDialog dynDialog1 = new TestModalSampleDialog("dyn modal dialog 1", true, false, -50, -50);
|
||||||
|
TestModalSampleDialog dynDialog2 = new TestModalSampleDialog("dyn modal dialog 2", true, false, -100, -100);
|
||||||
|
TestModalSampleDialog dynDialog3 = new TestModalSampleDialog("dyn modal dialog 3", true, false, -150, -150);
|
||||||
|
|
||||||
|
if (isReverse) {
|
||||||
|
showLater(dynDialog3);
|
||||||
|
showLater(dynDialog2);
|
||||||
|
showLater(dynDialog1);
|
||||||
|
} else {
|
||||||
|
showLater(dynDialog1);
|
||||||
|
showLater(dynDialog2);
|
||||||
|
showLater(dynDialog3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDynNonModalDialogs(boolean isReverse) {
|
||||||
|
TestModalSampleDialog dynDialog1 = new TestModalSampleDialog("dyn non modal dialog 1", false, false, -50, -50);
|
||||||
|
TestModalSampleDialog dynDialog2 = new TestModalSampleDialog("dyn non modal dialog 2", false, false, -100, -100);
|
||||||
|
TestModalSampleDialog dynDialog3 = new TestModalSampleDialog("dyn non modal dialog 3", false, false, -150, -150);
|
||||||
|
|
||||||
|
if (isReverse) {
|
||||||
|
showLater(dynDialog3);
|
||||||
|
showLater(dynDialog2);
|
||||||
|
showLater(dynDialog1);
|
||||||
|
} else {
|
||||||
|
showLater(dynDialog1);
|
||||||
|
showLater(dynDialog2);
|
||||||
|
showLater(dynDialog3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
* regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
buttonCancel = new javax.swing.JButton();
|
||||||
|
jLabel1 = new javax.swing.JLabel();
|
||||||
|
buttonShowConstModal123 = new javax.swing.JButton();
|
||||||
|
buttonShowConstModal321 = new javax.swing.JButton();
|
||||||
|
buttonShowDynModal123 = new javax.swing.JButton();
|
||||||
|
buttonShowDynModal321 = new javax.swing.JButton();
|
||||||
|
jLabel2 = new javax.swing.JLabel();
|
||||||
|
buttonShowConstNonModal123 = new javax.swing.JButton();
|
||||||
|
buttonShowConstNonModal321 = new javax.swing.JButton();
|
||||||
|
buttonShowDynNonModal321 = new javax.swing.JButton();
|
||||||
|
buttonShowDynNonModal123 = new javax.swing.JButton();
|
||||||
|
buttonPrintFramesList = new javax.swing.JButton();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
buttonCancel.setText("Close");
|
||||||
|
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonCancelActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jLabel1.setText("Test modal dialog system:");
|
||||||
|
|
||||||
|
buttonShowConstModal123.setText("const modal 123");
|
||||||
|
buttonShowConstModal123.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowConstModal123ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonShowConstModal321.setText("const modal 321");
|
||||||
|
buttonShowConstModal321.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowConstModal321ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonShowDynModal123.setText("dyn modal 123");
|
||||||
|
buttonShowDynModal123.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowDynModal123ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonShowDynModal321.setText("dyn modal 321");
|
||||||
|
buttonShowDynModal321.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowDynModal321ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jLabel2.setText("Test mon modal dialog system:");
|
||||||
|
|
||||||
|
buttonShowConstNonModal123.setText("const non modal 123");
|
||||||
|
buttonShowConstNonModal123.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowConstNonModal123ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonShowConstNonModal321.setText("const non modal 321");
|
||||||
|
buttonShowConstNonModal321.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowConstNonModal321ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonShowDynNonModal321.setText("dyn non modal 321");
|
||||||
|
buttonShowDynNonModal321.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowDynNonModal321ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonShowDynNonModal123.setText("dyn non modal 123");
|
||||||
|
buttonShowDynNonModal123.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonShowDynNonModal123ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonPrintFramesList.setText("print frames list");
|
||||||
|
buttonPrintFramesList.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonPrintFramesListActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
|
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jLabel1)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(buttonShowConstModal123)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buttonShowConstModal321))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(buttonShowDynModal123)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buttonShowDynModal321))
|
||||||
|
.addComponent(jLabel2)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(buttonShowConstNonModal123)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buttonShowConstNonModal321))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(buttonShowDynNonModal123)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buttonShowDynNonModal321))
|
||||||
|
.addComponent(buttonPrintFramesList))
|
||||||
|
.addGap(0, 44, Short.MAX_VALUE)))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(jLabel1)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(buttonShowConstModal123)
|
||||||
|
.addComponent(buttonShowConstModal321))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(buttonShowDynModal123)
|
||||||
|
.addComponent(buttonShowDynModal321))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jLabel2)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(buttonShowConstNonModal123)
|
||||||
|
.addComponent(buttonShowConstNonModal321))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(buttonShowDynNonModal123)
|
||||||
|
.addComponent(buttonShowDynNonModal321))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buttonPrintFramesList)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE)
|
||||||
|
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
||||||
|
onCancel();
|
||||||
|
}//GEN-LAST:event_buttonCancelActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowConstModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstModal123ActionPerformed
|
||||||
|
showConstModalDialogs(false);
|
||||||
|
}//GEN-LAST:event_buttonShowConstModal123ActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowConstModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstModal321ActionPerformed
|
||||||
|
showConstModalDialogs(true);
|
||||||
|
}//GEN-LAST:event_buttonShowConstModal321ActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowDynModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynModal123ActionPerformed
|
||||||
|
showDynModalDialogs(false);
|
||||||
|
}//GEN-LAST:event_buttonShowDynModal123ActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowDynModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynModal321ActionPerformed
|
||||||
|
showDynModalDialogs(true);
|
||||||
|
}//GEN-LAST:event_buttonShowDynModal321ActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowConstNonModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstNonModal123ActionPerformed
|
||||||
|
showConstNonModalDialogs(false);
|
||||||
|
}//GEN-LAST:event_buttonShowConstNonModal123ActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowConstNonModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstNonModal321ActionPerformed
|
||||||
|
showConstNonModalDialogs(true);
|
||||||
|
}//GEN-LAST:event_buttonShowConstNonModal321ActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowDynNonModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynNonModal321ActionPerformed
|
||||||
|
showDynNonModalDialogs(true);
|
||||||
|
}//GEN-LAST:event_buttonShowDynNonModal321ActionPerformed
|
||||||
|
|
||||||
|
private void buttonShowDynNonModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynNonModal123ActionPerformed
|
||||||
|
showDynNonModalDialogs(false);
|
||||||
|
}//GEN-LAST:event_buttonShowDynNonModal123ActionPerformed
|
||||||
|
|
||||||
|
private void buttonPrintFramesListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPrintFramesListActionPerformed
|
||||||
|
MageDialog.printFramesOrder("print");
|
||||||
|
}//GEN-LAST:event_buttonPrintFramesListActionPerformed
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JButton buttonCancel;
|
||||||
|
private javax.swing.JButton buttonPrintFramesList;
|
||||||
|
private javax.swing.JButton buttonShowConstModal123;
|
||||||
|
private javax.swing.JButton buttonShowConstModal321;
|
||||||
|
private javax.swing.JButton buttonShowConstNonModal123;
|
||||||
|
private javax.swing.JButton buttonShowConstNonModal321;
|
||||||
|
private javax.swing.JButton buttonShowDynModal123;
|
||||||
|
private javax.swing.JButton buttonShowDynModal321;
|
||||||
|
private javax.swing.JButton buttonShowDynNonModal123;
|
||||||
|
private javax.swing.JButton buttonShowDynNonModal321;
|
||||||
|
private javax.swing.JLabel jLabel1;
|
||||||
|
private javax.swing.JLabel jLabel2;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace pref="290" max="32767" attributes="0"/>
|
||||||
|
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="labelInfo" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="labelInfo" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="234" max="32767" attributes="0"/>
|
||||||
|
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JButton" name="buttonCancel">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Close"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="labelInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Sample dialog"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
|
@ -0,0 +1,119 @@
|
||||||
|
package mage.client.dialog;
|
||||||
|
|
||||||
|
import mage.client.MageFrame;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JayDi85
|
||||||
|
*/
|
||||||
|
public class TestModalSampleDialog extends MageDialog {
|
||||||
|
|
||||||
|
private final boolean useModal;
|
||||||
|
private final boolean useHideDialog;
|
||||||
|
private final int offsetX;
|
||||||
|
private final int offsetY;
|
||||||
|
|
||||||
|
public TestModalSampleDialog(String name, boolean useModal, boolean useHideDialog, int offsetX, int offsetY) {
|
||||||
|
initComponents();
|
||||||
|
|
||||||
|
this.useModal = useModal;
|
||||||
|
this.useHideDialog = useHideDialog;
|
||||||
|
this.offsetX = offsetX;
|
||||||
|
this.offsetY = offsetY;
|
||||||
|
|
||||||
|
labelInfo.setText(name);
|
||||||
|
this.setTitle(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog() {
|
||||||
|
this.setModal(useModal);
|
||||||
|
getRootPane().setDefaultButton(buttonCancel);
|
||||||
|
|
||||||
|
// windows settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
|
if (this.isModal()) {
|
||||||
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
|
} else {
|
||||||
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
|
}
|
||||||
|
this.makeWindowCentered();
|
||||||
|
Point p = this.getLocation();
|
||||||
|
p.x = p.x + offsetX;
|
||||||
|
p.y = p.y + offsetY;
|
||||||
|
this.setLocation(p);
|
||||||
|
|
||||||
|
// Close on "ESC"
|
||||||
|
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
|
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCancel() {
|
||||||
|
if (useHideDialog) {
|
||||||
|
this.hideDialog();
|
||||||
|
} else {
|
||||||
|
this.removeDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
* regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
buttonCancel = new javax.swing.JButton();
|
||||||
|
labelInfo = new javax.swing.JLabel();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
buttonCancel.setText("Close");
|
||||||
|
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonCancelActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
labelInfo.setText("Sample dialog");
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap(290, Short.MAX_VALUE)
|
||||||
|
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addContainerGap())
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(labelInfo)
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(labelInfo)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 234, Short.MAX_VALUE)
|
||||||
|
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
||||||
|
onCancel();
|
||||||
|
}//GEN-LAST:event_buttonCancelActionPerformed
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JButton buttonCancel;
|
||||||
|
private javax.swing.JLabel labelInfo;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
Loading…
Reference in a new issue