summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java8
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java28
2 files changed, 26 insertions, 10 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
index f564c07a..1d5a2cf4 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
@@ -38,9 +38,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.CellRendererPane;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
@@ -51,7 +48,6 @@ import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
-import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
@@ -1064,7 +1060,9 @@ public class BKUGUIImpl implements BKUGUIFacade {
@Override
public char[] getPin() {
if (pinField != null) {
- return pinField.getPassword();
+ char[] pin = pinField.getPassword();
+ pinField = null;
+ return pin;
}
return null;
}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
index 2054ae86..87b636f0 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
/**
@@ -30,9 +31,10 @@ import javax.swing.text.PlainDocument;
*/
class PINDocument extends PlainDocument {
- private PINSpec pinSpec;
- private Pattern pinPattern;
- private JButton enterButton;
+ protected PINSpec pinSpec;
+ protected Pattern pinPattern;
+ protected JButton enterButton;
+ protected Document compareTo;
public PINDocument(PINSpec pinSpec, JButton enterButton) {
this.pinSpec = pinSpec;
@@ -44,6 +46,11 @@ class PINDocument extends PlainDocument {
this.enterButton = enterButton;
}
+ public PINDocument(PINSpec pinSpec, JButton enterButton, Document compareTo) {
+ this(pinSpec, enterButton);
+ this.compareTo = compareTo;
+ }
+
@Override
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
if (pinSpec.getMaxLength() < 0 || pinSpec.getMaxLength() >= (getLength() + str.length())) {
@@ -58,12 +65,23 @@ class PINDocument extends PlainDocument {
super.insertString(offs, str, a);
}
}
- enterButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ if (enterButton != null) {
+ enterButton.setEnabled(getLength() >= pinSpec.getMinLength() && compare());
+ }
}
@Override
public void remove(int offs, int len) throws BadLocationException {
super.remove(offs, len);
- enterButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ if (enterButton != null) {
+ enterButton.setEnabled(getLength() >= pinSpec.getMinLength() && compare());
+ }
+ }
+
+ private boolean compare() throws BadLocationException {
+ if (compareTo == null) {
+ return true;
+ }
+ return compareTo.getText(0, compareTo.getLength()).equals(getText(0, getLength()));
}
} \ No newline at end of file