gcc/libjava/java/awt/Checkbox.java
Tom Tromey 760903c056 Makefile.in: Rebuilt.
* Makefile.in: Rebuilt.
	* Makefile.am (awt_java_source_files): Added Line2D.java.
	* java/awt/geom/Line2D.java: Wrote.

	* java/awt/Menu.java (addNotify): Wrote.

	* java/awt/PopupMenu.java (addNotify): Implemented.
	(show): Likewise.

	* java/awt/Scrollbar.java (addNotify): Call super.addNotify.
	* java/awt/List.java (addNotify): Call super.addNotify.
	* java/awt/Label.java (addNotify): Call super.addNotify.
	* java/awt/FileDialog.java (addNotify): Call super.addNotify.
	* java/awt/Dialog.java (addNotify): Call super.addNotify.
	* java/awt/Choice.java (addNotify): Call super.addNotify.
	* java/awt/CheckboxMenuItem.java (addNotify): Call super.addNotify.
	* java/awt/Checkbox.java (addNotify): Call super.addNotify.

	* java/awt/List.java (replaceItem): Notify peer.

	* java/awt/geom/Rectangle2D.java
	(Float.setRect(float,float,float,float)): New method.

	* java/awt/event/ContainerEvent.java (getContainer): Now returns
	Container.

	* java/awt/RenderingHints.java (Key): Class now public.

	* java/awt/Rectangle.java (Rectangle): Now implements
	Serializable.
	(getPathIterator): Removed.

	* java/awt/GraphicsConfiguration.java (GraphicsConfiguration): New
	constructor.

	* java/awt/FileDialog.java: Wrote.

	* java/awt/EventQueue.java (isDispatchThread): Now public.
	(invokeLater): Likewise.

	* java/awt/Component.java (setCursor): Update peer.
	(getFontMetrics): Use peer.

	* java/awt/ComponentOrientation.java (ComponentOrientation): Class
	now final.

From-SVN: r41489
2001-04-22 03:05:39 +00:00

187 lines
4.2 KiB
Java

/* Copyright (C) 2000, 2001 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt;
import java.awt.event.*;
import java.awt.peer.CheckboxPeer;
/** This class implements a component which has an on/off state. Two
* or more Checkboxes can be grouped by a CheckboxGroup.
* @author Tom Tromey <tromey@redhat.com>
* @date December 25, 2000
*/
public class Checkbox extends Component implements ItemSelectable
{
/** Create a new checkbox.
* @param label The checkbox label. A null value is the same as "";
* this is the default.
* @param state The initial check state; defaults to false.
* @param group The CheckboxGroup. Defaults to null.
*/
public Checkbox ()
{
this (null, null, false);
}
public Checkbox (String label)
{
this (label, null, false);
}
public Checkbox (String label, boolean state)
{
this (label, null, state);
}
public Checkbox (String label, boolean state, CheckboxGroup group)
{
this (label, group, state);
}
public Checkbox (String label, CheckboxGroup group, boolean state)
{
this.label = label;
this.group = group;
this.state = state;
}
/** Add a listener for item events.
* @param listener The listener to add.
*/
public synchronized void addItemListener (ItemListener listener)
{
listeners = AWTEventMulticaster.add (listeners, listener);
}
/** This creates the component's peer. */
public void addNotify ()
{
if (peer == null)
peer = getToolkit ().createCheckbox (this);
super.addNotify ();
}
/** Returns the current CheckboxGroup associated with this
* Checkbox. */
public CheckboxGroup getCheckboxGroup ()
{
return group;
}
/** Returns the current label; might be null. */
public String getLabel ()
{
return label;
}
/** Returns this checkbox's label if this checkbox is selected. */
public Object[] getSelectedObjects ()
{
Object[] r;
if (state)
{
r = new Object[1];
r[0] = label;
}
else
r = new Object[0];
return r;
}
/** Returns the current state of this checkbox. */
public boolean getState ()
{
return state;
}
/** Generates a String representation of this Checkbox's state. */
protected String paramString ()
{
return ("Checkbox["
+ "state=" + state + ","
+ "label=" + label + ","
+ "group=" + group + "]");
}
/** Process an event for this Checkbox.
* @param event The event the process.
*/
protected void processEvent (AWTEvent event)
{
if (event instanceof ItemEvent)
processItemEvent ((ItemEvent) event);
else
super.processEvent (event);
}
/** Process an item event for this Checkbox.
* @param event The ItemEvent to process
*/
protected void processItemEvent (ItemEvent event)
{
if (listeners != null)
listeners.itemStateChanged (event);
}
/** Remove an item listener.
* @param listener Item listener to remove.
*/
public synchronized void removeItemListener (ItemListener listener)
{
listeners = AWTEventMulticaster.remove (listeners, listener);
}
/** Set this checkbox's group.
* @param group The new group. null means remove the Checkbox from
* its group.
*/
public void setCheckboxGroup (CheckboxGroup group)
{
this.group = group;
if (peer != null)
{
CheckboxPeer cp = (CheckboxPeer) peer;
cp.setCheckboxGroup (group);
}
}
/** Set the checkbox's label.
* @param label The new label
*/
public synchronized void setLabel (String label)
{
this.label = label;
if (peer != null)
{
CheckboxPeer cp = (CheckboxPeer) peer;
// FIXME: unclear what to do here; we err on the side of
// caution.
cp.setLabel (label == null ? "" : label);
}
}
/** Set the checkbox's state.
* @param state The new state.
*/
public void setState (boolean state)
{
this.state = state;
if (peer != null)
{
CheckboxPeer cp = (CheckboxPeer) peer;
cp.setState (state);
}
}
private ItemListener listeners;
String label;
CheckboxGroup group;
boolean state;
}