Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Don't create new labels, reuse the existing ones.
If you don't understand my answer, don't ignore it, ask a question.
if i wanted to use correctLabel how would the code be written?
im not too sure.. any examples?
Can you make and post a SMALL, simple program that compiles, executes and shows the problem?
If you don't understand my answer, don't ignore it, ask a question.
u can see the problem, i just need help with that one line of code.
What one line of code? Please post the line of code that you are asking about.
If you don't understand my answer, don't ignore it, ask a question.
footer.add(new JLabel(butClicked.getText()));
Last edited by newtolearningjava; April 26th, 2014 at 06:01 PM.
The fix for that statement is to remove it:so that it does NOT add a new JLabel.// footer.add(new JLabel(buttonClicked.getText()));
If you don't understand my answer, don't ignore it, ask a question.
nn nm
Last edited by newtolearningjava; April 26th, 2014 at 06:01 PM.
Then use the variable: correctLabel to show the results. Don't create a new JLabel.
If you don't understand my answer, don't ignore it, ask a question.
i have done
but this only prints one value and then the next how do i get it to be 1 2 3 4
Last edited by newtolearningjava; April 26th, 2014 at 06:01 PM.
An example of what?
Here's how to set the value of correctLabel from the value in buttonClicked:If you need more: make and post a SMALL, simple program that compiles, executes and shows the problem?correctLabel.setText(buttonClicked.getText());
If you don't understand my answer, don't ignore it, ask a question.
please see post#36
Then see posts #29 and end of #37
If you don't understand my answer, don't ignore it, ask a question.
lol ur funny one aint ya.
Are you asking how to concatenate a new String to the end of the String currently being shown?
If you don't understand my answer, don't ignore it, ask a question.
yes
Use the String concatenation operator:String x = "1"; // define x and give it a value of "1" x = x + "2"; // now x has value of "12"
If you don't understand my answer, don't ignore it, ask a question.
dont worry your on a different topic to me all i was is the code to disaplay 1 2 3 4 not 1 then 2 then 3
Use concatenation so the display will be:
1
then
12
then
123
then
1234
etc
If you don't understand my answer, don't ignore it, ask a question.
but i need the values from from the buttonClicked what is in post#43
Last edited by newtolearningjava; April 26th, 2014 at 06:02 PM.
Something like this:
get value from buttonClicked into x
get value from label??? into y
concatenate x to end of y: y = y + x
set value for label??? from new value of y
If you don't understand my answer, don't ignore it, ask a question.
im not sure i am confused, before i changed the code from
footer.add(new JLabel(buttonClicked.getText()));
to
correctLabel.setText(buttonClicked.getText());
the label was showing 1 2 3 4 5
What is the variable name of "the label" that you are talking about?the label was showing 1 2 3 4 5
I thought that was what you wanted in the label.
Without a small, complete program that compiles, executes and shows the problem, this is getting to be a waste of time.
If you don't understand my answer, don't ignore it, ask a question.
"correctLabel"