Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes design for Indicator Light panel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "design for Indicator Light panel" Watch "design for Indicator Light panel" New topic
Author

design for Indicator Light panel

John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
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

Joined: Jun 09, 2003
Posts: 4632
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: design for Indicator Light panel