Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

design for Indicator Light panel

 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help designing an indicator light panel. I envision a set of vertically arranged JLabels with associated indicator components.
The idea is that when this Swing GUI is run, the indicator component is lit up or changes color based on code that I will supply which will be running in a timed loop checking on the health of processes running in another environment.
I need help with:

1. selecting a component from whats available. I envision a circle which is colored in RED or GREEN.

2. How to write a "listener" for the indicator which will change the indicator color based on results of the timed process checker running underneath.

3. How to set the timed process checker code running.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
start by creating a light panel which extends JPanel.
set its preferred size to be a square 50x50,100x100, whatever.
it has a default color of grey - to indicate off.
in the constructor, pass it another color to indicate on - red or amber or green.
in its paintComponent you set the color to on or off and use fillOval(from 0,0, to width,height).

now create a holding panel set as a gridlayout(3 rows, 1 column).
to the holding panel you add 3 x lightPanel.

add a timer to set one of the panels to on, the other 2 to off, then repaint them all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic