e0a339f785
* java/awt/BorderLayout.java (BorderLayout()): New constructor. * java/awt/Frame.java (Frame): Pass `null' to Window constructor. * java/awt/Window.java (addNotify): Wrote. (addWindowListener): Wrote. (getLocale): Wrote. (getWarningString): Wrote. (processEvent): Wrote. (processWindowEvent): Wrote. (removeWindowListener): Wrote. (show): Call validate(), setVisible(). (toBack): Wrote. (toFront): Wrote. * java/awt/Toolkit.java (createWindow): Declare. * java/awt/Frame.java (addNotify): Use getToolkit to find toolkit. * java/awt/Component.java (invalidate): Wrote. (isValid): Wrote. (getToolkit): Wrote. * java/awt/Container.java (addContainerListener): Removed unnecessary cast. (removeContainerListener): Likewise. (addImpl): Wrote. (add(Component)): Use it. (add(String,Component)): Likewise. (add(Component,int)): Likewise. (add(Component,Object)): Likewise. (add(Component,Object,int)): Likewise. (doLayout): Wrote. (getAlignmentX): Wrote. (getAlignmentY): Wrote. (getComponentAt): Wrote. (getMaximumSize): Wrote. (invalidate): Wrote. (list(PrintStream,int)): Wrote. (list(PrintWriter,int)): Wrote. (getMinimumSize): Wrote. (getPreferredSize): Wrote. (printComponents): Wrote. (processContainerEvent): Look at containerListener, not componentListener. (remove): Added event processing and peer destruction. (removeAll): Use remove. (removeNotify): Wrote. (validate): Wrote. (validateTree): Wrote. * java/awt/Scrollbar.java (addNotify): Do nothing if peer exists. * java/awt/Label.java (addNotify): Do nothing if peer exists. * java/awt/Container.java (addNotify): Don't create Container peer. * java/awt/Button.java (addNotify): Do nothing if peer exists. From-SVN: r35361
235 lines
4.4 KiB
Java
235 lines
4.4 KiB
Java
/* Copyright (C) 2000 Free Software Foundation
|
|
|
|
This file is part of libjava.
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
|
|
details. */
|
|
|
|
package java.awt;
|
|
import java.awt.event.*;
|
|
import java.awt.peer.ScrollbarPeer;
|
|
import java.awt.peer.ComponentPeer;
|
|
|
|
/**
|
|
* @author Tom Tromey <tromey@cygnus.com>
|
|
* @date April 12, 2000
|
|
*/
|
|
|
|
public class Scrollbar extends Component implements Adjustable
|
|
{
|
|
public Scrollbar ()
|
|
{
|
|
this (VERTICAL, 0, 10, 0, 100);
|
|
}
|
|
|
|
public Scrollbar (int orientation)
|
|
{
|
|
this (orientation, 0, 10, 0, 100);
|
|
}
|
|
|
|
public Scrollbar (int orientation, int value, int visible,
|
|
int minimum, int maximum)
|
|
{
|
|
if (orientation != HORIZONTAL && orientation != VERTICAL)
|
|
throw new IllegalArgumentException ();
|
|
|
|
if (maximum < minimum)
|
|
maximum = minimum;
|
|
if (value < minimum)
|
|
value = minimum;
|
|
if (value > maximum)
|
|
value = maximum;
|
|
|
|
this.orientation = orientation;
|
|
this.value = value;
|
|
this.visible = visible;
|
|
this.minimum = minimum;
|
|
this.maximum = maximum;
|
|
this.unit = 1;
|
|
|
|
this.block = 0; // FIXME
|
|
}
|
|
|
|
public void addNotify ()
|
|
{
|
|
if (peer == null)
|
|
peer = (ComponentPeer) getToolkit ().createScrollbar (this);
|
|
}
|
|
|
|
public int getOrientation ()
|
|
{
|
|
return orientation;
|
|
}
|
|
|
|
public void setOrientation (int orientation)
|
|
{
|
|
if (orientation != HORIZONTAL && orientation != VERTICAL)
|
|
throw new IllegalArgumentException ();
|
|
this.orientation = orientation;
|
|
}
|
|
|
|
public int getValue ()
|
|
{
|
|
return value;
|
|
}
|
|
|
|
public void setValue (int value)
|
|
{
|
|
setValues (value, visible, minimum, maximum);
|
|
}
|
|
|
|
public int getMinimum ()
|
|
{
|
|
return minimum;
|
|
}
|
|
|
|
public void setMinimum (int minimum)
|
|
{
|
|
setValues (value, visible, minimum, maximum);
|
|
}
|
|
|
|
public int getMaximum ()
|
|
{
|
|
return maximum;
|
|
}
|
|
|
|
public void setMaximum (int maximum)
|
|
{
|
|
setValues (value, visible, minimum, maximum);
|
|
}
|
|
|
|
public int getVisibleAmount ()
|
|
{
|
|
return visible;
|
|
}
|
|
|
|
public int getVisible ()
|
|
{
|
|
return visible;
|
|
}
|
|
|
|
public void setVisibleAmount (int visible)
|
|
{
|
|
setValues (value, visible, minimum, maximum);
|
|
}
|
|
|
|
public void setUnitIncrement (int v)
|
|
{
|
|
unit = v;
|
|
if (peer != null)
|
|
{
|
|
ScrollbarPeer sp = (ScrollbarPeer) peer;
|
|
sp.setLineIncrement (v);
|
|
}
|
|
}
|
|
|
|
/** @deprecated */
|
|
public void setLineIncrement (int v)
|
|
{
|
|
setUnitIncrement (v);
|
|
}
|
|
|
|
public int getUnitIncrement ()
|
|
{
|
|
return unit;
|
|
}
|
|
|
|
public int getLineIncrement ()
|
|
{
|
|
return unit;
|
|
}
|
|
|
|
public void setBlockIncrement (int v)
|
|
{
|
|
block = v;
|
|
if (peer != null)
|
|
{
|
|
ScrollbarPeer sp = (ScrollbarPeer) peer;
|
|
sp.setPageIncrement (v);
|
|
}
|
|
}
|
|
|
|
public void setPageIncrement (int v)
|
|
{
|
|
setBlockIncrement (v);
|
|
}
|
|
|
|
public int getBlockIncrement ()
|
|
{
|
|
return block;
|
|
}
|
|
|
|
public int getPageIncrement ()
|
|
{
|
|
return block;
|
|
}
|
|
|
|
public synchronized void setValues (int value, int visible,
|
|
int minimum, int maximum)
|
|
{
|
|
if (maximum < minimum)
|
|
maximum = minimum;
|
|
if (value < minimum)
|
|
value = minimum;
|
|
if (value > maximum)
|
|
value = maximum;
|
|
|
|
this.value = value;
|
|
this.visible = visible;
|
|
this.minimum = minimum;
|
|
this.maximum = maximum;
|
|
|
|
if (peer != null)
|
|
{
|
|
ScrollbarPeer sp = (ScrollbarPeer) peer;
|
|
sp.setValues (value, visible, minimum, maximum);
|
|
}
|
|
}
|
|
|
|
public void addAdjustmentListener (AdjustmentListener l)
|
|
{
|
|
listeners = AWTEventMulticaster.add (listeners, l);
|
|
}
|
|
|
|
public void removeAdjustmentListener (AdjustmentListener l)
|
|
{
|
|
listeners = AWTEventMulticaster.add (listeners, l);
|
|
}
|
|
|
|
protected void processEvent (AWTEvent e)
|
|
{
|
|
if (e instanceof AdjustmentEvent)
|
|
processAdjustmentEvent ((AdjustmentEvent) e);
|
|
else
|
|
super.processEvent (e);
|
|
}
|
|
|
|
protected void processAdjustmentEvent (AdjustmentEvent e)
|
|
{
|
|
if (listeners != null)
|
|
listeners.adjustmentValueChanged (e);
|
|
}
|
|
|
|
protected String paramString ()
|
|
{
|
|
return ("Scrollbar["
|
|
+ ((orientation == VERTICAL) ? "VERTICAL" : "HORIZONTAL") + ","
|
|
+ value + ","
|
|
+ visible + ","
|
|
+ minimum + ","
|
|
+ maximum + ","
|
|
+ unit + ","
|
|
+ block + "]");
|
|
}
|
|
|
|
private AdjustmentListener listeners;
|
|
private int orientation;
|
|
private int value;
|
|
private int visible;
|
|
private int minimum;
|
|
private int maximum;
|
|
private int unit;
|
|
private int block;
|
|
}
|