• 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

Status Bar Design Help

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems like a status bar is a pretty common component of a swing GUI so hopefully the community has some advice.

I am wondering what the best way is to design a standard status bar in a swing gui. I am looking at two options

1. Provide a static interface to a swing component to add text to it. The con with this is that every component that wants to send a status message has to send the message to the status pane directly.

2. Use some sort of event/listener design. I.E. swing component just listens for an event (I have no idea what type of event). When it receives that event it posts the status message contained within that event. All other components just fire off these events every time they want to send a status message.

#2 seems like the best answer to me but I am having trouble wrapping my head around it. I.E. what messages do I send/listen to. Is there already messages in the Java API that will work with this design. Seems like this has been done a thousand times before so hopefully someone can shed some light on this design for me.

Thanks in advance,
Billy
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Billy,

Using an event/listener design is a pretty typical way to do this. You can have a Status object that has the current status. Status will be Observable and anyone with a reference to the Status object can publish a message, and clients and listen. It might look something like



The StatusMessage class can have whatever you need, for example,



One of the status listeners can be the UI and it updates itself when it receives a new status message. Ideally you won't have too many status publishers (I'm assuming most of the status can be updated from with the model if you're using model-view-controller) so you won't have to pass too many references around.

Jeff
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Billy,

I got your private message but it says you are not accepting replies right now, so could you either repost out here or allow for private messages?

thanks,
Jeff
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Storey wrote:so could you either repost out here or allow for private messages?


Billy, please Use The Forum, Not Email when talking about threads and posts. That includes PMs.
reply
    Bookmark Topic Watch Topic
  • New Topic