MenuContainer.java: Fixed typo.
* java/awt/MenuContainer.java: Fixed typo. * Makefile.in: Rebuilt. * Makefile.am (awt_java_source_files): Added SystemColor.java. * java/awt/SystemColor.java: New file. * java/awt/Color.java (rgba): Now package-private. * java/awt/event/InputEvent.java (isAltGraphDown): New method. * java/awt/event/ContainerEvent.java (getContainer): Renamed from getComponent. * java/awt/MenuItem.java (addNotify): New method. (MenuItem(String,MenuShortcut)): New constructor. (setLabel): Notify peer of change. (setEnabled): Likewise. * java/awt/GridLayout.java (toString): New method. * java/awt/FlowLayout.java (LEADING, TRAILING): New constants. (FlowLayout): Check for LEADING and TRAILING. (setAlignment): Likewise. (layoutContainer): Handle component orientation. * java/awt/Component.java (orientatin): New field. (setComponentOrientation): Wrote. (getComponentOrientation): Wrote. * java/awt/Event.java (Event): Implements Serializable. (consumed): New field for serialization. * java/awt/Dimension.java (Dimension): Implements Serializable. * java/awt/Cursor.java (Cursor): Implements Serializable. * java/awt/Container.java (Container): No longer abstract. * java/awt/Choice.java: Wrote. * java/awt/Checkbox.java: Wrote. * java/awt/ItemSelectable.java: Documented. * java/awt/CheckboxGroup.java: Wrote. * java/awt/CardLayout.java (layoutContainer): Directly use fields in other classes. (getSize): Likewise. From-SVN: r38486
This commit is contained in:
parent
83050e0d93
commit
5472d1951a
21 changed files with 851 additions and 74 deletions
|
@ -7,9 +7,179 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|||
details. */
|
||||
|
||||
package java.awt;
|
||||
import java.awt.event.*;
|
||||
import java.awt.peer.CheckboxPeer;
|
||||
|
||||
/* A very incomplete placeholder. */
|
||||
|
||||
public class Checkbox extends Component
|
||||
/** 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);
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue