Total members 11889 |It is currently Fri Mar 29, 2024 7:41 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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.




Author:
Newbie
User avatar Posts: 3
Have thanks: 0 time

Wow :D , thanks for posting this

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

Thanks for this good topic

_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 109
Have thanks: 5 time
Post new topic Reply to topic  [ 3 posts ] 

  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?!!     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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