package support;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class PinPad extends javax.swing.JPanel implements ActionListener{
{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}
private JPanel jPanel1;
private JButton jB_PINReset;
private JLabel jLabelPIN;
private JTextField jTF_PIN;
private JButton jB_PINOK;
private JButton jB_PIN0;
private JButton jB_PIN9;
private JButton jB_PIN8;
private JButton jB_PIN7;
private JButton jB_PIN6;
private JButton jB_PIN5;
private JButton jB_PIN4;
private JButton jB_PIN3;
private JButton jB_PIN2;
private JButton jB_PIN1;
private JPanel jPanel3;
private JPanel jPanel2;
public PinPad() {
super();
initGUI();
this.addActionListener(this);
}
private void initGUI() {
try {
BorderLayout thisLayout = new BorderLayout();
this.setLayout(thisLayout);
this.setPreferredSize(new java.awt.Dimension(400, 321));
{
jPanel1 = new JPanel();
this.add(jPanel1, BorderLayout.NORTH);
{
jLabelPIN = new JLabel();
jPanel1.add(jLabelPIN);
jLabelPIN.setText("Geben Sie die PIN hier ein");
}
}
{
jPanel2 = new JPanel();
this.add(jPanel2, BorderLayout.SOUTH);
jPanel2.setPreferredSize(new java.awt.Dimension(400, 41));
{
jTF_PIN = new JTextField(4);
jPanel2.add(jTF_PIN);
jTF_PIN.setPreferredSize(new java.awt.Dimension(180, 20));
}
}
{
jPanel3 = new JPanel();
GridBagLayout jPanel3Layout = new GridBagLayout();
jPanel3Layout.columnWidths = new int[] {7, 60, 60, 60, 7};
jPanel3Layout.rowHeights = new int[] {60, 60, 60, 60};
jPanel3Layout.columnWeights = new double[] {0.1, 0.0, 0.0, 0.0, 0.1};
jPanel3Layout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0};
this.add(jPanel3, BorderLayout.CENTER);
jPanel3.setLayout(jPanel3Layout);
{
jB_PIN1 = new JButton();
jPanel3.add(jB_PIN1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN1.setText("1");
jB_PIN1.setActionCommand("PIN1");
}
{
jB_PIN2 = new JButton();
jPanel3.add(jB_PIN2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN2.setText("2");
jB_PIN2.setActionCommand("PIN2");
}
{
jB_PIN3 = new JButton();
jPanel3.add(jB_PIN3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN3.setText("3");
jB_PIN3.setActionCommand("PIN3");
}
{
jB_PIN4 = new JButton();
jPanel3.add(jB_PIN4, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN4.setText("4");
jB_PIN4.setActionCommand("PIN4");
}
{
jB_PIN5 = new JButton();
jPanel3.add(jB_PIN5, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN5.setText("5");
jB_PIN5.setActionCommand("PIN");
}
{
jB_PIN6 = new JButton();
jPanel3.add(jB_PIN6, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN6.setText("6");
jB_PIN6.setActionCommand("PIN6");
}
{
jB_PIN7 = new JButton();
jPanel3.add(jB_PIN7, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN7.setText("7");
jB_PIN7.setActionCommand("PIN7");
}
{
jB_PIN8 = new JButton();
jPanel3.add(jB_PIN8, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN8.setText("8");
jB_PIN8.setActionCommand("PIN8");
}
{
jB_PIN9 = new JButton();
jPanel3.add(jB_PIN9, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN9.setText("9");
jB_PIN9.setActionCommand("PIN9");
}
{
jB_PIN0 = new JButton();
jPanel3.add(jB_PIN0, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PIN0.setActionCommand("PIN0");
jB_PIN0.setText("0");
}
{
jB_PINReset = new JButton();
jPanel3.add(jB_PINReset, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PINReset.setText("Reset");
jB_PINReset.setActionCommand("PINReset");
}
{
jB_PINOK = new JButton();
jPanel3.add(jB_PINOK, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jB_PINOK.setText("OK");
jB_PINOK.setActionCommand("PINOK");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void addActionListener(ActionListener l)
{
jB_PIN0.addActionListener(this);
jB_PIN1.addActionListener(this);
jB_PIN2.addActionListener(this);
jB_PIN3.addActionListener(this);
jB_PIN4.addActionListener(this);
jB_PIN5.addActionListener(this);
jB_PIN6.addActionListener(this);
jB_PIN7.addActionListener(this);
jB_PIN8.addActionListener(this);
jB_PIN9.addActionListener(this);
jB_PINReset.addActionListener(this);
jB_PINOK.addActionListener(this);
}
public void addFocusListener(FocusListener l)
{
}
public void appendPIN(int ziffer)
{
if (jTF_PIN.getText() == ""){
jTF_PIN.setText(Integer.toString(ziffer));
}
if (jTF_PIN.getText() != ""){
jTF_PIN.setText(jTF_PIN.getText()+Integer.toString(ziffer));
}
}
public void actionPerformed(ActionEvent l) {
// TODO Auto-generated method stub
if (l.getActionCommand() == "PIN0")
{
System.out.println("PIN0");
}
}
}