Make your own free website on Tripod.com
WEB/420 Team C

JavaBeans

Home
JavaScript vs. VBScript
JavaScript
VBScript
Perl vs. Java
Perl
Java
Active X vs. JavaBeans
Active X
JavaBeans
Multiple Choice Quiz
References

Under construction

©WEB/420 Team C 2004 - All rights reserved

Source code for the example

/* 
 * DKnob example
 * (c) 2000, Joakim Eriksson, 
 * Instructions at:  
 * http://www.dreamfabric.com/java/knob/knob.html
 * Please e-mail joakim@dreamfabric.com for comments or
 * questions.
 */

import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;

public class TestKnob extends Applet
{
	public void start() {
	    DKnob knob;
	    JLabel jl;

	    setLayout(new BorderLayout());	    
	    JPanel jp = new JPanel(new BorderLayout());
	    jp.add(knob = new DKnob(), BorderLayout.CENTER);
	    jp.add(jl = new JLabel("Value: 0"), BorderLayout.NORTH);
	    add(jp, BorderLayout.CENTER);
	    final JLabel jla = jl;

	    // Add a change listener to the knob
	    knob.addChangeListener(new ChangeListener() {
		    public void stateChanged(ChangeEvent e) {
			DKnob t = (DKnob) e.getSource();
			jla.setText("Value: " + 
				    ((int)(100 * t.getValue()))/100.0 );
		    }
		});
	}
}