Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

old NASA style counter built from Swing components

Sun Jun 17, 2007 4:49 am

Here's an old NASA style counter widget I built using Swing. You guys can modify this code to make a progress meter out of it if you'd like.



There's three files to this eclipse project. Here's the first file:

java code
package lgfOldStyleCounter;

import java.awt.Color;
import java.awt.Dimension;
import javax.swing.*;

/*
* NOTE: this counter only goes up to 99,999 and no higher
*/
public class OldStyleCounter {
Dimension size;
Counter c;

public void updateValue( int i){ c.updateValue(i); }

public OldStyleCounter() {

JFrame.setDefaultLookAndFeelDecorated(false);

JFrame frame = new JFrame("OldStyleCounter Test");
size = new Dimension( 450, 190 );
frame.setSize(size);
frame.setMaximumSize(size);
frame.setMinimumSize(size);
frame.setPreferredSize(size);
frame.setLocation( 100,100 );
frame.setLayout(null);
c = new Counter();
frame.add(c);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBackground(Color.black);
frame.setVisible(true);
} // close constructor

public static void main(String[] args) {
OldStyleCounter o = new OldStyleCounter();

for( int i = 1; i 0 ) displayZero = true;
element1.paintYourself( g, tenthousands, displayZero );

int temp = value - ( tenthousands * 10000 ); // temp holds a,bcd
thousands = temp / 1000;
if ( thousands > 0 ) displayZero = true;
element2.paintYourself( g, thousands, displayZero );

temp = temp - ( thousands * 1000 ); // temp holds 0,bcd
hundreds = temp / 100;
if( hundreds > 0 ) displayZero = true;
element3.paintYourself( g, hundreds, displayZero );

temp = temp - ( hundreds * 100) ; // temp holds 0,0cd
tens = temp / 10;

if( tens > 0 ) displayZero = true;
element4.paintYourself( g, tens, displayZero );

temp = temp - ( tens * 10); // temp holds 0,00d
ones = temp;
displayZero = true;
element5.paintYourself(g, ones, displayZero);

g.setColor(oldColor);
}

public void run() {
int oldValue = 32768;
while( true) {
//System.out.println("running");
try {
Thread.sleep(500);
}
catch( InterruptedException ie) { /**/ }
if ( oldValue != value ) {
repaint();
oldValue = value;
}
} // close while
}
} // close class Counter


All this code is in the public domain so you can do what you'd like with it.



Re: old NASA style counter built from Swing components

Sun Jun 17, 2007 7:42 am

Wow :D , thanks for posting this

Re: old NASA style counter built from Swing components

Sun Jun 17, 2007 10:56 pm

Thanks for this good topic

Post a reply
  Related Posts  to : old NASA style counter built from Swing components
 an ammeter ( round gauge ) sortof widget built using Swing     -  
 java Color Components     -  
 Listing elements using list components in J2me     -  
 jsp page counter     -  
 reset the list counter     -  
 Writing a Counter to any PORT     -  
 File page counter in php     -  
 Use cookie to create page counter     -  
 Use cookie to create page counter     -  
 What is Swing?!!     -