Displaying selected numbers (buttons) into a label.

Posted on 2006-05-21
Last Modified: 2010-03-31
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.
Question by:Carson60
    LVL 86

    Accepted Solution

    You need to do

    label.setText(label.getText() + button.getActionCommand());
    LVL 6

    Assisted Solution

    I donot think so.
    To me, it should be
    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)
    LVL 92

    Assisted Solution

    > 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


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now