Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Why doesn't JButton text change?
Robert Paris
Ranch Hand
Posts: 585
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I changed the text on my JButton and it doesn't change on the screen. I tried:
myButton.setText( "new text" );
and
myButton.setText( "new text" ); myButton.revalidate(); myButton.repaint();
myButton.setText( "new text" ); SwingUtilities.updateComponentTreeUI( myButton );
None of this works! What am I doing wrong?
Joe Ess
Bartender
Posts: 9626
16
I like...
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
JButton.setText() works for me. My wild guess would be that you have one instance of JButton that you add to the GUI and you create a second one somewhere that you are calling setText() on.
[
How To Ask Questions On JavaRanch
]
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Can't get an ActionListener to change a JLabel text
NullPointerException received trying to change the button label
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI
Processing different ActionEvents in actionPerformed()
AWT-EventQueue-0" - need Help
More...