An Applet with a Scrollbar


The applet's real estate is the area within the border

Source

AnAppletWithScrollbar.java:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class AnAppletWithScrollbar extends Applet implements AdjustmentListener {
	public void init() {
		scrollbar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 0, 0, 100);
		add(scrollbar);
		scrollbar.addAdjustmentListener(this);
		textField = new TextField(3);
		textField.setEditable(false);
		add(textField);
	}

	public void adjustmentValueChanged(AdjustmentEvent e) {
		textField.setText(scrollbar.getValue()+"");
	}

	Scrollbar scrollbar;
	TextField textField;
}

Notes

Working with Scrollbar Listening to the Scrollbar

This Applet's Behavior

Things to Do

API work Playing With the Applet

Place the following applets on the same page: