Sun Jun 17, 2007 4:49 am
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
Sun Jun 17, 2007 7:42 am
Sun Jun 17, 2007 10:56 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.