• 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

update JLabel and JTextArea in background thread

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For some complicated components like JTable or JList, I understand that I have to follow the MVC pattern to first update the data in model in order to have change effective.
But for those simply components like JLabel and JTextArea, is there any model behind? or do necessary to follow the same routine like JTable? Can I just update the content (the text property) in a background thread? Please advise?
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to change your name to fit the Naming policy (first and last name).
As for your question, JLabel doesn't use one so you can just setText("whatever"). JTextArea also behaves the same way, but it has more options for things like line wrapping and columns. Just go look it up in the Java docs and look at Sun's tutorial here.
Technically, you could say that the String you setwith setText is the model and the TextArea is the controller and viewer.
Hope this helps
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chris!

Actually for all the things that inherit from JTextComponent (like JTextArea) the Model is called the Document, so they really do have a Model... The only Swing components I can think of that aren't pure MVC are JLabel (like you mentioned), JSeparator, and those components that are made just to hold other components, like JPanel, JFrame, etc.
 
reply
    Bookmark Topic Watch Topic
  • New Topic