Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel not updating its text dynamically  RSS feed

 
Satish Chinthanippu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi can anyone tell me why JLabel setText method is not setting up the text dynamically even though i am calling repaint() once i set the text?

Code snippet is below

Locale currentLocale = new Locale(panel.getCountryLocal(), panel.getCountry());
ResourceBundle messages = ResourceBundle.getBundle(Constants.messageBundle, currentLocale);
messages = Panel.getMessages();
String displayString = messages.getString("101022");

int btnWidth = SwingUtil.getPercent((int) dim.getWidth(), 10);
int btnHeight = SwingUtil.getPercent((int) dim.getHeight(),99);

Button buttonOK = new Button();
buttonOK.setPreferredSize(new Dimension(200, 400));

buttonOK.setText(displayString);

JLabel welcomeString = new JLabel(displayString);

repaint();
 
Campbell Ritchie
Sheriff
Posts: 55315
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you changing the text on a button? That will make for a very peculiar look'n'feel.
You are not changing the text on any labels. You seem to create a new label but you haven't shown us anywhere that you use that label.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!