Java Programming - jLabel Question?
-
Hey guys- So in my program, I have a button that generates random numbers. When the generate button is pressed (by the user), I want one of the labels to update with the random number it generated. I am using a NetBeans Desktop Application. I know that jLabels have a .SetText property, but I can't even find the variable name that I named the label, in my class for the random numbers. How would I change the text after the user clicks the button? It looks like the labels were created in a class called GameView, and I am trying to reference them in another class called RNG. They were declared Private (automagically), and you cannot change this code. Help!
-
Answer:
You need to use an action listener with the button and add the code for changing the text in the label there. Since you posted no code and I don't know what your GameView class contains, that is the best advice I can give. http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html
Yahoo! Answers Visit the source
Other answers
You need to use an action listener with the button and add the code for changing the text in the label there. Since you posted no code and I don't know what your GameView class contains, that is the best advice I can give. http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html
Related Q & A:
- How to start programming a game in java?Best solution by Game Development
- How to Convert a Procedural Programming into Object-Oriented Programming?Best solution by Stack Overflow
- Computer Science Java Programming?Best solution by AllExperts
- Is java or visual basic a machine level, low level, high level or binary level programming language?Best solution by Quora
- Help on Lisp programming question.Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.