Adjustment Event

import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.*;

public class AdjustmentListenerDemo extends JFrame implements
		AdjustmentListener {
	JPanel p1;
	JTextArea ta;
	JScrollPane sp;

	public AdjustmentListenerDemo() {
		super("My window");
		setSize(500, 500);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		p1 = new JPanel();
		getContentPane().add(p1);
		ta = new JTextArea(10, 20);
		sp = new JScrollPane(ta);
		p1.add(sp);
		sp.getHorizontalScrollBar().addAdjustmentListener(this);
		sp.getVerticalScrollBar().addAdjustmentListener(this);
		setVisible(true);

	}

	@Override
	public void adjustmentValueChanged(AdjustmentEvent e) {
		setTitle("" + e.getValue());
		System.out.println("Adjustment event");

	}

	public static void main(String[] args) {
		new AdjustmentListenerDemo();
	}

}

Download

Event handling in Java

Action Event with Menu Item
Action Event in Applet
Action Event
Adjustment Event
Focus Event
Item Event
Key Event
MOuse Event
Event with Timer
Window Event


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code