gcc/libjava/java/awt/CheckboxMenuItem.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

135 lines
3.1 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.peer.CheckboxMenuItemPeer;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
/** This implements a menu item which keeps track of a boolean state.
* @author Tom Tromey <tromey@redhat.com>
* @date December 25, 2000
*/
public class CheckboxMenuItem extends MenuItem implements ItemSelectable
{
/** Create a new CheckboxMenuItem.
* @param label The checkbox label. A null value is the same as "";
* null is the default.
* @param state The initial check state; defaults to false.
*/
public CheckboxMenuItem ()
{
this (null, false);
}
public CheckboxMenuItem (String label)
{
this (label, false);
}
public CheckboxMenuItem (String label, boolean state)
{
this.label = label;
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)
{
// This choice of toolkit seems unsatisfying, but I'm not sure
// what else to do.
peer = Toolkit.getDefaultToolkit ().createCheckboxMenuItem (this);
}
super.addNotify ();
}
/** 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. */
public String paramString ()
{
return ("[" + getClass ().getName ()
+ "state=" + state + ","
+ "label=" + label + "]");
}
/** 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 the checkbox's state.
* @param state The new state.
*/
public void setState (boolean state)
{
this.state = state;
if (peer != null)
{
CheckboxMenuItemPeer cp = (CheckboxMenuItemPeer) peer;
cp.setState (state);
}
}
// Private state.
String label;
boolean state;
ItemListener listeners;
}