JPasswordField and JButton Problem

Happy New Year to all of you guys and gals. Here's the problem

I have a String Array of buttons made already .. The design and measuring of the buttons are similar to a regular calculator.

Now depending on the button that I press I set the text of the JPasswordField to "whatever", which is wrong because it's not being appended. So there has to be another way to do this.

Take a calculator or bank for example. You press one button, it shows, and press the same button, so you have two digits appear on screen. That's exactly what I'm looking for. But I'm stuck...

Here's the code to create the buttons

for (int i = 0; i < 13; i++)

{

button = new JButton(Buttons);

button.addActionListener(this);

button.setFont(new Font("Comic Sans MS", Font.BOLD, 12));

button.setSize(50, 30);

button.setLocation(x, y);

button.setBackground(Color.darkGray);

button.setForeground(Color.white);

button.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.black, Color.lightGray));

theKeysP.add(button);

x = x + 50;

if((i + 1) % 4 == 0)

{

x = 210;

y = y + 30;

}

if(i == 12)

{

button.setLocation(410, 65);

button.setBackground(Color.green);

button.setForeground(Color.black);

}

}

Lets say starting from button 0 to 5 are numbers starting from 1 - 6

Since I'm clicking on the button it's an ActionEvent,

so If(e.getSource() == button[0])

{

PF.setText("1"); //Wrong because it's not being appended. Therefore it resets everytime button[0] is clicked.

}

I hope this I made clear enough. Can anyone provide suggestions for this problem.

[1853 byte] By [JavaStrider42a] at [2007-11-26 13:50:42]
# 1
Try doing it this way insteadpassword.setText( password.getText() + "1" );Next time please use the code tags when postingICE
icewalker2ga at 2007-7-8 1:27:37 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thank You Very Much ICE =)
JavaStrider42a at 2007-7-8 1:27:37 > top of Java-index,Desktop,Core GUI APIs...