[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • 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
 
phuocnhCommented:
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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