DCPanel.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Common Development and Distribution License, Version 1.0 only
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * (the "License"). You may not use this file except in compliance
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * When distributing Covered Code, include this CDDL HEADER in each
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * If applicable, add the following below this CDDL HEADER, with the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * fields enclosed by brackets "[]" replaced with your own identifying
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * information: Portions Copyright [yyyy] [name of copyright owner]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER END
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * ident "%Z%%M% %I% %E% SMI"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * All rights reserved.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Creates a panel with two buttons (+ and - side by side on it). The
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * panel registers a DCListener with it that gets notified whenever
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * these butons are clicked. <bold>The buttons may also be kept continously
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * pressed for faster increments/decrements.</bold>
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * On a single click of the button, the listener is notified to
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * increment/decrement itself by a small amount. When the button is kept
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * pressed the following notifications are sent out for larger
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * increments/decrements. (It is up to the listener to decide the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * increment/decrement corresponding to large/small.) Moreover, these
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * notifications will be sent out much faster if the button is kept
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * pressed.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl // The panel waits for a period of BIG_SLEEP_TIME before the faster
9512fe850e98fdd448c638ca63fdd92a8a510255ahl // increments are sent out. They, in turn, are sent out after
9512fe850e98fdd448c638ca63fdd92a8a510255ahl // intervals of SMALL_SLEEP_TIME. Therfore, an instance of this class
9512fe850e98fdd448c638ca63fdd92a8a510255ahl // is associated with 2 timers - a longer one that starts off and then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl // schedules the shorter one. The shorter one keeps scheduling itself
9512fe850e98fdd448c638ca63fdd92a8a510255ahl // every time it wakes up.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl private boolean incrementFlag;
public boolean isFocusTraversable() {
return oldListener;
private void startAction() {
private void stopAction() {
if (bigFlag) {
if (incrementFlag)
if (incrementFlag)
private boolean running = false;
public void run() {
running = false;
wait();
running = true;
doTask();
} catch (InterruptedException e) {}
public synchronized void request() {
notify();
public void cancel() {
if (running) {
interrupt();
* user really wants to amek the increments/decrements go by fast.
* to have a bigIncrement/bigDecrement. After that, your job is
protected void doTask() {
informListener(true);
} catch (InterruptedException e) {
informListener(false);
protected void doTask() {
informListener(true);
} catch (InterruptedException e) {}
private boolean plusOrMinus;
super(text);
public boolean isFocusTraversable() {
f.setVisible(true);