Manage {config} token in -setp option
This commit is contained in:
@@ -1046,12 +1046,12 @@
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace pref="15" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="7" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="panelExpert" max="32767" attributes="0"/>
|
||||
<Component id="devicesPanel" pref="232" max="32767" attributes="0"/>
|
||||
<Component id="devicesPanel" pref="242" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace pref="7" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -1088,7 +1088,7 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="checkExpert" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" pref="19" max="32767" attributes="0"/>
|
||||
<EmptySpace type="separate" pref="26" max="32767" attributes="0"/>
|
||||
<Component id="buttonExpertCommands" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="buttonRecovery" min="-2" max="-2" attributes="0"/>
|
||||
|
||||
@@ -695,18 +695,18 @@ public class MainPanel extends Panel {
|
||||
panelHexiposiLayout.setHorizontalGroup(
|
||||
panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelHexiposiLayout.createSequentialGroup()
|
||||
.addContainerGap(13, Short.MAX_VALUE)
|
||||
.addContainerGap(9, Short.MAX_VALUE)
|
||||
.addGroup(panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
||||
.addComponent(buttonDetectCover)
|
||||
.addComponent(hexiposiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(14, Short.MAX_VALUE))
|
||||
.addContainerGap(9, Short.MAX_VALUE))
|
||||
);
|
||||
panelHexiposiLayout.setVerticalGroup(
|
||||
panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelHexiposiLayout.createSequentialGroup()
|
||||
.addContainerGap(15, Short.MAX_VALUE)
|
||||
.addContainerGap(14, Short.MAX_VALUE)
|
||||
.addComponent(hexiposiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
|
||||
.addComponent(buttonDetectCover)
|
||||
.addContainerGap())
|
||||
);
|
||||
@@ -733,11 +733,11 @@ public class MainPanel extends Panel {
|
||||
panelViewTypeLayout.setHorizontalGroup(
|
||||
panelViewTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelViewTypeLayout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap(8, Short.MAX_VALUE)
|
||||
.addGroup(panelViewTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
||||
.addComponent(buttonDrawing)
|
||||
.addComponent(buttonCamera))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(8, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
panelViewTypeLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCamera, buttonDrawing});
|
||||
@@ -808,7 +808,7 @@ public class MainPanel extends Panel {
|
||||
.addGap(4, 4, 4)
|
||||
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jSeparator2)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)))
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, Short.MAX_VALUE)))
|
||||
.addGroup(jPanel3Layout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
@@ -996,7 +996,7 @@ public class MainPanel extends Panel {
|
||||
.addGroup(panelSystemStatusLayout.createSequentialGroup()
|
||||
.addComponent(buttonRelease)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addComponent(filler1, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE))
|
||||
.addComponent(filler1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGap(4, 4, 4))
|
||||
);
|
||||
|
||||
@@ -1196,7 +1196,7 @@ public class MainPanel extends Panel {
|
||||
.addGroup(panelExpertLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(checkExpert)
|
||||
.addGap(18, 18, Short.MAX_VALUE)
|
||||
.addGap(18, 26, Short.MAX_VALUE)
|
||||
.addComponent(buttonExpertCommands)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(buttonRecovery)
|
||||
@@ -1216,18 +1216,18 @@ public class MainPanel extends Panel {
|
||||
.addGroup(panelDevicesLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(devicesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(panelExpert, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(13, Short.MAX_VALUE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
panelDevicesLayout.setVerticalGroup(
|
||||
panelDevicesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelDevicesLayout.createSequentialGroup()
|
||||
.addContainerGap(14, Short.MAX_VALUE)
|
||||
.addContainerGap(7, Short.MAX_VALUE)
|
||||
.addGroup(panelDevicesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(panelExpert, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(devicesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
.addComponent(devicesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE))
|
||||
.addContainerGap(7, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout panelRightLayout = new javax.swing.GroupLayout(panelRight);
|
||||
@@ -1237,16 +1237,16 @@ public class MainPanel extends Panel {
|
||||
.addGroup(panelRightLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addGroup(panelRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(panelDetail, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
|
||||
.addComponent(panelDetail, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)
|
||||
.addComponent(panelDisplayMode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(panelDevices, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE))
|
||||
.addComponent(panelDevices, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE))
|
||||
.addGap(0, 0, 0))
|
||||
);
|
||||
panelRightLayout.setVerticalGroup(
|
||||
panelRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelRightLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(panelDetail, javax.swing.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE)
|
||||
.addComponent(panelDetail, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(panelDevices, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
@@ -1417,7 +1417,7 @@ public class MainPanel extends Panel {
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(panelTop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(panelBottom, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
|
||||
.addComponent(panelBottom, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
|
||||
.addGap(1, 1, 1))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
@@ -1480,6 +1480,16 @@ public class MainPanel extends Panel {
|
||||
|
||||
|
||||
private void checkExpertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkExpertActionPerformed
|
||||
if (checkExpert.isSelected()){
|
||||
PasswordDialog dlg = new PasswordDialog(getTopLevel(), true, 1234);
|
||||
dlg.setResizable(false);
|
||||
dlg.setLocationRelativeTo(getTopLevel());
|
||||
dlg.setVisible(true);
|
||||
if (dlg.getResult() == false){
|
||||
checkExpert.setSelected(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setExpertMode(checkExpert.isSelected());
|
||||
}//GEN-LAST:event_checkExpertActionPerformed
|
||||
|
||||
|
||||
157
src/main/java/ch/psi/mxsc/PasswordDialog.form
Normal file
157
src/main/java/ch/psi/mxsc/PasswordDialog.form
Normal file
@@ -0,0 +1,157 @@
|
||||
<?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="32767" attributes="0"/>
|
||||
<Component id="button1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="button2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="button3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="button4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="button5" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="textPassword" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="buttonClear" min="-2" pref="87" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="9" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="buttonCancel" linkSize="1" min="-2" pref="120" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="buttonOk" linkSize="1" min="-2" pref="120" 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 min="-2" pref="40" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="2" attributes="0">
|
||||
<Component id="button2" alignment="2" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<Component id="button1" alignment="2" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<Component id="button3" alignment="2" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<Component id="button4" alignment="2" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<Component id="button5" alignment="2" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="44" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="2" attributes="0">
|
||||
<Component id="buttonClear" alignment="2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="textPassword" alignment="2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="35" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="buttonOk" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="button2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="X or Y"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="button2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="button1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="X or Y"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="button1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="button3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="X or Y"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="button3ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="button4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="X or Y"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="button4ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="button5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="X or Y"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="button5ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonCancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonOk">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOkActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonClear">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Clear"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonClearActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JPasswordField" name="textPassword">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Lucida Grande" size="24" style="0"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
282
src/main/java/ch/psi/mxsc/PasswordDialog.java
Normal file
282
src/main/java/ch/psi/mxsc/PasswordDialog.java
Normal file
@@ -0,0 +1,282 @@
|
||||
package ch.psi.mxsc;
|
||||
|
||||
|
||||
import ch.psi.utils.swing.StandardDialog;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PasswordDialog extends StandardDialog {
|
||||
final List numbers;
|
||||
final long secret;
|
||||
|
||||
public PasswordDialog(java.awt.Frame parent, boolean modal, long secret) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
numbers = Arrays.asList(0,1,2,3,4,5,6,7,8,9);
|
||||
this.secret = secret;
|
||||
Collections.shuffle(numbers);
|
||||
setTitle("Password");
|
||||
|
||||
button1.setText(numbers.get(0) + " or " + numbers.get(1));
|
||||
button2.setText(numbers.get(2) + " or " + numbers.get(3));
|
||||
button3.setText(numbers.get(4) + " or " + numbers.get(5));
|
||||
button4.setText(numbers.get(6) + " or " + numbers.get(7));
|
||||
button5.setText(numbers.get(8) + " or " + numbers.get(9));
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean checkPassword(){
|
||||
char[] password = textPassword.getPassword();
|
||||
int length = password.length;
|
||||
String pass = String.valueOf(secret);
|
||||
if ((length==0) || (length != pass.length())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i=0; i<length; i++){
|
||||
char c = password[i];
|
||||
int digit = Integer.valueOf(pass.substring(i, i+1));
|
||||
int index = c - '0';
|
||||
if ((!numbers.get(index*2).equals(digit)) && (!numbers.get(index*2+1).equals(digit))){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
button2 = new javax.swing.JButton();
|
||||
button1 = new javax.swing.JButton();
|
||||
button3 = new javax.swing.JButton();
|
||||
button4 = new javax.swing.JButton();
|
||||
button5 = new javax.swing.JButton();
|
||||
buttonCancel = new javax.swing.JButton();
|
||||
buttonOk = new javax.swing.JButton();
|
||||
buttonClear = new javax.swing.JButton();
|
||||
textPassword = new javax.swing.JPasswordField();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
button2.setText("X or Y");
|
||||
button2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
button2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
button1.setText("X or Y");
|
||||
button1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
button1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
button3.setText("X or Y");
|
||||
button3.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
button3ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
button4.setText("X or Y");
|
||||
button4.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
button4ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
button5.setText("X or Y");
|
||||
button5.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
button5ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonCancel.setText("Cancel");
|
||||
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonOk.setText("Ok");
|
||||
buttonOk.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonOkActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonClear.setText("Clear");
|
||||
buttonClear.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonClearActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
textPassword.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
|
||||
textPassword.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
|
||||
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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(button1)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(button2)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(button3)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(button4)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(button5))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(textPassword)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(buttonClear, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(9, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonOk, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCancel, buttonOk});
|
||||
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(40, 40, 40)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
||||
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(44, 44, 44)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
||||
.addComponent(buttonClear)
|
||||
.addComponent(textPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonOk)
|
||||
.addComponent(buttonCancel))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
|
||||
textPassword.setText("");
|
||||
}//GEN-LAST:event_buttonClearActionPerformed
|
||||
|
||||
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
||||
cancel();
|
||||
}//GEN-LAST:event_buttonCancelActionPerformed
|
||||
|
||||
private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
|
||||
if (!checkPassword()){
|
||||
SwingUtils.showMessage(this, "Error", "Invalid password");
|
||||
buttonClearActionPerformed(null);
|
||||
return;
|
||||
}
|
||||
accept();
|
||||
}//GEN-LAST:event_buttonOkActionPerformed
|
||||
|
||||
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed
|
||||
textPassword.setText(textPassword.getText() + "0");
|
||||
}//GEN-LAST:event_button1ActionPerformed
|
||||
|
||||
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button2ActionPerformed
|
||||
textPassword.setText(textPassword.getText() + "1");
|
||||
}//GEN-LAST:event_button2ActionPerformed
|
||||
|
||||
private void button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button3ActionPerformed
|
||||
textPassword.setText(textPassword.getText() + "2");
|
||||
}//GEN-LAST:event_button3ActionPerformed
|
||||
|
||||
private void button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button4ActionPerformed
|
||||
textPassword.setText(textPassword.getText() + "3");
|
||||
}//GEN-LAST:event_button4ActionPerformed
|
||||
|
||||
private void button5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button5ActionPerformed
|
||||
textPassword.setText(textPassword.getText() + "4");
|
||||
}//GEN-LAST:event_button5ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(PasswordDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(PasswordDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(PasswordDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(PasswordDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
PasswordDialog dialog = new PasswordDialog(new javax.swing.JFrame(), true, 1234);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton button1;
|
||||
private javax.swing.JButton button2;
|
||||
private javax.swing.JButton button3;
|
||||
private javax.swing.JButton button4;
|
||||
private javax.swing.JButton button5;
|
||||
private javax.swing.JButton buttonCancel;
|
||||
private javax.swing.JButton buttonClear;
|
||||
private javax.swing.JButton buttonOk;
|
||||
private javax.swing.JPasswordField textPassword;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user