• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Displaying selected numbers (buttons) into a label.

Writing a routine that displays selected numbers from buttons. How do I display the picked numbers (using a label) from numerical buttons being pushed. I am successful using a Text Field but wanted to use a label instead.
0
Carson60
Asked:
Carson60
3 Solutions
 
CEHJCommented:
You need to do

label.setText(label.getText() + button.getActionCommand());
0
 
Nguyen Huu PhuocSenior ManagerCommented:
I donot think so.
To me, it should be
label.setText(e.getActionCommand());
And e is ActionEvent passed to actionPerformed event of button.
Take example, if I have a label named jLable1 and a button named jButton1. The code is:
  void jButton1_actionPerformed(ActionEvent e)
  {
    jLabel1.setText(e.getActionCommand());
  }
0
 
objectsCommented:
> I am successful using a Text Field but wanted to use a label instead.

you should just be able to change the code that updates the text field to update the label
and then call revalidate() on the panel containing your label
 

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now