Commit bda14505 by Tom Tromey Committed by Tom Tromey

ButtonPeer.java: Replace with Classpath version.

	* java/awt/peer/ButtonPeer.java: Replace with Classpath version.
	* java/awt/peer/CanvasPeer.java: Replace with Classpath version.
	* java/awt/peer/CheckboxMenuItemPeer.java: Replace with Classpath
	version.
	* java/awt/peer/CheckboxPeer.java: Replace with Classpath version.
	* java/awt/peer/ChoicePeer.java: Replace with Classpath version.
	* java/awt/peer/ComponentPeer.java: Replace with Classpath version.
	* java/awt/peer/ContainerPeer.java: Replace with Classpath version.
	* java/awt/peer/DialogPeer.java: Replace with Classpath version.
	* java/awt/peer/FileDialogPeer.java: Replace with Classpath version.
	* java/awt/peer/FontPeer.java: Replace with Classpath version.
	* java/awt/peer/FramePeer.java: Replace with Classpath version.
	* java/awt/peer/LabelPeer.java: Replace with Classpath version.
	* java/awt/peer/LightweightPeer.java: Replace with Classpath version.
	* java/awt/peer/ListPeer.java: Replace with Classpath version.
	* java/awt/peer/MenuBarPeer.java: Replace with Classpath version.
	* java/awt/peer/MenuComponentPeer.java: Replace with Classpath version.
	* java/awt/peer/MenuItemPeer.java: Replace with Classpath version.
	* java/awt/peer/MenuPeer.java: Replace with Classpath version.
	* java/awt/peer/PanelPeer.java: Replace with Classpath version.
	* java/awt/peer/PopupMenuPeer.java: Replace with Classpath version.
	* java/awt/peer/ScrollPanePeer.java: Replace with Classpath version.
	* java/awt/peer/ScrollbarPeer.java: Replace with Classpath version.
	* java/awt/peer/TextAreaPeer.java: Replace with Classpath version.
	* java/awt/peer/TextComponentPeer.java: Replace with Classpath version.
	* java/awt/peer/TextFieldPeer.java: Replace with Classpath version.
	* java/awt/peer/WindowPeer.java: Replace with Classpath version.
	* gnu/awt/xlib/XPanelPeer.java (insets): New method.
	* gnu/awt/xlib/XCanvasPeer.java (show, hide): New methods.
	(minimumSize, preferredSize, reshape): Likewise.
	* gnu/awt/xlib/XFramePeer.java (insets, enable, disable,
	getColorModel): New methods.
	* java/awt/PopupMenu.java: Merged with Classpath.
	* java/awt/MenuBar.java: Merged with Classpath.
	* java/awt/SystemColor.java: Replace with Classpath version.
	* java/awt/Panel.java: Merged with Classpath.
	* java/awt/PaintContext.java: Updated copyright.
	* java/awt/MenuShortcut.java: Merged with Classpath.
	* java/awt/MenuContainer.java: Merged with Classpath.
	* java/awt/Menu.java: Merged with Classpath.
	* java/awt/MediaEntry.java: New file from Classpath.
	* java/awt/MediaTracker.java: New file from Classpath.
	* java/awt/List.java: Merged with Classpath version.
	* java/awt/Insets.java: Merged with Classpath version.
	* java/awt/ImageMediaEntry.java: New file from Classpath.
	* java/awt/Image.java: Replaced with Classpath version.
	* java/awt/FontMetrics.java: Merged with Classpath version.
	* java/awt/Cursor.java (getDefaultCursor): Use DEFAULT_CURSOR
	constant.
	* java/awt/Font.java: Merged with Classpath version.
	* java/awt/Dialog.java: Merged with Classpath version.
	* java/awt/Color.java: Merged with Classpath version.
	* java/awt/Choice.java: Merged with Classpath version.
	* java/awt/CheckboxMenuItem.java: Merged with Classpath version.
	* java/awt/Adjustable.java: Replace with Classpath version.
	* java/awt/MenuItem.java (paramString): Don't include class name
	or brackets.  Call superclass paramString.
	* java/awt/MenuComponent.java (toString): Call paramString.
	(paramString): Compute string; don't call toString.
	* java/awt/Label.java (paramString): Don't include class name
	or brackets.  Call superclass paramString.
	* java/awt/Checkbox.java (paramString): Don't include class name
	or brackets.  Call superclass paramString.
	* java/awt/Button.java (paramString): Don't include class name or
	brackets.  Call superclass paramString.
	* java/awt/MenuComponent.java (getTreeLock): Now protected.

From-SVN: r49099
parent e3b0efd1
2002-01-22 Tom Tromey <tromey@redhat.com>
* java/awt/peer/ButtonPeer.java: Replace with Classpath version.
* java/awt/peer/CanvasPeer.java: Replace with Classpath version.
* java/awt/peer/CheckboxMenuItemPeer.java: Replace with Classpath
version.
* java/awt/peer/CheckboxPeer.java: Replace with Classpath version.
* java/awt/peer/ChoicePeer.java: Replace with Classpath version.
* java/awt/peer/ComponentPeer.java: Replace with Classpath version.
* java/awt/peer/ContainerPeer.java: Replace with Classpath version.
* java/awt/peer/DialogPeer.java: Replace with Classpath version.
* java/awt/peer/FileDialogPeer.java: Replace with Classpath version.
* java/awt/peer/FontPeer.java: Replace with Classpath version.
* java/awt/peer/FramePeer.java: Replace with Classpath version.
* java/awt/peer/LabelPeer.java: Replace with Classpath version.
* java/awt/peer/LightweightPeer.java: Replace with Classpath version.
* java/awt/peer/ListPeer.java: Replace with Classpath version.
* java/awt/peer/MenuBarPeer.java: Replace with Classpath version.
* java/awt/peer/MenuComponentPeer.java: Replace with Classpath version.
* java/awt/peer/MenuItemPeer.java: Replace with Classpath version.
* java/awt/peer/MenuPeer.java: Replace with Classpath version.
* java/awt/peer/PanelPeer.java: Replace with Classpath version.
* java/awt/peer/PopupMenuPeer.java: Replace with Classpath version.
* java/awt/peer/ScrollPanePeer.java: Replace with Classpath version.
* java/awt/peer/ScrollbarPeer.java: Replace with Classpath version.
* java/awt/peer/TextAreaPeer.java: Replace with Classpath version.
* java/awt/peer/TextComponentPeer.java: Replace with Classpath version.
* java/awt/peer/TextFieldPeer.java: Replace with Classpath version.
* java/awt/peer/WindowPeer.java: Replace with Classpath version.
* gnu/awt/xlib/XPanelPeer.java (insets): New method.
* gnu/awt/xlib/XCanvasPeer.java (show, hide): New methods.
(minimumSize, preferredSize, reshape): Likewise.
* gnu/awt/xlib/XFramePeer.java (insets, enable, disable,
getColorModel): New methods.
* java/awt/PopupMenu.java: Merged with Classpath.
* java/awt/MenuBar.java: Merged with Classpath.
* java/awt/SystemColor.java: Replace with Classpath version.
* java/awt/Panel.java: Merged with Classpath.
* java/awt/PaintContext.java: Updated copyright.
* java/awt/MenuShortcut.java: Merged with Classpath.
* java/awt/MenuContainer.java: Merged with Classpath.
* java/awt/Menu.java: Merged with Classpath.
* java/awt/MediaEntry.java: New file from Classpath.
* java/awt/MediaTracker.java: New file from Classpath.
* java/awt/List.java: Merged with Classpath version.
* java/awt/Insets.java: Merged with Classpath version.
* java/awt/ImageMediaEntry.java: New file from Classpath.
* java/awt/Image.java: Replaced with Classpath version.
* java/awt/FontMetrics.java: Merged with Classpath version.
* java/awt/Cursor.java (getDefaultCursor): Use DEFAULT_CURSOR
constant.
* java/awt/Font.java: Merged with Classpath version.
* java/awt/Dialog.java: Merged with Classpath version.
* java/awt/Color.java: Merged with Classpath version.
* java/awt/Choice.java: Merged with Classpath version.
* java/awt/CheckboxMenuItem.java: Merged with Classpath version.
* java/awt/Adjustable.java: Replace with Classpath version.
* java/awt/MenuItem.java (paramString): Don't include class name
or brackets. Call superclass paramString.
* java/awt/MenuComponent.java (toString): Call paramString.
(paramString): Compute string; don't call toString.
* java/awt/Label.java (paramString): Don't include class name
or brackets. Call superclass paramString.
* java/awt/Checkbox.java (paramString): Don't include class name
or brackets. Call superclass paramString.
* java/awt/Button.java (paramString): Don't include class name or
brackets. Call superclass paramString.
* java/awt/MenuComponent.java (getTreeLock): Now protected.
2002-01-20 Andreas Schwab <schwab@suse.de> 2002-01-20 Andreas Schwab <schwab@suse.de>
* java/net/natPlainSocketImpl.cc (_Jv_recv): Change return type of * java/net/natPlainSocketImpl.cc (_Jv_recv): Change return type of
......
/* Copyright (C) 2000 Free Software Foundation /* Copyright (C) 2000, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -230,6 +230,11 @@ public class XCanvasPeer implements CanvasPeer ...@@ -230,6 +230,11 @@ public class XCanvasPeer implements CanvasPeer
throw new UnsupportedOperationException("FIXME, not implemented"); throw new UnsupportedOperationException("FIXME, not implemented");
} }
public ColorModel getColorModel ()
{
return null;
}
public Graphics getGraphics() public Graphics getGraphics()
{ {
DirectRasterGraphics gfxDevice = new XGraphics(window, config); DirectRasterGraphics gfxDevice = new XGraphics(window, config);
...@@ -251,11 +256,21 @@ public class XCanvasPeer implements CanvasPeer ...@@ -251,11 +256,21 @@ public class XCanvasPeer implements CanvasPeer
return MIN_SIZE; return MIN_SIZE;
} }
public Dimension minimumSize ()
{
return getMinimumSize ();
}
public Dimension getPreferredSize () public Dimension getPreferredSize ()
{ {
return component.getSize(); return component.getSize();
} }
public Dimension preferredSize ()
{
return getPreferredSize();
}
public Toolkit getToolkit() public Toolkit getToolkit()
{ {
return getXToolkit(); return getXToolkit();
...@@ -318,6 +333,11 @@ public class XCanvasPeer implements CanvasPeer ...@@ -318,6 +333,11 @@ public class XCanvasPeer implements CanvasPeer
ensureFlush(); ensureFlush();
} }
public void reshape (int x, int y, int width, int height)
{
setBounds (x, y, width, height);
}
public void setCursor(Cursor cursor) public void setCursor(Cursor cursor)
{ {
throw new UnsupportedOperationException("FIXME, not implemented"); throw new UnsupportedOperationException("FIXME, not implemented");
...@@ -328,6 +348,16 @@ public class XCanvasPeer implements CanvasPeer ...@@ -328,6 +348,16 @@ public class XCanvasPeer implements CanvasPeer
throw new UnsupportedOperationException("FIXME, not implemented"); throw new UnsupportedOperationException("FIXME, not implemented");
} }
public void enable ()
{
setEnabled (true);
}
public void disable ()
{
setEnabled (false);
}
public void setEventMask(long eventMask) public void setEventMask(long eventMask)
{ {
WindowAttributes attributes = new WindowAttributes(); WindowAttributes attributes = new WindowAttributes();
...@@ -371,6 +401,16 @@ public class XCanvasPeer implements CanvasPeer ...@@ -371,6 +401,16 @@ public class XCanvasPeer implements CanvasPeer
} }
} }
public void show ()
{
setVisible (true);
}
public void hide ()
{
setVisible (false);
}
static class DoMap implements Runnable static class DoMap implements Runnable
{ {
Window window; Window window;
......
/* Copyright (C) 2000 Free Software Foundation /* Copyright (C) 2000, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -93,6 +93,11 @@ public class XFramePeer extends XCanvasPeer implements FramePeer ...@@ -93,6 +93,11 @@ public class XFramePeer extends XCanvasPeer implements FramePeer
return (Insets) INSETS_0_PROTOTYPE.clone(); return (Insets) INSETS_0_PROTOTYPE.clone();
} }
public Insets insets ()
{
return getInsets ();
}
public void beginValidate() public void beginValidate()
{ {
} }
......
/* Copyright (C) 2000 Free Software Foundation /* Copyright (C) 2000, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -40,6 +40,11 @@ public class XPanelPeer extends XCanvasPeer implements PanelPeer ...@@ -40,6 +40,11 @@ public class XPanelPeer extends XCanvasPeer implements PanelPeer
return (Insets) INSETS_0_PROTOTYPE.clone(); return (Insets) INSETS_0_PROTOTYPE.clone();
} }
public Insets insets()
{
return getInsets();
}
public void beginValidate() public void beginValidate()
{ {
// NOP // NOP
......
/* Copyright (C) 1999, 2000 Free Software Foundation /* Adjustable.java -- Objects with a numeric adjustment scale.
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libjava. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.event.*;
import java.awt.event.AdjustmentListener;
/** /**
* @author Tom Tromey <tromey@cygnus.com> * This interface is for objects that take a numeric value that
* @date April 8, 2000 * can be adjusted within a bounded range. For example, a scroll bar.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface Adjustable
{
/*
* Static Variables
*/ */
/* Status: Believed complete and correct to JDK 1.2. */ /**
* Constant for a horizontal orientation
*/
public static final int HORIZONTAL = 0;
/**
* Constant for a vertical orientation
*/
public static final int VERTICAL = 1;
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Returns the current value of the object.
*
* @return The current value of the object.
*/
public abstract int
getValue();
/*************************************************************************/
/**
* Sets the current value of the object.
*
* @param value The current value of the object.
*/
public abstract void
setValue(int value);
/*************************************************************************/
/**
* Returns the orientation of the object, either <code>HORIZONTAL</code>
* or <code>VERTICAL</code>.
*
* @return The orientation of this object.
*/
public abstract int
getOrientation();
/*************************************************************************/
/**
* Returns the minimum value this object can take.
*
* @return The minimum value this object can take.
*/
public abstract int
getMinimum();
/*************************************************************************/
/**
* Sets the minimum value this object can take to the specified value.
*
* @param minimum The new minimum value for this object.
*/
public abstract void
setMinimum(int minimum);
/*************************************************************************/
/**
* Returns the maximum value this object can take.
*
* @return The maximum value this object can take.
*/
public abstract int
getMaximum();
/*************************************************************************/
/**
* Sets the maximum value this object can take to the specified value.
*
* @param maximum The new maximum value for this object.
*/
public abstract void
setMaximum(int maximum);
/*************************************************************************/
/**
* Returns the increment value for incrementing by units.
*
* @return The unit increment value.
*/
public abstract int
getUnitIncrement();
/*************************************************************************/
/**
* Sets the increment value for incrementing by units to the specified value.
*
* @param increment The unit increment value.
*/
public abstract void
setUnitIncrement(int increment);
/*************************************************************************/
/**
* Returns the increment value for incrementing by blocks.
*
* @return The block increment value.
*/
public abstract int
getBlockIncrement();
/*************************************************************************/
/**
* Sets the increment value for incrementing by blocks to the specified value.
*
* @param increment The block increment value.
*/
public abstract void
setBlockIncrement(int increment);
/*************************************************************************/
/**
* Returns the length of the indicator for this object.
*
* @return The indicator length.
*/
public abstract int
getVisibleAmount();
/*************************************************************************/
/**
* Sets the length of the indicator for this object to the specified value.
*
* @param length The indicator length
*/
public abstract void
setVisibleAmount(int length);
/*************************************************************************/
/**
* Adds a listener that will receive adjustment events for this object.
*
* @param listener The adjustment listener to add.
*/
public abstract void
addAdjustmentListener(AdjustmentListener listener);
/*************************************************************************/
/**
* Removes an adjustment listener from this object. It will no longer
* receive adjustment events.
*
* @param listener The adjustment listener to remove.
*/
public abstract void
removeAdjustmentListener(AdjustmentListener listener);
} // interface Adjustable
public interface Adjustable
{
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
public void addAdjustmentListener (AdjustmentListener l);
public int getBlockIncrement ();
public int getMaximum ();
public int getMinimum ();
public int getOrientation ();
public int getUnitIncrement ();
public int getValue ();
public int getVisibleAmount ();
public void removeAdjustmentListener (AdjustmentListener l);
public void setBlockIncrement (int b);
public void setMaximum (int max);
public void setMinimum (int min);
public void setUnitIncrement (int u);
public void setValue (int v);
public void setVisibleAmount (int v);
}
...@@ -269,8 +269,8 @@ dispatchEventImpl(AWTEvent e) ...@@ -269,8 +269,8 @@ dispatchEventImpl(AWTEvent e)
protected String protected String
paramString() paramString()
{ {
return(getClass().getName() + "(label=" + getLabel() + ",actionCommand=" + return ("label=" + getLabel() + ",actionCommand=" + getActionCommand()
getActionCommand() + ")"); + "," + super.paramString());
} }
} // class Button } // class Button
......
...@@ -362,8 +362,8 @@ processItemEvent(ItemEvent event) ...@@ -362,8 +362,8 @@ processItemEvent(ItemEvent event)
protected String protected String
paramString() paramString()
{ {
return(getClass().getName() + "[label=" + label + ",state=" + state return ("label=" + label + ",state=" + state + ",group=" + group
+ ",group=" + group + "]"); + "," + super.paramString());
} }
} // class Checkbox } // class Checkbox
/* Copyright (C) 2000, 2001 Free Software Foundation /* CheckboxMenuItem.java -- A menu option with a checkbox on it.
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.peer.CheckboxMenuItemPeer; import java.awt.peer.CheckboxMenuItemPeer;
import java.awt.event.ItemListener; import java.awt.peer.MenuItemPeer;
import java.awt.peer.MenuComponentPeer;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* This class implements a menu item that has a checkbox on it indicating
* the selected state of some option.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@redhat.com>
*/
public class CheckboxMenuItem extends MenuItem implements ItemSelectable,
java.io.Serializable
{
/** This implements a menu item which keeps track of a boolean state. /*
* @author Tom Tromey <tromey@redhat.com> * Static Variables
* @date December 25, 2000
*/ */
public class CheckboxMenuItem extends MenuItem implements ItemSelectable
// Serialization constant
private static final long serialVersionUID = 6190621106981774043L;
/*
* Instance Variables
*/
/**
* @serial The state of the checkbox, with <code>true</code> being on and
* <code>false</code> being off.
*/
private boolean state;
// List of registered ItemListeners
private transient ItemListener item_listeners;
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>CheckboxMenuItem</code> with no
* label and an initial state of off.
*/
public
CheckboxMenuItem()
{ {
/** Create a new CheckboxMenuItem. this("", false);
* @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;
} }
/*************************************************************************/
/**
* Initializes a new instance of <code>CheckboxMenuItem</code> with the
* specified label and an initial state of off.
*
* @param label The label of the menu item.
*/
public
CheckboxMenuItem(String label)
{
this(label, false);
}
/*************************************************************************/
/**
* Initializes a new instance of <code>CheckboxMenuItem</code> with the
* specified label and initial state.
*
* @param label The label of the menu item.
* @param state The initial state of the menu item, where <code>true</code>
* is on, and <code>false</code> is off.
*/
public
CheckboxMenuItem(String label, boolean state)
{
super(label);
this.state = state;
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Returns the state of this menu item.
*
* @return The state of this menu item.
*/
public boolean
getState()
{
return(state);
}
/*************************************************************************/
/**
* Sets the state of this menu item.
*
* @param state The initial state of the menu item, where <code>true</code>
* is on, and <code>false</code> is off.
*/
public synchronized void
setState(boolean state)
{
this.state = state;
if (peer != null)
{
CheckboxMenuItemPeer cp = (CheckboxMenuItemPeer) peer;
cp.setState (state);
}
}
/*************************************************************************/
/**
* Returns an array of length 1 with the menu item label for this object
* if the state is on. Otherwise <code>null</code> is returned.
*
* @param An array with this menu item's label if it has a state of on,
* or <code>null</code> otherwise.
*/
public Object[]
getSelectedObjects()
{
if (state == false)
return(null);
Object[] obj = new Object[1];
obj[0] = getLabel();
return(obj);
}
/*************************************************************************/
/**
* Create's this object's native peer
*/
public synchronized void
addNotify()
{
if (peer != null)
{
// This choice of toolkit seems unsatisfying, but I'm not sure
// what else to do.
peer = getToolkit().createCheckboxMenuItem(this);
}
super.addNotify ();
}
/*************************************************************************/
/**
* Adds the specified listener to the list of registered item listeners
* for this object.
*
* @param listener The listener to add.
*/
public synchronized void
addItemListener(ItemListener listener)
{
item_listeners = AWTEventMulticaster.add(item_listeners, listener);
enableEvents(AWTEvent.ITEM_EVENT_MASK);
}
/*************************************************************************/
/**
* Removes the specified listener from the list of registered item
* listeners for this object.
*
* @param listener The listener to remove.
*/
public synchronized void
removeItemListener(ItemListener listener)
{
item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
}
/*************************************************************************/
/**
* Processes the specified event by calling <code>processItemEvent()</code>
* if it is an instance of <code>ItemEvent</code> or calling the superclass
* method otherwise.
*
* @param event The event to process.
*/
protected void
processEvent(AWTEvent event)
{
if (event instanceof ItemEvent)
processItemEvent((ItemEvent)event);
else
super.processEvent(event);
}
/*************************************************************************/
/**
* Processes the specified event by dispatching it to any registered listeners.
*
* @param event The event to process.
*/
protected void
processItemEvent(ItemEvent event)
{
if (item_listeners != null)
item_listeners.itemStateChanged(event);
}
/*************************************************************************/
/**
* Returns a debugging string for this object.
*
* @return A debugging string for this object.
*/
public String
paramString()
{
return ("label=" + getLabel() + ",state=" + state
+ "," + super.paramString());
}
} // class CheckboxMenuItem
/* Copyright (C) 2000, 2001 Free Software Foundation /* Choice.java -- Java choice button widget.
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.event.*;
import java.awt.peer.ChoicePeer; import java.awt.peer.ChoicePeer;
import java.util.ArrayList; import java.awt.peer.ComponentPeer;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.Serializable;
import java.util.Vector;
/**
* This class implements a drop down choice list.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class Choice extends Component implements ItemSelectable, Serializable
{
/*
* Static Variables
*/
// Serialization constant
private static final long serialVersionUID = -4075310674757313071L;
/*************************************************************************/
/*
* Instance Variables
*/
/**
* @serial A list of items for the choice box, which can be <code>null</code>.
*/
private Vector pItems = new Vector();
/**
* @serial The index of the selected item in the choice box.
*/
private int selectedIndex = -1;
// Listener chain
private ItemListener item_listeners;
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>Choice</code>.
*/
public
Choice()
{
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Returns the number of items in the list.
*
* @return The number of items in the list.
*/
public int
getItemCount()
{
return(pItems.size());
}
/*************************************************************************/
/**
* Returns the number of items in the list.
*
* @return The number of items in the list.
*
* @deprecated This method is deprecated in favor of <code>getItemCount</code>.
*/
public int
countItems()
{
return(pItems.size());
}
/*************************************************************************/
/**
* Returns the item at the specified index in the list.
*
* @param index The index into the list to return the item from.
*
* @exception ArrayIndexOutOfBoundsException If the index is invalid.
*/
public String
getItem(int index)
{
return((String)pItems.elementAt(index));
}
/*************************************************************************/
/**
* Adds the specified item to this choice box.
*
* @param item The item to add.
*/
public synchronized void
add(String item)
{
if (item == null)
throw new IllegalArgumentException ("item must be non-null");
pItems.addElement(item);
int i = pItems.size () - 1;
if (peer != null)
{
ChoicePeer cp = (ChoicePeer) peer;
cp.add (item, i);
}
if (i == 0)
select (0);
}
/*************************************************************************/
/** This component lets the user choose an item from a list of /**
* Strings. * Adds the specified item to this choice box.
* @author Tom Tromey <tromey@redhat.com> *
* @date December 25, 2000 * @param item The item to add.
*/
public synchronized void
addItem(String item)
{
add(item);
}
/*************************************************************************/
/** Inserts an item into this Choice. Existing items are shifted
* upwards. If the new item is the only item, then it is selected.
* If the currently selected item is shifted, then the first item is
* selected. If the currently selected item is not shifted, then it
* remains selected.
*
* @param item The item to add.
* @param index The index at which the item should be inserted.
*/ */
public class Choice extends Component implements ItemSelectable public synchronized void
insert(String item, int index)
{ {
/** Create a new Choice object. */ if (index > getItemCount ())
public Choice () index = getItemCount ();
{
items = new ArrayList (); pItems.insertElementAt(item, index);
selected = -1;
} if (peer != null)
{
/** Add a new item to this Choice object. If the item is the first ChoicePeer cp = (ChoicePeer) peer;
* item on the list, then it is selected. cp.add (item, index);
* @param item The new item; must be non-null. }
*/
public synchronized void add (String item) if (getItemCount () == 1 || selectedIndex >= index)
{ select (0);
if (item == null) }
throw new IllegalArgumentException ("item must be non-null");
items.add (item); /*************************************************************************/
int i = items.size () - 1; /**
if (peer != null) * Removes the specified item from the choice box.
{ *
ChoicePeer cp = (ChoicePeer) peer; * @param item The item to remove.
cp.add (item, i); *
} * @param IllegalArgumentException If the specified item doesn't exist.
*/
if (i == 0) public synchronized void
select (0); remove(String item)
} {
int index = pItems.indexOf(item);
/** Add a new item to this Choice object. This is the same as the if (index == -1)
* add method. */ throw new IllegalArgumentException ("item \""
public void addItem (String item) + item + "\" not found in Choice");
{ remove(index);
add (item);
}
/** 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 ().createChoice (this);
super.addNotify ();
}
/** Returns number of items.
* @deprecated
*/
public int countItems ()
{
return getItemCount ();
}
/** Returns an item from this choice.
* @param index Index of the item. Indices start at zero.
*/
public String getItem (int index)
{
return (String) items.get (index);
}
/** Returns number of items in Choice. */
public int getItemCount ()
{
return items.size ();
}
/** Returns index of selected item; -1 if no item is selected. */
public int getSelectedIndex ()
{
return selected;
}
/** Returns currently selected item; null if no item is selected. */
public synchronized String getSelectedItem ()
{
return selected == -1 ? null : (String) items.get (selected);
}
/** Returns the currently selected item. */
public synchronized Object[] getSelectedObjects ()
{
// The JCL says this can return null but that breaks the contract
// for ItemSelectable.
Object[] r;
if (selected != -1)
{
r = new Object[1];
r[0] = items.get (selected);
}
else
r = new Object[0];
return r;
}
/** Inserts an item into this Choice. Existing items are shifted
* upwards. If the new item is the only item, then it is selected.
* If the currently selected item is shifted, then the first item is
* selected. If the currently selected item is not shifted, then it
* remains selected.
* @param item The new item
* @param index The position at which to insert it.
*/
public synchronized void insert (String item, int index)
{
if (index > items.size ())
index = items.size ();
items.add (index, item);
if (peer != null)
{
ChoicePeer cp = (ChoicePeer) peer;
cp.add (item, index);
}
if (items.size () == 1 || selected >= index)
select (0);
}
/** Generates a String representation of this Choice's state. */
protected String paramString ()
{
return ("Choice["
+ "selected=" + selected
+ "]");
}
/** Process an event for this Choice
* @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 Choice.
* @param event The ItemEvent to process
*/
protected void processItemEvent (ItemEvent event)
{
if (listeners != null)
listeners.itemStateChanged (event);
}
/** Remove an item from this Choice. If several matches exist, the
* first one is removed. If the removed item is selected, the the
* first item is selected.
* @param item The item string.
*/
public synchronized void remove (String item)
{
int size = items.size ();
for (int i = 0; i < size; ++i)
{
if (item.equals (items.get (i)))
{
remove (i);
break;
}
}
throw new IllegalArgumentException ("item \"" + item + "\" not in Choice");
}
/** Remove an item from this Choice. If the removed item is
* selected, the the first item is selected.
* @param index Index of the item to remove
*/
public synchronized void remove (int index)
{
items.remove (index);
if (peer != null)
{
ChoicePeer cp = (ChoicePeer) peer;
cp.remove (index);
}
if (index == selected)
select (0);
else if (selected > index)
--selected;
}
/** Remove all items from this choice. */
public synchronized void removeAll ()
{
int oldsize = items.size ();
items.clear ();
selected = -1;
if (peer != null)
{
ChoicePeer cp = (ChoicePeer) peer;
for (int i = 0; i < oldsize; ++i)
{
// Always remove item 0.
cp.remove (0);
}
}
}
/** Remove an item listener.
* @param listener Item listener to remove.
*/
public synchronized void removeItemListener (ItemListener listener)
{
listeners = AWTEventMulticaster.remove (listeners, listener);
}
/** Select an item in this Choice.
* @param item Name of the item to select.
*/
public synchronized void select (String item)
{
int size = items.size ();
for (int i = 0; i < size; ++i)
{
if (item.equals (items.get (i)))
{
select (i);
break;
}
}
}
/** Select an item in this choice.
* @param index Index of item to select.
*/
public synchronized void select (int index)
{
if (index < 0 || index > items.size ())
throw new IllegalArgumentException ("index out of range");
selected = index;
if (peer != null)
{
ChoicePeer cp = (ChoicePeer) peer;
cp.select (index);
}
}
private ItemListener listeners;
// List of items.
ArrayList items;
// Index of selected item.
int selected;
} }
/*************************************************************************/
/**
* Removes the item at the specified index from the choice box.
*
* @param index The index of the item to remove.
*
* @exception ArrayIndexOutOfBoundException If the index is not valid.
*/
public synchronized void
remove(int index)
{
pItems.removeElementAt(index);
if (peer != null)
{
ChoicePeer cp = (ChoicePeer) peer;
cp.remove (index);
}
if (index == selectedIndex)
select (0);
else if (selectedIndex > index)
--selectedIndex;
}
/*************************************************************************/
/**
* Removes all of the objects from this choice box.
*/
public synchronized void
removeAll()
{
int count = getItemCount();
for (int i = 0; i < count; i++)
{
// Always remove 0.
remove(0);
}
}
/*************************************************************************/
/**
* Returns the currently selected item, or null if no item is
* selected.
*
* @return The currently selected item.
*/
public synchronized String
getSelectedItem()
{
return (selectedIndex == -1
? null
: ((String)pItems.elementAt(selectedIndex)));
}
/*************************************************************************/
/**
* Returns an array with one row containing the selected item.
*
* @return An array containing the selected item.
*/
public synchronized Object[]
getSelectedObjects()
{
if (selectedIndex == -1)
return null;
Object[] objs = new Object[1];
objs[0] = pItems.elementAt(selectedIndex);
return(objs);
}
/*************************************************************************/
/**
* Returns the index of the selected item.
*
* @return The index of the selected item.
*/
public int
getSelectedIndex()
{
return(selectedIndex);
}
/*************************************************************************/
/**
* Forces the item at the specified index to be selected.
*
* @param index The index of the row to make selected.
*
* @param IllegalArgumentException If the specified index is invalid.
*/
public synchronized void
select(int index)
{
if ((index < 0) || (index > getItemCount()))
throw new IllegalArgumentException("Bad index: " + index);
this.selectedIndex = index;
if (peer != null)
{
ChoicePeer cp = (ChoicePeer) peer;
cp.select (index);
}
}
/*************************************************************************/
/**
* Forces the named item to be selected.
*
* @param item The item to be selected.
*
* @exception IllegalArgumentException If the specified item does not exist.
*/
public synchronized void
select(String item)
{
int index = pItems.indexOf(item);
if (index >= 0)
select(index);
}
/*************************************************************************/
/**
* Creates the native peer for this object.
*/
public void
addNotify()
{
if (peer == null)
peer = getToolkit ().createChoice (this);
super.addNotify ();
}
/*************************************************************************/
/**
* Adds the specified listener to the list of registered listeners for
* this object.
*
* @param listener The listener to add.
*/
public synchronized void
addItemListener(ItemListener listener)
{
item_listeners = AWTEventMulticaster.add(item_listeners, listener);
}
/*************************************************************************/
/**
* Removes the specified listener from the list of registered listeners for
* this object.
*
* @param listener The listener to remove.
*/
public synchronized void
removeItemListener(ItemListener listener)
{
item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
}
/*************************************************************************/
/**
* Processes this event by invoking <code>processItemEvent()</code> if the
* event is an instance of <code>ItemEvent</code>, otherwise the event
* is passed to the superclass.
*
* @param event The event to process.
*/
protected void
processEvent(AWTEvent event)
{
if (event instanceof ItemEvent)
processItemEvent((ItemEvent)event);
else
super.processEvent(event);
}
/*************************************************************************/
/**
* Processes item event by dispatching to any registered listeners.
*
* @param event The event to process.
*/
protected void
processItemEvent(ItemEvent event)
{
if (item_listeners != null)
item_listeners.itemStateChanged(event);
}
/*************************************************************************/
/**
* Returns a debugging string for this object.
*
* @return A debugging string for this object.
*/
protected String
paramString()
{
return ("selectedIndex=" + selectedIndex + "," + super.paramString());
}
} // class Choice
/* Copyright (C) 2000 Free Software Foundation /* Color.java -- Class representing a color in Java
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
/** /**
* @author Warren Levy <warrenl@cygnus.com> * This class represents a color value in the AWT system.
* @date March 15, 2000. *
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class Color implements java.io.Serializable
{
/*
* Static Variables
*/
/**
* Constant for the color white
*/
public static final Color white = new Color(255,255,255,255);
/**
* Constant for the color light gray
*/
public static final Color lightGray = new Color(192,192,192,255);
/**
* Constant for the color gray
*/
public static final Color gray = new Color(128,128,128,255);
/**
* Constant for the color dark gray
*/
public static final Color darkGray = new Color(64,64,64,255);
/**
* Constant for the color black
*/
public static final Color black = new Color(0,0,0,255);
/**
* Constant for the color red
*/
public static final Color red = new Color(255,0,0,255);
/**
* Constant for the color pink
*/
public static final Color pink = new Color(255, 175, 175,255);
/**
* Constant for the color orange
*/
public static final Color orange = new Color(255, 200, 0,255);
/**
* Constant for the color yellow
*/
public static final Color yellow = new Color(255,255,0,255);
/**
* Constant for the color green
*/
public static final Color green = new Color(0,255,0,255);
/**
* Constant for the color magenta
*/
public static final Color magenta = new Color(255,0,255,255);
/**
* Constant for the color cyan
*/
public static final Color cyan = new Color(0,255,255,255);
/**
* Constant for the color blue
*/
public static final Color blue = new Color(0,0,255,255);
// Serialization Constant
private static final long serialVersionUID = 118526816881161077L;
// Masks for individual color components
private static final int redmask = 255 << 16;
private static final int greenmask = 255 << 8;
private static final int bluemask = 255;
private static final int alphamask = 255 << 24;
private static final int BRIGHT_STEP = 0x30;
/*************************************************************************/
/*
* Instance Variables
*/ */
/** /**
* Written using on-line Java Platform 1.2 API Specification, as well * @serial The RGB value of the color.
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). */
* Status: Stubbed; A very incomplete implementation. private int value = 0xFFFFFFFF;
/*************************************************************************/
/*
* Static Methods
*/ */
public class Color extends Object implements Paint, java.io.Serializable /**
{ * Converts the specified string to a number and creates a new instance
public static final Color white = new Color(0xFFFFFFFF, true); * of <code>Color</code> from the value.
public static final Color lightGray = new Color(0xFFC0C0C0, true); *
public static final Color gray = new Color(0xFF808080, true); * @param str The numeric color string.
public static final Color darkGray = new Color(0xFF404040, true); *
public static final Color black = new Color(0xFF000000, true); * @return A new instance of <code>Color</code> for the string.
public static final Color red = new Color(0xFFFF0000, true); *
public static final Color pink = new Color(0xFFFFAFAF, true); * @exception NumberFormatException If the string cannot be parsed.
public static final Color orange = new Color(0xFFFFC800, true); */
public static final Color yellow = new Color(0xFFFFFF00, true); public static Color
public static final Color green = new Color(0xFF00FF00, true); decode(String str) throws NumberFormatException
public static final Color magenta = new Color(0xFFFF00FF, true); {
public static final Color cyan = new Color(0xFF00FFFF, true); Integer i = Integer.decode(str);
public static final Color blue = new Color(0xFF0000FF, true); return(new Color(i.intValue()));
}
// The internal sRGB representation.
// Alpha is bits 24-31, if hasalpha is true. /*************************************************************************/
// Red is bits 16-23; Green is bits 8-15; Blue is bits 0-7.
int rgba = 0xFFFFFFFF; /**
* Returns a new instance of <code>Color</code> from the value of
public Color(int rgb) * the system property named by the specified string. If the property
{ * does not exist, or cannot be parsed, then <code>null</code> will be
this(rgb, false); * returned.
} *
* @param prop The system property to retrieve.
public Color(int rgba, boolean hasalpha) */
{ public static Color
this.rgba = rgba; getColor(String prop)
if (!hasalpha) {
rgba |= 0xFF000000; return(getColor(prop, null));
} }
public Color(int r, int g, int b) /*************************************************************************/
{
this(r, g, b, 0xFF); /**
} * Returns a new instance of <code>Color</code> from the value of the
* system property named by the specified string. If the property does
public Color(int r, int g, int b, int a) * not exist, or cannot be parsed, then the default RGB value will be
{ * used to create a return value.
rgba = a << 24 | ((r << 16) & 0x00FF0000) | ((g << 8) & 0x0000FF00) | *
(b & 0x000000FF); * @param prop The system property to retrieve.
} * @param defrgb The default RGB value.
*/
public int getRed() public static Color
{ getColor(String prop, int defrgb)
return (rgba >> 16) & 0xFF; {
} return(getColor(prop, new Color(defrgb)));
}
public int getGreen()
{ /*************************************************************************/
return (rgba >> 8) & 0xFF;
} /**
* Returns a new instance of <code>Color</code> from the value of the
public int getBlue() * system property named by the specified string. If the property does
{ * not exist, or cannot be parsed, then the default color value will be
return rgba & 0xFF; * returned
} *
* @param prop The system property to retrieve.
public int getAlpha() * @param defcolor The default color
{ */
return (rgba >> 24) & 0xFF; public static Color
} getColor(String prop, Color defcolor)
{
public int getRGB() String val = System.getProperty(prop);
{ if (val == null)
return rgba; return(defcolor);
}
try
static final int BRIGHT_STEP = 0x30; {
return(decode(val));
public Color brighter() }
{ catch(NumberFormatException e)
return new Color(Math.min(255, getRed() + BRIGHT_STEP), {
Math.min(255, getGreen() + BRIGHT_STEP), return(defcolor);
Math.min(255, getBlue() + BRIGHT_STEP), }
getAlpha()); }
}
/*************************************************************************/
public Color darker()
{ /**
return new Color(Math.max(0, getRed() - BRIGHT_STEP), * Converts from the HSB (hue, saturation, brightness) color model to
Math.max(0, getGreen() - BRIGHT_STEP), * the RGB (red, green, blue) color model.
Math.max(0, getBlue() - BRIGHT_STEP), *
getAlpha()); * @param hue The hue of the HSB value.
} * @param saturation The saturation of the HSB value.
* @param brightness The brightness of the HSB value.
public int hashCode() *
{ * @return The RGB value.
return rgba; */
} public static int
HSBtoRGB(float hue, float saturation, float brightness)
public int getTransparency() {
{ // FIXME: Implement
if (getAlpha() == 0xFF) throw new RuntimeException("Not implemented yet");
return Transparency.OPAQUE; }
else
return Transparency.TRANSLUCENT; /*************************************************************************/
}
/**
* Converts from the RGB (red, green, blue) color model to the HSB
* (hue, saturation, brightness) color model.
*
* @param red The red part of the RGB value.
* @param green The green part of the RGB value.
* @param blue The blue part of the RGB value.
* @param hsbvals An array of three floats used for storing the HSB values,
* or <code>null</code> if this return mechanism is not used.
*
* @return The HSB value.
*/
public static float[]
RGBtoHSB(int red, int green, int blue, float hsbvals[])
{
// FIXME: Implement
throw new RuntimeException("Not implemented yet");
}
/*************************************************************************/
/**
* Returns a new instance of <code>Color</code> based on the specified
* HSB values.
*
* @param hue The hue of the HSB value.
* @param saturation The saturation of the HSB value.
* @param brightness The brightness of the HSB value.
*
* @return The new <code>Color</code> object.
*/
public static Color
getHSBColor(float hue, float saturation, float brightness)
{
return(new Color(HSBtoRGB(hue, saturation, brightness)));
} }
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>Color</code> using the specified
* red, green, and blue values, which must be given as integers in the
* range of 0-255.
*
* @param red The red component of the RGB value.
* @param green The green component of the RGB value.
* @param blue The blue component of the RGB value.
*
* @exception IllegalArgumentException If the values are out of range.
*/
public
Color(int red, int green, int blue)
{
if ((red < 0) || (red > 255) || (green < 0) || (green > 255) ||
(blue < 0) || (blue > 255))
throw new IllegalArgumentException("Bad RGB values");
value = blue + (green << 8) + (red << 16);
}
public
Color(int red, int green, int blue, int alpha)
{
if ((red < 0) || (red > 255) || (green < 0) || (green > 255) ||
(blue < 0) || (blue > 255))
throw new IllegalArgumentException("Bad RGB values");
value = blue + (green << 8) + (red << 16) + (alpha << 24);
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Color</code> using the specified
* RGB value. The blue value is in bits 0-7, green in bits 8-15, and
* red in bits 16-23. The other bits are ignored.
*
* @param value The RGB value
*/
public
Color(int value)
{
this.value = value;
}
public
Color(int value, boolean hasalpha)
{
this.value = value;
if (! hasalpha)
this.value |= 0xFF000000;
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Color</code> using the specified
* RGB values. These must be in the range of 0.0-1.0.
*
* @param red The red component of the RGB value.
* @param green The green component of the RGB value.
* @param blue The blue component of the RGB value.
*
* @exception IllegalArgumentException If the values are out of range.
*/
public
Color(float red, float green, float blue)
{
if ((red < 0.0) || (red > 1.0) || (green < 0.0) || (green > 1.0) ||
(blue < 0.0) || (blue > 1.0))
throw new IllegalArgumentException("Bad RGB values");
int redval = (int)(255 * red);
int greenval = (int)(255 * green);
int blueval = (int)(255 * blue);
value = blueval + (greenval << 8) + (redval << 16);
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Returns the red value for this color.
*
* @return The red value for this color.
*/
public int
getRed()
{
int redval = (value & redmask) >> 16;
return(redval);
}
/*************************************************************************/
/**
* Returns the green value for this color.
*
* @return The green value for this color.
*/
public int
getGreen()
{
int greenval = (value & greenmask) >> 8;
return(greenval);
}
/*************************************************************************/
/**
* Returns the blue value for this color.
*
* @return The blue value for this color.
*/
public int
getBlue()
{
int blueval = (value & bluemask);
return(blueval);
}
public int
getAlpha()
{
int alphaval = (value & alphamask);
return(alphaval);
}
public int
getTransparency()
{
if (getAlpha() == 0xFF)
return Transparency.OPAQUE;
else
return Transparency.TRANSLUCENT;
}
/*************************************************************************/
/**
* Returns the RGB value for this color. The blue value will be in bits
* 0-7, green in 8-15, and red in 6-23. The upper bits should be ignored.
*
* @return The RGB value for this color.
*/
public int
getRGB()
{
return(value);
}
/*************************************************************************/
/**
* Returns a brighter version of this color. This is done by increasing
* the RGB values by an arbitrary scale factor. Note that this method
* and the <code>darker()</code> method are not necessarily inverses.
*
* @return A brighter version of this color.
*/
public Color
brighter()
{
return new Color(Math.min(255, getRed() + BRIGHT_STEP),
Math.min(255, getGreen() + BRIGHT_STEP),
Math.min(255, getBlue() + BRIGHT_STEP),
getAlpha());
}
/*************************************************************************/
/**
* Returns a darker version of this color. This is done by decreasing
* the RGB values by an arbitrary scale factor. Note that this method
* and the <code>brighter()</code> method are not necessarily inverses.
*
* @return A darker version of this color.
*/
public Color
darker()
{
return new Color(Math.max(0, getRed() - BRIGHT_STEP),
Math.max(0, getGreen() - BRIGHT_STEP),
Math.max(0, getBlue() - BRIGHT_STEP),
getAlpha());
}
/*************************************************************************/
/**
* Returns a hash value for this color.
*
* @return A hash value for this color.
*/
public int
hashCode()
{
return(value);
}
/*************************************************************************/
/**
* Tests this object for equality against the specified object. This will
* be true if and only if the specified object is an instance of
* <code>Color</code> and has the same red, green, and blue values as
* this object.
*
* @return <code>true</code> if the specified object is equal to this one,
* <code>false</code> otherwise.
*/
public boolean
equals(Object obj)
{
if (!(obj instanceof Color))
return(false);
Color c = (Color)obj;
return value == c.value;
}
/*************************************************************************/
/**
* Returns a string representation of this object.
*
* @return A string representation of this object.
*/
public String
toString()
{
return(getClass().getName() + "(red=" + getRed() + ",green=" + getGreen() +
",blue=" + getBlue() + ")");
}
} // class Color
/* Copyright (C) 2000 Free Software Foundation /* Copyright (C) 1999, 2000, 2002 Free Software Foundation
This file is part of libgcj. This file is part of GNU Classpath.
This software is copyrighted work licensed under the terms of the GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
package java.awt; GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
/* A somewhat incomplete placeholder. */
package java.awt;
/**
* This class represents various predefined cursor types.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class Cursor implements java.io.Serializable public class Cursor implements java.io.Serializable
{ {
public static final int DEFAULT_CURSOR = 0, /**
CROSSHAIR_CURSOR = 1, * Constant for the system default cursor type
TEXT_CURSOR = 2, */
WAIT_CURSOR = 3, public static final int DEFAULT_CURSOR = 0;
SW_RESIZE_CURSOR = 4,
SE_RESIZE_CURSOR = 5, /**
NW_RESIZE_CURSOR = 6, * Constant for a cross-hair cursor.
NE_RESIZE_CURSOR = 7, */
N_RESIZE_CURSOR = 8, public static final int CROSSHAIR_CURSOR = 1;
S_RESIZE_CURSOR = 9,
W_RESIZE_CURSOR = 10, /**
E_RESIZE_CURSOR = 11, * Constant for a cursor over a text field.
HAND_CURSOR = 12, */
MOVE_CURSOR = 13, public static final int TEXT_CURSOR = 2;
CUSTOM_CURSOR = 0xFFFFFFFF;
/**
* Constant for a cursor to display while waiting for an action to complete.
*/
public static final int WAIT_CURSOR = 3;
/**
* Cursor used over SW corner of window decorations.
*/
public static final int SW_RESIZE_CURSOR = 4;
/**
* Cursor used over SE corner of window decorations.
*/
public static final int SE_RESIZE_CURSOR = 5;
/**
* Cursor used over NW corner of window decorations.
*/
public static final int NW_RESIZE_CURSOR = 6;
/**
* Cursor used over NE corner of window decorations.
*/
public static final int NE_RESIZE_CURSOR = 7;
/**
* Cursor used over N edge of window decorations.
*/
public static final int N_RESIZE_CURSOR = 8;
/**
* Cursor used over S edge of window decorations.
*/
public static final int S_RESIZE_CURSOR = 9;
/**
* Cursor used over W edge of window decorations.
*/
public static final int W_RESIZE_CURSOR = 10;
/**
* Cursor used over E edge of window decorations.
*/
public static final int E_RESIZE_CURSOR = 11;
/**
* Constant for a hand cursor.
*/
public static final int HAND_CURSOR = 12;
/**
* Constant for a cursor used during window move operations.
*/
public static final int MOVE_CURSOR = 13;
public static final int CUSTOM_CURSOR = 0xFFFFFFFF;
private static final int PREDEFINED_COUNT = 14; private static final int PREDEFINED_COUNT = 14;
protected static Cursor[] predefined = new Cursor[PREDEFINED_COUNT]; protected static Cursor[] predefined = new Cursor[PREDEFINED_COUNT];
protected String name; protected String name;
/**
* @serial The numeric id of this cursor.
*/
int type; int type;
/**
* Initializes a new instance of <code>Cursor</code> with the specified
* type.
*
* @param type The cursor type.
*/
public Cursor(int type) public Cursor(int type)
{ {
if (type < 0 || type >= PREDEFINED_COUNT) if (type < 0 || type >= PREDEFINED_COUNT)
...@@ -43,14 +130,25 @@ public class Cursor implements java.io.Serializable ...@@ -43,14 +130,25 @@ public class Cursor implements java.io.Serializable
} }
/** This constructor is used internally only. /** This constructor is used internally only.
* Application code should call Toolkit.createCustomCursor(). * Application code should call Toolkit.createCustomCursor().
*/ */
protected Cursor(String name) protected Cursor(String name)
{ {
this.name = name; this.name = name;
this.type = CUSTOM_CURSOR; this.type = CUSTOM_CURSOR;
} }
/**
* Returns an instance of <code>Cursor</code> for one of the specified
* predetermined types.
*
* @param type The type contant from this class.
*
* @return The requested predefined cursor.
*
* @exception IllegalArgumentException If the constant is not one of the
* predefined cursor type constants from this class.
*/
public static Cursor getPredefinedCursor(int type) public static Cursor getPredefinedCursor(int type)
{ {
if (type < 0 || type >= PREDEFINED_COUNT) if (type < 0 || type >= PREDEFINED_COUNT)
...@@ -67,11 +165,21 @@ public class Cursor implements java.io.Serializable ...@@ -67,11 +165,21 @@ public class Cursor implements java.io.Serializable
return null; return null;
} }
/**
* Returns an instance of the system default cursor type.
*
* @return The system default cursor.
*/
public static Cursor getDefaultCursor() public static Cursor getDefaultCursor()
{ {
return getPredefinedCursor(0); return getPredefinedCursor(DEFAULT_CURSOR);
} }
/**
* Returns the numeric type identifier for this cursor.
*
* @return The cursor id.
*/
public int getType() public int getType()
{ {
return type; return type;
......
/* Copyright (C) 2000, 2001 Free Software Foundation /* Dialog.java -- An AWT dialog box
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.peer.DialogPeer; import java.awt.peer.DialogPeer;
import java.awt.peer.WindowPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.ComponentPeer;
/**
* A dialog box widget class.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@redhat.com>
*/
public class Dialog extends Window implements java.io.Serializable
{
/*
* Static Variables
*/
// Serialization constant
private static final long serialVersionUID = 5920926903803293709L;
/*************************************************************************/
/*
* Instance Variables
*/
/**
* @serial Indicates whether or not this dialog box is modal.
*/
private boolean modal;
/**
* @serial Indicates whether or not this dialog box is resizable.
*/
private boolean resizable;
/**
* @serial The title string for this dialog box, which can be
* <code>null</code>.
*/
private String title;
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent, that is not resizable and not modal, and which has no title.
*
* @param parent The parent frame of this dialog box.
*/
public
Dialog(Frame parent)
{
this(parent, "", false);
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent and modality, that is not resizable and which has no title.
*
* @param parent The parent frame of this dialog box.
* @param modal <true> if this dialog box is modal, <code>false</code>
* otherwise.
*/
public
Dialog(Frame parent, boolean modal)
{
this(parent, "", modal);
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent, that is not resizable and not modal, and which has the specified
* title.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
*/
public
Dialog(Frame parent, String title)
{
this(parent, title, false);
}
/*************************************************************************/
/** /**
* @author Tom Tromey <tromey@redhat.com> * Initializes a new instance of <code>Dialog</code> with the specified,
* @date April 17, 2001 * parent, title, and modality, that is not resizable.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
* @param modal <true> if this dialog box is modal, <code>false</code>
* otherwise.
*/
public
Dialog(Frame parent, String title, boolean modal)
{
super(parent);
this.title = title;
this.modal = modal;
resizable = false;
setLayout(new BorderLayout());
}
public
Dialog (Dialog owner)
{
this (owner, "", false);
}
public
Dialog (Dialog owner, String title)
{
this (owner, title, false);
}
public
Dialog (Dialog owner, String title, boolean modal)
{
super (owner);
this.modal = modal;
this.title = title;
setLayout (new BorderLayout ());
}
/*************************************************************************/
/*
* Instance Variables
*/ */
public class Dialog extends Window /**
{ * Returns the title of this dialog box.
public Dialog (Dialog owner) *
{ * @return The title of this dialog box.
this (owner, "", false); */
} public String
getTitle()
public Dialog (Dialog owner, String title) {
{ return(title);
this (owner, title, false); }
}
/*************************************************************************/
public Dialog (Dialog owner, String title, boolean modal)
{ /**
super (owner); * Sets the title of this dialog box to the specified string.
this.modal = modal; *
this.title = title; * @param title The new title.
setLayout (new BorderLayout ()); */
} public synchronized void
setTitle(String title)
public Dialog (Frame owner) {
{ this.title = title;
this (owner, "", false); if (peer != null)
} {
DialogPeer d = (DialogPeer) peer;
public Dialog (Frame owner, boolean modal) d.setTitle (title);
{ }
this (owner, "", modal); }
}
/*************************************************************************/
public Dialog (Frame owner, String title)
{ /**
this (owner, title, false); * Tests whether or not this dialog box is modal.
} *
* @return <code>true</code> if this dialog box is modal,
public Dialog (Frame owner, String title, boolean modal) * <code>false</code> otherwise.
{ */
super (owner); public boolean
this.modal = modal; isModal()
this.title = title; {
setLayout (new BorderLayout ()); return(modal);
} }
/** Create the peer if it does not already exist. */ /*************************************************************************/
public void addNotify ()
{ /**
if (peer == null) * Changes the modality of this dialog box. This can only be done before
peer = getToolkit ().createDialog (this); * the peer is created.
super.addNotify (); *
} * @param modal <code>true</code> to make this dialog box modal,
* <code>false</code> to make it non-modal.
public boolean isModal () */
{ public void
return modal; setModal(boolean modal)
} {
this.modal = modal;
public void setModal (boolean modal) }
{
this.modal = modal; /*************************************************************************/
}
/**
public String getTitle () * Tests whether or not this dialog box is resizable.
{ *
return title; * @return <code>true</code> if this dialog is resizable, <code>false</code>,
} * otherwise.
*/
public void setTitle (String title) public boolean
{ isResizable()
this.title = title; {
if (peer != null) return(resizable);
{ }
DialogPeer d = (DialogPeer) peer;
d.setTitle (title); /*************************************************************************/
}
} /**
* Changes the resizability of this dialog box.
public void show () *
{ * @param resizable <code>true</code> to make this dialog resizable,
boolean vis = isVisible (); * <code>false</code> to make it non-resizable.
super.show (); */
if (modal && vis) public synchronized void
{ setResizable(boolean resizable)
// Don't return until something happens. We lock on the peer {
// instead of `this' so that we don't interfere with whatever this.resizable = resizable;
// locks the caller might want to use. if (peer != null)
synchronized (peer) {
{ DialogPeer d = (DialogPeer) peer;
try d.setResizable (resizable);
{ }
peer.wait (); }
}
catch (InterruptedException _) /*************************************************************************/
{
} /**
} * Creates this object's native peer.
} */
} public synchronized void
addNotify()
public void hide () {
{ if (peer == null)
super.hide (); peer = getToolkit ().createDialog (this);
synchronized (peer) super.addNotify ();
{
peer.notify ();
}
}
public void dispose ()
{
super.dispose ();
synchronized (peer)
{
peer.notify ();
}
}
public boolean isResizable ()
{
return resizable;
}
public void setResizable (boolean resizable)
{
this.resizable = resizable;
if (peer != null)
{
DialogPeer d = (DialogPeer) peer;
d.setResizable (resizable);
}
}
protected String paramString ()
{
return ("Dialog["
+ title + ","
+ modal + ","
+ resizable + "]");
}
// True if dialog is modal.
private boolean modal;
// True if dialog is resizable by the user.
private boolean resizable = false;
// Dialog title.
private String title;
} }
/*************************************************************************/
/**
* Makes this dialog visible and brings it to the front.
*/
public void
show()
{
super.show();
}
/*************************************************************************/
/**
* Returns a debugging string for this component.
*
* @return A debugging string for this component.
*/
protected String
paramString()
{
return ("title+" + title + ",modal=" + modal +
",resizable=" + resizable + "," + super.paramString());
}
} // class Dialog
/* Copyright (C) 2000, 2001 Free Software Foundation /* FileDialog.java -- A filename selection dialog box
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.peer.FileDialogPeer; import java.awt.peer.FileDialogPeer;
import java.awt.peer.DialogPeer;
import java.awt.peer.WindowPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.ComponentPeer;
import java.io.FilenameFilter; import java.io.FilenameFilter;
/** /**
* @author Tom Tromey <tromey@redhat.com> * This class implements a file selection dialog box widget.
* @date April 20, 2001 *
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@redhat.com>
*/
public class FileDialog extends Dialog implements java.io.Serializable
{
/*
* Static Variables
*/
/**
* Indicates that the purpose of the dialog is for opening a file.
*/
public static final int LOAD = 0;
/**
* Indicates that the purpose of the dialog is for saving a file.
*/
public static final int SAVE = 1;
// Serialization constant
private static final long serialVersionUID = 5035145889651310422L;
/*************************************************************************/
/*
* Instance Variables
*/ */
public class FileDialog extends Dialog /**
* @serial The directory for this file dialog.
*/
private String dir;
/**
* @serial The filename for this file dialog
*/
private String file;
/**
* @serial The filter for selecting filenames to display
*/
private FilenameFilter filter;
/**
* @serial The mode of this dialog, either <code>LOAD</code> or
* <code>SAVE</code>.
*/
private int mode;
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>FileDialog</code> with the
* specified parent. This dialog will have no title and will be for
* loading a file.
*
* @param parent The parent frame for this dialog.
*/
public
FileDialog(Frame parent)
{
this(parent, "", LOAD);
}
/*************************************************************************/
/**
* Initialized a new instance of <code>FileDialog</code> with the
* specified parent and title. This dialog will be for opening a file.
*
* @param parent The parent frame for this dialog.
* @param title The title for this dialog.
*/
public
FileDialog(Frame parent, String title)
{ {
public static int LOAD = 0; this(parent, title, LOAD);
public static int SAVE = 1;
public FileDialog (Frame parent)
{
this (parent, "", LOAD);
}
public FileDialog (Frame parent, String title)
{
this (parent, title, LOAD);
}
public FileDialog (Frame parent, String title, int mode)
{
super (parent, title, true);
if (mode != LOAD && mode != SAVE)
throw new IllegalArgumentException ("unknown mode: " + mode);
this.mode = mode;
}
public void addNotify ()
{
if (peer == null)
peer = getToolkit ().createFileDialog (this);
super.addNotify ();
}
public String getDirectory ()
{
return dir;
}
public String getFile ()
{
return file;
}
public FilenameFilter getFilenameFilter ()
{
return filter;
}
public int getMode ()
{
return mode;
}
protected String paramString ()
{
return ("FileDialog[mode=" + mode
+ ",dir=" + dir
+ ",file=" + file + "]");
}
public void setDirectory (String dir)
{
this.dir = dir;
if (peer != null)
{
FileDialogPeer f = (FileDialogPeer) peer;
f.setDirectory (dir);
}
}
public void setFile (String file)
{
this.file = file;
if (peer != null)
{
FileDialogPeer f = (FileDialogPeer) peer;
f.setFile (file);
}
}
public void setFilenameFilter (FilenameFilter filter)
{
this.filter = filter;
if (peer != null)
{
FileDialogPeer f = (FileDialogPeer) peer;
f.setFilenameFilter (filter);
}
}
public void setMode (int mode)
{
if (mode != LOAD && mode != SAVE)
throw new IllegalArgumentException ("unknown mode: " + mode);
this.mode = mode;
// FIXME: update peer?
}
// Names here from serialization spec.
private int mode;
private String dir;
private String file;
private FilenameFilter filter;
} }
/*************************************************************************/
/**
* Initialized a new instance of <code>FileDialog</code> with the
* specified parent, title, and mode.
*
* @param parent The parent frame for this dialog.
* @param title The title for this dialog.
* @param mode The mode of the dialog, either <code>LOAD</code> or
* <code>SAVE</code>.
*/
public
FileDialog(Frame parent, String title, int mode)
{
super(parent, title, true);
if ((mode != LOAD) && (mode != SAVE))
throw new IllegalArgumentException("Bad mode: " + mode);
this.mode = mode;
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Returns the mode of this dialog, either <code>LOAD</code> or
* <code>SAVE</code>.
*
* @return The mode of this dialog.
*/
public int
getMode()
{
return(mode);
}
/*************************************************************************/
/**
* Sets the mode of this dialog to either <code>LOAD</code> or
* <code>SAVE</code>. This method is only effective before the native
* peer is created.
*
* @param mode The new mode of this file dialog.
*/
public void
setMode(int mode)
{
if ((mode != LOAD) && (mode != SAVE))
throw new IllegalArgumentException("Bad mode: " + mode);
this.mode = mode;
}
/*************************************************************************/
/**
* Returns the directory for this file dialog.
*
* @return The directory for this file dialog.
*/
public String
getDirectory()
{
return(dir);
}
/*************************************************************************/
/**
* Sets the directory for this file dialog.
*
* @param dir The new directory for this file dialog.
*/
public synchronized void
setDirectory(String dir)
{
this.dir = dir;
if (peer != null)
{
FileDialogPeer f = (FileDialogPeer) peer;
f.setDirectory (dir);
}
}
/*************************************************************************/
/**
* Returns the file that is selected in this dialog.
*
* @return The file that is selected in this dialog.
*/
public String
getFile()
{
return(file);
}
/*************************************************************************/
/**
* Sets the selected file for this dialog.
*
* @param file The selected file for this dialog.
*/
public synchronized void
setFile(String file)
{
this.file = file;
if (peer != null)
{
FileDialogPeer f = (FileDialogPeer) peer;
f.setFile (file);
}
}
/*************************************************************************/
/**
* Returns the filename filter being used by this dialog.
*
* @param The filename filter being used by this dialog.
*/
public FilenameFilter
getFilenameFilter()
{
return(filter);
}
/*************************************************************************/
/**
* Sets the filename filter used by this dialog.
*
* @param filter The new filename filter for this file dialog box.
*/
public synchronized void
setFilenameFilter(FilenameFilter filter)
{
this.filter = filter;
if (peer != null)
{
FileDialogPeer f = (FileDialogPeer) peer;
f.setFilenameFilter (filter);
}
}
/*************************************************************************/
/**
* Creates the native peer for this file dialog box.
*/
public void
addNotify()
{
if (peer == null)
peer = getToolkit ().createFileDialog (this);
super.addNotify ();
}
/*************************************************************************/
/**
* Returns a debugging string for this object.
*
* @return A debugging string for this object.
*/
protected String
paramString()
{
return ("dir=" + dir + ",file=" + file +
",mode=" + mode + "," + super.paramString());
}
} // class FileDialog
/* Copyright (C) 1999, 2000 Free Software Foundation /* Font.java -- Font object
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libjava. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt; package java.awt;
import java.util.Locale; import java.awt.peer.FontPeer;
import java.util.StringTokenizer;
/**
* This class represents a windowing system font.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy <warrenl@cygnus.com>
*/
public class Font implements java.io.Serializable
{
/*
* Static Variables
*/
/**
* Constant indicating a "plain" font.
*/
public static final int PLAIN = 0;
/**
* Constant indicating a "bold" font.
*/
public static final int BOLD = 1;
/**
* Constant indicating an "italic" font.
*/
public static final int ITALIC = 2;
public static final int ROMAN_BASELINE = 0;
public static final int CENTER_BASELINE = 1;
public static final int HANGING_BASELINE = 2;
// Serialization constant
private static final long serialVersionUID = -4206021311591459213L;
/*************************************************************************/
/*
* Instance Variables
*/
/**
* The name of this font
*/
protected String name;
/**
* The font style, which is a combination (by summing, not OR-ing) of
* the font style constants in this class.
*/
protected int style;
/**
* The font point size.
*/
protected int size;
protected float pointSize;
// The native peer for this font
private FontPeer peer;
/*************************************************************************/
/*
* Static Methods
*/
/** /**
* @author Warren Levy <warrenl@cygnus.com> * Creates a <code>Font</code> object from the specified string, which
* @date March 16, 2000. * is in one of the following formats:
* <p>
* <ul>
* <li>fontname-style-pointsize
* <li>fontname-style
* <li>fontname-pointsize
* <li>fontname
* </ul>
* <p>
* The style should be one of BOLD, ITALIC, or BOLDITALIC. The default
* style if none is specified is PLAIN. The default size if none
* is specified is 12.
*/
public static Font
decode(String fontspec)
{
String name = null;
int style = PLAIN;
int size = 12;
StringTokenizer st = new StringTokenizer(fontspec, "-");
while (st.hasMoreTokens())
{
String token = st.nextToken();
if (name == null)
{
name = token;
continue;
}
if (token.toUpperCase().equals("BOLD"))
{
style = BOLD;
continue;
}
if (token.toUpperCase().equals("ITALIC"))
{
style = ITALIC;
continue;
}
if (token.toUpperCase().equals("BOLDITALIC"))
{
style = BOLD + ITALIC;
continue;
}
int tokenval = 0;
try
{
tokenval = Integer.parseInt(token);
}
catch(Exception e) { ; }
if (tokenval != 0)
size = tokenval;
}
return(new Font(name, style, size));
}
/*************************************************************************/
/**
* Returns a <code>Font</code> object from the passed property name.
*
* @param propname The name of the system property.
* @param default Value to use if the property is not found.
*
* @return The requested font, or <code>default</code> if the property
* not exist or is malformed.
*/
public static Font
getFont(String propname, Font defval)
{
String propval = System.getProperty(propname);
if (propval != null)
return(decode(propval));
return(defval);
}
/*************************************************************************/
/**
* Returns a <code>Font</code> object from the passed property name.
*
* @param propname The name of the system property.
*
* @return The requested font, or <code>null</code> if the property
* not exist or is malformed.
*/
public static Font
getFont(String propname)
{
return(getFont(propname, null));
}
/*************************************************************************/
/*
* Constructors
*/ */
/** /**
* Written using on-line Java Platform 1.2 API Specification, as well * Initializes a new instance of <code>Font</code> with the specified
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * attributes.
* Status: Stubbed; A very incomplete implementation. *
* @param name The name of the font.
* @param style The font style.
* @param size The font point size.
*/
public
Font(String name, int style, int size)
{
this.name = name;
this.style = style;
this.size = size;
this.pointSize = size;
}
/*************************************************************************/
/*
* Instance Methods
*/ */
public class Font /**
{ * Returns the name of the font.
// FIXME *
* @return The name of the font.
public static final int PLAIN = 0; */
public static final int BOLD = 1; public String
public static final int ITALIC = 2; getName()
public static final int ROMAN_BASELINE = 0; {
public static final int CENTER_BASELINE = 1; return(name);
public static final int HANGING_BASELINE = 2; }
protected String name;
protected int style; /*************************************************************************/
protected int size;
protected float pointSize; /**
* Returns the style of the font.
public Font(String name, int style, int size) *
{ * @return The font style.
this.name = name; */
this.style = style & 0x3; // Only use lowest 2 bits. public int
this.size = size; getSize()
pointSize = size; // Assume some subclass can set a different val. {
} return(size);
}
public boolean isPlain()
{ public float
if (style == PLAIN) getSize2D()
return true; {
return pointSize;
return false; }
}
/*************************************************************************/
public boolean isBold()
{ /**
if ((style & BOLD) == BOLD) * Tests whether or not this is a plain font. This will be true if
return true; * and only if neither the bold nor the italics style is set.
*
return false; * @return <code>true</code> if this is a plain font, <code>false</code>
} * otherwise.
*/
public boolean isItalic() public boolean
{ isPlain()
if ((style & ITALIC) == ITALIC) {
return true; if (style == PLAIN)
return(true);
return false; else
} return(false);
}
public String getName()
{ /*************************************************************************/
return name;
} /**
* Tests whether or not this font is bold.
public String getFamily() *
{ * @return <code>true</code> if this font is bold, <code>false</code>
// FIXME * otherwise.
return null; */
} public boolean
isBold()
public String getFamily(Locale l) {
{ if ((style == BOLD) || (style == (BOLD+ITALIC)))
// FIXME return(true);
return null; else
} return(false);
}
public int getStyle()
{ /*************************************************************************/
return style;
} /**
* Tests whether or not this font is italic.
public int getSize() *
{ * @return <code>true</code> if this font is italic, <code>false</code>
return size; * otherwise.
} */
public boolean
public float getSize2D() isItalic()
{ {
return pointSize; if ((style == ITALIC) || (style == (BOLD+ITALIC)))
} return(true);
else
public static Font decode(String str) { return null; } // FIXME return(false);
}
public String toString()
{ /*************************************************************************/
String style_str = "";
if (isPlain()) /**
style_str = "plain"; * Returns the system specific font family name.
else *
{ * @return The system specific font family name.
if (isBold()) */
style_str += "bold"; public String
if (isItalic()) getFamily()
style_str += "italic"; {
} // FIXME: How do I implement this?
return getClass().getName() + "[family=" + getFamily() + ",name=" + return(name);
getName() + ",style=" + style_str + ",size=" + getSize() + "]"; }
}
public int
getStyle()
{
return style;
}
/*************************************************************************/
/**
* Returns a native peer object for this font.
*
* @return A native peer object for this font.
*/
public FontPeer
getPeer()
{
if (peer != null)
return(peer);
peer = Toolkit.getDefaultToolkit().getFontPeer(name, style);
return(peer);
} }
/*************************************************************************/
/**
* Returns a hash value for this font.
*
* @return A hash for this font.
*/
public int
hashCode()
{
return((new String(name + size + style)).hashCode());
}
/*************************************************************************/
/**
* Tests whether or not the specified object is equal to this font. This
* will be true if and only if:
* <P>
* <ul>
* <li>The object is not <code>null</code>.
* <li>The object is an instance of <code>Font</code>.
* <li>The object has the same name, style, and size as this object.
* </ul>
*
* @return <code>true</code> if the specified object is equal to this
* object, <code>false</code> otherwise.
*/
public boolean
equals(Object obj)
{
if (obj == null)
return(false);
if (!(obj instanceof Font))
return(false);
Font f = (Font)obj;
if (!f.name.equals(name))
return(false);
if (f.size != size)
return(false);
if (f.style != style)
return(false);
return(true);
}
/*************************************************************************/
/**
* Returns a string representation of this font.
*
* @return A string representation of this font.
*/
public String
toString()
{
return(getClass().getName() + "(name=" + name + ",style=" + style +
",size=" + size + ")");
}
} // class Font
/* Copyright (C) 2000 Free Software Foundation /* FontMetrics.java -- Information about about a fonts display characteristics
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
// FIXME: I leave many methods basically unimplemented. This
// should be reviewed.
/** /**
* Status: Stubbed; A very incomplete implementation. * This class returns information about the display characteristics of
* a font. It is abstract, and concrete subclasses should implement at
* least the following methods:
* <p>
* <ul>
* <li>getAscent
* <li>getDescent
* <li>getLeading()
* <li>getMaxAdvance()
* <li>charWidth(char)
* <li>charsWidth(char[], int, int)
* </ul>
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public abstract class FontMetrics implements java.io.Serializable
{
/*
* Static Variables
*/ */
public class FontMetrics implements java.io.Serializable // Serialization constant
{ private static final long serialVersionUID = 1681126225205050147L;
protected Font font;
/*************************************************************************/
protected FontMetrics(Font font)
{ /*
this.font = font; * Instance Variables
} */
public Font getFont() /**
{ * This is the font for which metrics will be returned.
return font; */
} protected Font font;
public int getLeading() /*************************************************************************/
{
return getMaxAscent() + getMaxDescent() - (getAscent() + getDescent()); /*
} * Constructors
*/
public int getAscent()
{ /**
return getHeight() - (getDescent() + getLeading()); * Initializes a new instance of <code>FontMetrics</code> for the
} * specified font.
*
public int getDescent() * @param font The font to return metric information for.
{ */
return getHeight() - (getLeading() + getDescent()); protected
} FontMetrics(Font font)
{
public int getHeight() this.font = font;
{ }
return getLeading() + getAscent() + getDescent();
} /*************************************************************************/
public int getMaxAscent() /*
{ * Instance Methods
return getAscent(); */
}
/**
public int getMaxDescent() * Returns the font that this object is creating metric information fo.
{ *
return getDescent(); * @return The font for this object.
} */
public Font
/* @deprecated Use getMaxDescent() instead. */ getFont()
public int getMaxDecent() {
{ return(font);
return getMaxDescent(); }
}
/*************************************************************************/
/** @return max advance, or -1 if unknown. */
public int getMaxAdvance() /**
{ * Returns the leading, or spacing between lines, for this font.
return -1; *
} * @return The font leading.
*/
public int
public int charWidth(int ch) getLeading()
{ {
return charWidth((char) ch); return(0);
} }
public int charWidth(char ch) /*************************************************************************/
{
Character chObj = new Character(ch); /**
return stringWidth(chObj.toString()); * Returns the ascent of the font, which is the distance from the base
} * to the top of the majority of characters in the set. Some characters
* can exceed this value however.
public int stringWidth(String str) *
{ * @return The font ascent.
return charsWidth(str.toCharArray(), 0, str.length()); */
} public int
getAscent()
public int charsWidth(char[] data, int off, int len) {
{ return(1);
return stringWidth(new String(data, off, len)); }
}
/*************************************************************************/
public int bytesWidth(byte[] data, int off, int len)
{ /**
return stringWidth(new String(data, off, len)); * Returns the descent of the font, which is the distance from the base
} * to the bottom of the majority of characters in the set. Some characters
* can exceed this value however.
public int[] getWidths() *
{ * @return The font descent.
int[] widths = new int[256]; */
for (char c=0; c<256; c++) widths[c] = charWidth(c); public int
return widths; getDescent()
} {
return(1);
public boolean hasUniformLineMetrics() }
{
// FIXME /*************************************************************************/
return false;
} /**
* Returns the height of a line in this font. This will be the sum
// Don't have LineMetrics yet... * of the leading, the ascent, and the descent.
/* *
public LineMetrics getLineMetrics(String str, Graphics context) * @return The height of the font.
*/
public LineMetrics getLineMetrics(String str, int beginIndex, int limit, public int
Graphics context) getHeight()
{
public LineMetrics getLineMetrics(char[] chars, int beginIndex, int limit, return(getAscent() + getDescent() + getLeading());
Graphics context) }
public LineMetrics getLineMetrics(CharacterIterator ci, int beginIndex, /*************************************************************************/
int limit, Graphics context)
*/ /**
* Returns the maximum ascent value. This is the maximum distance any
// Don't have Java2D yet. * character in the font rised above the baseline.
/* *
public Rectangle2D getStringBounds(String str, Graphics context) * @return The maximum ascent for this font.
*/
public Rectangle2D getStringBounds(String str, int beginIndex, int limit, public int
Graphics context) getMaxAscent()
{
public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit, return(getAscent());
Graphics context) }
public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex, /*************************************************************************/
int limit, Graphics context)
/**
public Rectangle2D getMaxCharBounds(Graphics context) * Returns the maximum descent value. This is the maximum distance any
*/ * character in the font extends below the baseline.
*
public String toString() * @return The maximum descent for this font.
{ */
return this.getClass() + "[font=" + font + ",ascent=" + getAscent() public int
+ ",descent=" + getDescent() + ",height=" + getHeight() + "]"; getMaxDescent()
} {
return(getDescent());
}
/*************************************************************************/
/**
* Returns the maximum descent value. This is the maximum distance any
* character in the font extends below the baseline.
*
* @return The maximum descent for this font.
*
* @deprecated This method is deprecated in favor of
* <code>getMaxDescent()</code>.
*/
public int
getMaxDecent()
{
return(getMaxDescent());
}
/*************************************************************************/
/**
* Returns the width of the widest character in the font.
*
* @return The width of the widest character in the font.
*/
public int
getMaxAdvance()
{
return(-1);
}
/*************************************************************************/
/**
* Returns the width of the specified character.
*
* @param ch The character to return the width of.
*
* @return The width of the specified character.
*/
public int
charWidth(int ch)
{
return(charWidth((char)ch));
}
/*************************************************************************/
/**
* Returns the width of the specified character.
*
* @param ch The character to return the width of.
*
* @return The width of the specified character.
*/
public int
charWidth(char ch)
{
return(1);
}
/*************************************************************************/
/**
* Returns the total width of the specified string
*
* @param str The string to return the width of.
*
* @return The width of the string.
*/
public int
stringWidth(String str)
{
char[] buf = new char[str.length()];
str.getChars(0, str.length(), buf, 0);
return(charsWidth(buf, 0, buf.length));
}
/*************************************************************************/
/**
* Returns the total width of the specified character array.
*
* @param buf The character array containing the data.
* @param offset The offset into the array to start calculating from.
* @param len The total number of bytes to process.
*
* @return The width of the requested characters.
*/
public int
charsWidth(char buf[], int offset, int len)
{
int total_width = 0;
for (int i = offset; i < len; i++)
total_width = charWidth(buf[i]);
return(total_width);
} }
/*************************************************************************/
/**
* Returns the total width of the specified byte array.
*
* @param buf The byte array containing the data.
* @param offset The offset into the array to start calculating from.
* @param len The total number of bytes to process.
*
* @return The width of the requested characters.
*/
public int
bytesWidth(byte buf[], int offset, int len)
{
int total_width = 0;
for (int i = offset; i < len; i++)
total_width = charWidth((char)buf[i]);
return(total_width);
}
/*************************************************************************/
/**
* Returns the widths of the first 256 characters in the font.
*
* @return The widths of the first 256 characters in the font.
*/
public int[]
getWidths()
{
return(new int[256]);
}
/*************************************************************************/
/**
* Returns a string representation of this object.
*
* @return A string representation of this object.
*/
public String
toString()
{
return (this.getClass() + "[font=" + font + ",ascent=" + getAscent()
+ ",descent=" + getDescent() + ",height=" + getHeight() + "]");
}
} // class FontMetrics
/* Copyright (C) 2000 Free Software Foundation /* Image.java -- Java class for images
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.image.ImageObserver; import java.awt.image.*;
import java.awt.image.ImageProducer;
/** /**
* @author Warren Levy <warrenl@cygnus.com> * This is the abstract superclass of all image objects in Java.
* @date March 15, 2000. *
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public abstract class Image
{
/*
* Static Variables
*/ */
/** /**
* Written using on-line Java Platform 1.2 API Specification, as well * Constant indicating that the default scaling algorithm should be used.
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). */
* Status: Mostly complete, but look for FIXMEs. public static final int SCALE_DEFAULT = 1;
/**
* Constant indicating that a fast scaling algorithm should be used.
*/
public static final int SCALE_FAST = 2;
/**
* Constant indicating that a smooth scaling algorithm should be used.
*/
public static final int SCALE_SMOOTH = 4;
/**
* Constant indicating that the <code>ReplicateScaleFilter</code> class
* algorithm should be used for scaling.
*/
public static final int SCALE_REPLICATE = 8;
/**
* Constant indicating that the area averaging scaling algorithm should be
* used.
*/
public static final int SCALE_AREA_AVERAGING = 16;
/**
* This variable is returned whenever a property that is not defined
* is requested.
*/
public static final Object UndefinedProperty = Image.class;
/*************************************************************************/
/*
* Constructors
*/ */
public abstract class Image extends Object /**
* A default constructor for subclasses.
*/
public
Image()
{ {
public static final Object UndefinedProperty = new Object(); }
public static final int SCALE_DEFAULT = 1<<0, /*************************************************************************/
SCALE_FAST = 1<<1,
SCALE_SMOOTH = 1<<2,
SCALE_REPLICATE = 1<<3,
SCALE_AREA_AVERAGING = 1<<4;
public abstract int getWidth(ImageObserver observer); /*
* Instance Methods
*/
/**
* Returns the width of the image, or -1 if it is unknown. If the
* image width is unknown, the observer object will be notified when
* the value is known.
*
* @param observer The image observer for this object.
*/
public abstract int
getWidth(ImageObserver observer);
/*************************************************************************/
/**
* Returns the height of the image, or -1 if it is unknown. If the
* image height is unknown, the observer object will be notified when
* the value is known.
*
* @param observer The image observer for this object.
*/
public abstract int
getHeight(ImageObserver observer);
/*************************************************************************/
public abstract int getHeight(ImageObserver observer); /**
* Returns the image producer object for this object.
*
* @return The image producer for this object.
*/
public abstract ImageProducer
getSource();
public abstract ImageProducer getSource(); /*************************************************************************/
public abstract Graphics getGraphics(); /**
* Returns a graphics context object for drawing an off-screen object.
* This method is only valid for off-screen objects.
*
* @return A graphics context object for an off-screen object.
*/
public abstract Graphics
getGraphics();
public abstract Object getProperty(String name, ImageObserver observer); /*************************************************************************/
public Image getScaledInstance(int width, int height, int hints) /**
* This method requests a named property for an object. The value of the
* property is returned. The value <code>UndefinedProperty</code> is
* returned if there is no property with the specified name. The value
* <code>null</code> is returned if the properties for the object are
* not yet known. In this case, the specified image observer is notified
* when the properties are known.
*
* @param name The requested property name.
* @param observer The image observer for this object.
*/
public abstract Object
getProperty(String name, ImageObserver observer);
/*************************************************************************/
/**
* Scales the image to the requested dimension.
*
* XXX: FIXME
*
* @param width The width of the scaled image.
* @param height The height of the scaled image.
* @param flags A value indicating the algorithm to use, which will be
* set from contants defined in this class.
*
* @return The scaled <code>Image</code> object.
*/
public Image
getScaledInstance(int width, int height, int flags)
{ {
throw new UnsupportedOperationException("FIXME: not implemented yet"); return null;
} }
public abstract void flush(); /*************************************************************************/
}
/**
* Flushes (that is, destroys) any resources used for this image. This
* includes the actual image data.
*/
public abstract void
flush();
} // class Image
/* ImageMediaEntry.java -- A media entry type for images.
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package java.awt;
import java.awt.image.ImageObserver;
import java.io.Serializable;
/**
* A concrete MediaEntry subtype for images.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
class ImageMediaEntry extends MediaEntry implements ImageObserver,
Serializable
{
private Image image;
private int width;
private int height;
ImageMediaEntry(MediaTracker tracker, Image image, int ID, int width, int height)
{
super(tracker, ID);
this.image = image;
this.width = width;
this.height = height;
}
public Object
getMedia()
{
return(image.getSource()); // FIXME: Is this really right?
}
public void
startLoad()
{
int status = getStatus();
// status |= MediaEntry.LOADSTARTED;
}
public boolean
imageUpdate(Image image, int flags, int x, int y, int width, int height)
{
// implement me
return true;
}
} // class ImageMediaEntry
/* Copyright (C) 2000 Free Software Foundation /* Insets.java -- Information about a container border.
Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
/**
* This class represents the "margin" or space around a container.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class Insets implements Cloneable, java.io.Serializable public class Insets implements Cloneable, java.io.Serializable
{ {
public int top;
public int left; /*
public int bottom; * Instance Variable
public int right; */
public Insets(int top, int left, int bottom, int right) /**
{ * @serial The top inset
this.top = top; */
this.left = left; public int top;
this.bottom = bottom;
this.right = right; /**
} * @serial This bottom inset
*/
public boolean equals(Object obj) public int bottom;
{
if (obj instanceof Insets) /**
{ * @serial The left inset
Insets i = (Insets) obj; */
return (i.top == top public int left;
&& i.left == left
&& i.bottom == bottom /**
&& i.right == right); * @serial The right inset
} */
return false; public int right;
}
/*************************************************************************/
public int hashCode()
{ /**
// FIXME: what is the correct algorithm for this? * Initializes a new instance of <code>Inset</code> with the specified
return (top * (2 * left) * (3 * right) * (4 * bottom)); * inset values.
} *
* @param top The top inset
public String toString() * @param left The left inset
{ * @param bottom The bottom inset
return (getClass() + "[top=" + top + ",left=" + left + ",bottom=" * @param right The right inset
+ bottom + ",right=" + right + "]"); */
} public
Insets(int top, int left, int bottom, int right)
public Object clone() {
{ this.top = top;
Insets r = new Insets(top, left, bottom, right); this.left = left;
return r; this.bottom = bottom;
} this.right = right;
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Tests whether this object is equal to the specified object. This will
* be true if and only if the specified object:
* <p>
* <ul>
* <li>Is not <code>null</code>.
* <li>Is an instance of <code>Insets</code>.
* <li>Has the same top, bottom, left, and right inset values as this object.
* </ul>
*
* @param obj The object to test against.
*
* @return <code>true</code> if the specified object is equal to this
* one, <code>false</code> otherwise.
*/
public boolean
equals(Object obj)
{
if (!(obj instanceof Insets))
return(false);
Insets i = (Insets)obj;
if (i.top != top)
return(false);
if (i.bottom != bottom)
return(false);
if (i.left != left)
return(false);
if (i.right != right)
return(false);
return(true);
}
public int
hashCode()
{
return top + bottom + left + right;
}
/*************************************************************************/
/**
* Returns a string representation of this object.
*
* @return A string representation of this object.
*/
public String
toString()
{
return(getClass().getName() + "(top=" + top + ",bottom=" + bottom +
",left=" + left + ",right=" + right + ")");
}
/*************************************************************************/
/**
* Returns a copy of this object.
*
* @return A copy of this object.
*/
public Object
clone()
{
try
{
return(super.clone());
}
catch(Exception e)
{
return(null);
}
} }
} // class Insets
...@@ -225,8 +225,8 @@ addNotify() ...@@ -225,8 +225,8 @@ addNotify()
protected String protected String
paramString() paramString()
{ {
return(getClass().getName() + "(text=" + getText() + ",alignment=" + return ("text=" + getText() + ",alignment=" +
getAlignment() + ")"); getAlignment() + "," + super.paramString());
} }
} // class Label } // class Label
......
/* Copyright (C) 2000, 2001 Free Software Foundation /* List.java -- A listbox widget
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
import java.io.Serializable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.peer.ListPeer; import java.awt.peer.ListPeer;
import java.awt.event.*; import java.awt.peer.ComponentPeer;
import java.util.Vector; import java.util.Vector;
/** /**
* @author Tom Tromey <tromey@redhat.com> * Class that implements a listbox widget
* @date April 17, 2001 *
* Status: incomplete * @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class List extends Component implements ItemSelectable, Serializable
{
/*
* Static Variables
*/
// Serialization constant
private static final long serialVersionUID = -3304312411574666869L;
/*************************************************************************/
/*
* Instance Variables
*/
// FIXME: Need read/writeObject
/**
* @serial The items in the list.
*/
private Vector items = new Vector();
/**
* @serial Indicates whether or not multiple items can be selected
* simultaneously.
*/
private boolean multipleMode;
/**
* @serial The number of rows in the list. This is set on creation
* only and cannot be modified.
*/
private int rows;
/**
* @serial An array of the item indices that are selected.
*/
private int[] selected;
/**
* @serial An index value used by <code>makeVisible()</code> and
* <code>getVisibleIndex</code>.
*/
private int visibleIndex;
// The list of ItemListeners for this object.
private ItemListener item_listeners;
// The list of ActionListeners for this object.
private ActionListener action_listeners;
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>List</code> with no visible lines
* and multi-select disabled.
*/
public
List()
{
this(4, false);
}
/*************************************************************************/
/**
* Initializes a new instance of <code>List</code> with the specified
* number of visible lines and multi-select disabled.
*
* @param lines The number of visible lines in the list.
*/
public
List(int rows)
{
this(rows, false);
}
/*************************************************************************/
/**
* Initializes a new instance of <code>List</code> with the specified
* number of lines and the specified multi-select setting.
*
* @param lines The number of visible lines in the list.
* @param multipleMode <code>true</code> if multiple lines can be selected
* simultaneously, <code>false</code> otherwise.
*/
public
List(int rows, boolean multipleMode)
{
this.rows = rows;
this.multipleMode = multipleMode;
}
/*************************************************************************/
/*
* Instance Variables
*/ */
public class List extends Component implements ItemSelectable /**
{ * Returns the number of items in this list.
/** Creates a new scrolling list with four rows. *
* Initially, multiple selections are not allowed. * @return The number of items in this list.
*/ */
public List () public int
{ getItemCount()
this (4, false); {
} return(items.size());
}
/** Create a new scrolling list with the indicated number of rows.
* Initially, multiple selections are not allowed. /*************************************************************************/
* @param rows Number of rows
*/ /**
public List (int rows) * Returns the number of items in this list.
{ *
this (rows, false); * @return The number of items in this list.
} *
* @deprecated This method is deprecated in favor of
/** Create a new scrolling list with the indicated number of rows. * <code>getItemCount()</code>
* @param rows Number of rows */
* @param multiple True if multiple selections allowed public int
*/ countItems()
public List (int rows, boolean multiple) {
{ return(getItemCount());
this.rows = rows; }
this.multipleMode = multiple;
} /*************************************************************************/
/** Create the peer if it does not already exist. */ /**
public void addNotify () * Returns the complete list of items.
{ *
if (peer != null) * @return The complete list of items in the list.
peer = getToolkit ().createList (this); */
super.addNotify (); public synchronized String[]
} getItems()
{
public int getItemCount () String[] l_items = new String[getItemCount()];
{
return items.size (); items.copyInto(l_items);
} return(l_items);
}
/** @deprecated Use getItemCount() instead. */
public int countItems () /*************************************************************************/
{
return getItemCount (); /**
} * Returns the item at the specified index.
*
public String getItem (int index) * @param index The index of the item to retrieve.
{ *
return (String) items.elementAt (index); * @exception IndexOutOfBoundsException If the index value is not valid.
} */
public String
public String[] getItems () getItem(int index)
{ {
String[] els = new String[items.size ()]; return((String)items.elementAt(index));
items.copyInto (els); }
return els;
} /*************************************************************************/
public void add (String item) /**
{ * Returns the number of visible rows in the list.
add (item, items.size ()); *
} * @return The number of visible rows in the list.
*/
/** @deprecated Use add() instead. */ public int
public void addItem (String item) getRows()
{ {
add (item); return(rows);
} }
public void add (String item, int index) /*************************************************************************/
{
items.insertElementAt (item, index); /**
if (peer != null) * Tests whether or not multi-select mode is enabled.
{ *
ListPeer l = (ListPeer) peer; * @return <code>true</code> if multi-select mode is enabled,
l.add (item, index); * <code>false</code> otherwise.
} */
} public boolean
isMultipleMode()
/** @deprecated Use add() instead. */ {
public void addItem (String item, int index) return(multipleMode);
{ }
add (item, index);
} /*************************************************************************/
public void replaceItem (String item, int index) /**
{ * Tests whether or not multi-select mode is enabled.
items.setElementAt (item, index); *
if (peer != null) * @return <code>true</code> if multi-select mode is enabled,
{ * <code>false</code> otherwise.
ListPeer l = (ListPeer) peer; *
l.delItems (index, index); * @deprecated This method is deprecated in favor of
l.add (item, index); * <code>isMultipleMode()</code>.
} */
} public boolean
allowsMultipleSelections()
public void removeAll () {
{ return(multipleMode);
items.clear (); }
if (peer != null)
{ /*************************************************************************/
ListPeer l = (ListPeer) peer;
l.removeAll (); /**
} * This method enables or disables multiple selection mode for this
} * list.
*
/** @deprecated Use removeAll() instead. */ * @param multipleMode <code>true</code> to enable multiple mode,
public void clear () * <code>false</code> otherwise.
{ */
removeAll (); public void
} setMultipleMode(boolean multipleMode)
{
public void remove (String item) this.multipleMode = multipleMode;
{ if (peer != null)
remove (items.indexOf (item)); {
} ListPeer l = (ListPeer) peer;
l.setMultipleMode (multipleMode);
public void remove (int index) }
{ }
items.removeElementAt (index);
if (peer != null) /*************************************************************************/
{
ListPeer l = (ListPeer) peer; /**
l.delItems (index, index); * This method enables or disables multiple selection mode for this
} * list.
} *
* @param multipleMode <code>true</code> to enable multiple mode,
/** @deprecated Use remove() instead. */ * <code>false</code> otherwise.
public void delItem (int index) */
{ public void
remove (index); setMultipleSelections(boolean multipleMode)
} {
setMultipleMode(multipleMode);
public int getSelectedIndex () }
{
if (peer != null) /*************************************************************************/
{
ListPeer l = (ListPeer) peer; /**
selected = l.getSelectedIndexes (); * Returns the minimum size of this component.
} *
* @return The minimum size of this component.
if (selected == null || selected.length > 1) */
return -1; public Dimension
return selected[0]; getMinimumSize()
} {
return(getMinimumSize(rows));
public int[] getSelectedIndexes () }
{
if (peer != null) /*************************************************************************/
{
ListPeer l = (ListPeer) peer; /**
selected = l.getSelectedIndexes (); * Returns the minimum size of this component.
} *
return selected; * @return The minimum size of this component.
} *
* @deprecated This method is deprecated in favor of
public String getSelectedItem () * <code>getMinimumSize</code>.
{ */
int i = getSelectedIndex (); public Dimension
return i == -1 ? null : (String) items.elementAt (i); minimumSize()
} {
return(getMinimumSize(rows));
public String[] getSelectedItems () }
{
int[] is = getSelectedIndexes (); /*************************************************************************/
if (is == null)
return null; /**
String[] r = new String[is.length]; * Returns the minimum size of this component assuming it had the specified
for (int i = 0; i < is.length; ++i) * number of rows.
r[i] = (String) items.elementAt (is[i]); *
return r; * @param rows The number of rows to size for.
} *
* @return The minimum size of this component.
public Object[] getSelectedObjects () */
{ public Dimension
return getSelectedItems (); getMinimumSize(int rows)
} {
ListPeer lp = (ListPeer)getPeer();
public void select (int index) if (lp != null)
{ return(lp.minimumSize(rows));
if (peer != null) else
{ return(new Dimension(0,0));
ListPeer l = (ListPeer) peer; }
l.select (index);
} /*************************************************************************/
else if (selected == null)
{ /**
selected = new int[1]; * Returns the minimum size of this component assuming it had the specified
selected[0] = index; * number of rows.
} *
else * @param rows The number of rows to size for.
{ *
int i; * @return The minimum size of this component.
for (i = 0; i < selected.length; ++i) *
{ * @deprecated This method is deprecated in favor of
if (selected[i] == index) * <code>getMinimumSize(int)</code>>
return; */
if (selected[i] > index) public Dimension
break; minimumSize(int rows)
} {
return(getMinimumSize(rows));
int[] ns = new int[selected.length + 1]; }
System.arraycopy (selected, 0, ns, 0, i);
ns[i] = index; /*************************************************************************/
System.arraycopy (selected, i, ns, i + 1, selected.length - i);
/**
selected = ns; * Returns the preferred size of this component.
} *
} * @return The preferred size of this component.
*/
public void deselect (int index) public Dimension
{ getPreferredSize()
if (peer != null) {
{ return(getPreferredSize(rows));
ListPeer l = (ListPeer) peer; }
l.deselect (index);
} /*************************************************************************/
else if (selected != null)
{ /**
int i; * Returns the preferred size of this component.
for (i = 0; i < selected.length; ++i) *
{ * @return The preferred size of this component.
if (selected[i] == index) *
break; * @deprecated This method is deprecated in favor of
} * <code>getPreferredSize</code>.
if (i < selected.length) */
{ public Dimension
int[] ns = new int[selected.length - 1]; preferredSize()
System.arraycopy (selected, 0, ns, 0, i); {
System.arraycopy (selected, i + 1, ns, i, selected.length - i); return(getPreferredSize(rows));
selected = ns; }
}
} /*************************************************************************/
}
/**
public boolean isIndexSelected (int index) * Returns the preferred size of this component assuming it had the specified
{ * number of rows.
int[] is = getSelectedIndexes (); *
for (int i = 0; i < is.length; ++i) * @param rows The number of rows to size for.
{ *
if (is[i] == index) * @return The preferred size of this component.
return true; */
} public Dimension
return false; getPreferredSize(int rows)
} {
ListPeer lp = (ListPeer)getPeer();
/** @deprecated Use isIndexSelected(). */ if (lp != null)
public boolean isSelected (int index) return(lp.preferredSize(rows));
{ else
return isIndexSelected (index); return(new Dimension(0,0));
} }
public int getRows () /*************************************************************************/
{
return rows; /**
} * Returns the preferred size of this component assuming it had the specified
* number of rows.
public boolean isMultipleMode () *
{ * @param rows The number of rows to size for.
return multipleMode; *
} * @return The preferred size of this component.
*
/** @deprecated Use isMultipleMode(). */ * @deprecated This method is deprecated in favor of
public boolean allowsMultipleSelections () * <code>getPreferredSize(int)</code>>
{ */
return isMultipleMode (); public Dimension
} preferredSize(int rows)
{
public void setMultipleMode (boolean multiple) return(getPreferredSize(rows));
{ }
this.multipleMode = multiple;
if (peer != null) /*************************************************************************/
{
ListPeer l = (ListPeer) peer; /**
l.setMultipleMode (multiple); * This method adds the specified item to the end of the list.
} *
} * @param item The item to add to the list.
*/
/** @deprecated Use setMultipleMode(). */ public void
public void setMultipleSelections (boolean multiple) add(String item)
{ {
setMultipleMode (multiple); add(item, -1);
}
public int getVisibleIndex ()
{
return visibleIndex;
}
public void makeVisible (int index)
{
visibleIndex = index;
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.makeVisible (index);
}
}
public Dimension getPreferredSize (int rows)
{
return null; // FIXME
}
/** @deprecated Use getPreferredSize(int). */
public Dimension preferredSize (int rows)
{
return getPreferredSize (rows);
}
public Dimension getPreferredSize ()
{
return null; // FIXME
}
/** @deprecated Use getPreferredSize(). */
public Dimension preferredSize ()
{
return getPreferredSize ();
}
public Dimension getMinimumSize (int rows)
{
return null; // FIXME
}
/** @deprecated Use getMinimumSize(int). */
public Dimension minimumSize (int rows)
{
return getMinimumSize (rows);
}
public Dimension getMinimumSize ()
{
return null; // FIXME
}
/** @deprecated Use getMinimumSize(). */
public Dimension minimumSize ()
{
return getMinimumSize ();
}
public void addItemListener (ItemListener listen)
{
item_listeners = AWTEventMulticaster.add (item_listeners, listen);
}
public void removeItemListener (ItemListener listen)
{
item_listeners = AWTEventMulticaster.remove (item_listeners, listen);
}
public void addActionListener (ActionListener listen)
{
action_listeners = AWTEventMulticaster.add (action_listeners, listen);
}
public void removeActionListener (ActionListener listen)
{
action_listeners = AWTEventMulticaster.remove (action_listeners, listen);
}
protected void processEvent (AWTEvent e)
{
if (e instanceof ItemEvent)
processItemEvent ((ItemEvent) e);
else if (e instanceof ActionEvent)
processActionEvent ((ActionEvent) e);
else
super.processEvent (e);
}
protected void processItemEvent (ItemEvent e)
{
if (item_listeners != null)
item_listeners.itemStateChanged (e);
}
protected void processActionEvent (ActionEvent e)
{
if (action_listeners != null)
action_listeners.actionPerformed (e);
}
protected String paramString ()
{
return ("List[multiple=" + multipleMode
+ ",rows=" + rows
+ "]");
}
/** @deprecated */
public void delItems (int start, int end)
{
for (int i = end; i >= start; --i)
items.removeElementAt (i);
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.delItems (start, end);
}
}
// Vector of items in the list.
private Vector items;
// True if multiple selection mode enabled.
private boolean multipleMode;
// Number of rows.
private int rows;
// Array of indices of selected items. When there is no peer, we
// maintain this in place. When there is a peer, the peer maintains
// the list and we ask for it whenever needed.
private int[] selected;
// Value used by makeVisible().
private int visibleIndex;
// Listeners.
private ActionListener action_listeners;
private ItemListener item_listeners;
} }
/*************************************************************************/
/**
* This method adds the specified item to the end of the list.
*
* @param item The item to add to the list.
*
* @deprecated Use add() instead.
*/
public void
addItem(String item)
{
addItem(item, -1);
}
/*************************************************************************/
/**
* Adds the specified item to the specified location in the list.
* If the desired index is -1 or greater than the number of rows
* in the list, then the item is added to the end.
*
* @param item The item to add to the list.
* @param index The location in the list to add the item, or -1 to add
* to the end.
*/
public void
add(String item, int index)
{
if ((index == -1) || (index >= items.size()))
items.addElement(item);
else
items.insertElementAt(item, index);
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.add (item, index);
}
}
/*************************************************************************/
/**
* Adds the specified item to the specified location in the list.
* If the desired index is -1 or greater than the number of rows
* in the list, then the item is added to the end.
*
* @param item The item to add to the list.
* @param index The location in the list to add the item, or -1 to add
* to the end.
*
* @deprecated Use add() instead.
*/
public void
addItem(String item, int index)
{
add(item, index);
}
/*************************************************************************/
/**
* Deletes the item at the specified index.
*
* @param index The index of the item to delete.
*
* @exception IllegalArgumentException If the index is not valid
*/
public void
delItem(int index) throws IllegalArgumentException
{
remove(index);
}
/*************************************************************************/
/**
* Deletes the item at the specified index.
*
* @param index The index of the item to delete.
*
* @exception IllegalArgumentException If the index is not valid
*/
public void
remove(int index) throws IllegalArgumentException
{
items.removeElementAt (index);
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.delItems (index, index);
}
}
/*************************************************************************/
/**
* Deletes all items in the specified index range.
*
* @param start The beginning index of the range to delete.
* @param end The ending index of the range to delete.
*
* @exception IllegalArgumentException If the indexes are not valid
*
* @deprecated This method is deprecated for some unknown reason.
*/
public synchronized void
delItems(int start, int end) throws IllegalArgumentException
{
if ((start < 0) || (start >= items.size()))
throw new IllegalArgumentException("Bad list start index value: " + start);
if ((start < 0) || (start >= items.size()))
throw new IllegalArgumentException("Bad list start index value: " + start);
if (start > end)
throw new IllegalArgumentException("Start is greater than end!");
// We must run the loop in reverse direction.
for (int i = end; i >= start; --i)
items.removeElementAt (i);
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.delItems (start, end);
}
}
/*************************************************************************/
/**
* Deletes the first occurrence of the specified item from the list.
*
* @param item The item to delete.
*
* @exception IllegalArgumentException If the specified item does not exist.
*/
public synchronized void
remove(String item) throws IllegalArgumentException
{
int index = items.indexOf(item);
if (index == -1)
throw new IllegalArgumentException("List element to delete not found");
remove(index);
}
/*************************************************************************/
/**
* Deletes all of the items from the list.
*/
public synchronized void
removeAll()
{
items.clear();
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.removeAll ();
}
}
/*************************************************************************/
/**
* Deletes all of the items from the list.
*
* @deprecated This method is deprecated in favor of <code>removeAll()</code>.
*/
public void
clear()
{
removeAll();
}
/*************************************************************************/
/**
* Replaces the item at the specified index with the specified item.
*
* @param item The new item value.
* @param index The index of the item to replace.
*
* @exception IllegalArgumentException If the index is not valid.
*/
public synchronized void
replaceItem(String item, int index) throws IllegalArgumentException
{
remove(index);
addItem(item, index);
}
/*************************************************************************/
/**
* Returns the index of the currently selected item. -1 will be returned
* if there are no selected rows or if there are multiple selected rows.
*
* @return The index of the selected row.
*/
public synchronized int
getSelectedIndex()
{
if (peer != null)
{
ListPeer l = (ListPeer) peer;
selected = l.getSelectedIndexes ();
}
if (selected == null || selected.length > 1)
return -1;
return selected[0];
}
/*************************************************************************/
/**
* Returns an array containing the indexes of the rows that are
* currently selected.
*
* @return A list of indexes of selected rows.
*/
public synchronized int[]
getSelectedIndexes()
{
if (peer != null)
{
ListPeer l = (ListPeer) peer;
selected = l.getSelectedIndexes ();
}
return selected;
}
/*************************************************************************/
/**
* Returns the item that is currently selected, or <code>null</code> if there
* is no item selected. FIXME: What happens if multiple items selected?
*
* @return The selected item, or <code>null</code> if there is no
* selected item.
*/
public synchronized String
getSelectedItem()
{
int index = getSelectedIndex();
if (index == -1)
return(null);
return((String)items.elementAt(index));
}
/*************************************************************************/
/**
* Returns the list of items that are currently selected in this list.
*
* @return The list of currently selected items.
*/
public synchronized String[]
getSelectedItems()
{
int[] indexes = getSelectedIndexes();
if (indexes == null)
return(new String[0]);
String[] retvals = new String[indexes.length];
if (retvals.length > 0)
for (int i = 0 ; i < retvals.length; i++)
retvals[i] = (String)items.elementAt(indexes[i]);
return(retvals);
}
/*************************************************************************/
/**
* Returns the list of items that are currently selected in this list as
* an array of type <code>Object[]</code> instead of <code>String[]</code>.
*
* @return The list of currently selected items.
*/
public synchronized Object[]
getSelectedObjects()
{
int[] indexes = getSelectedIndexes();
if (indexes == null)
return(new Object[0]);
Object[] retvals = new Object[indexes.length];
if (retvals.length > 0)
for (int i = 0 ; i < retvals.length; i++)
retvals[i] = items.elementAt(indexes[i]);
return(retvals);
}
/*************************************************************************/
/**
* Tests whether or not the specified index is selected.
*
* @param index The index to test.
*
* @return <code>true</code> if the index is selected, <code>false</code>
* otherwise.
*/
public boolean
isIndexSelected(int index)
{
int[] indexes = getSelectedIndexes();
for (int i = 0; i < indexes.length; i++)
if (indexes[i] == index)
return(true);
return(false);
}
/*************************************************************************/
/**
* Tests whether or not the specified index is selected.
*
* @param index The index to test.
*
* @return <code>true</code> if the index is selected, <code>false</code>
* otherwise.
*
* @deprecated This method is deprecated in favor of
* <code>isIndexSelected(int)</code>.
*/
public boolean
isSelected(int index)
{
return(isIndexSelected(index));
}
/*************************************************************************/
/**
* This method ensures that the item at the specified index is visible.
*
* @exception IllegalArgumentException If the specified index is out of
* range.
*/
public synchronized void
makeVisible(int index) throws IllegalArgumentException
{
if ((index < 0) || (index >= items.size()))
throw new IllegalArgumentException("Bad list index: " + index);
visibleIndex = index;
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.makeVisible (index);
}
}
/*************************************************************************/
/**
* Returns the index of the last item that was made visible via the
* <code>makeVisible()</code> method.
*
* @return The index of the last item made visible via the
* <code>makeVisible()</code> method.
*/
public int
getVisibleIndex()
{
return(visibleIndex);
}
/*************************************************************************/
/**
* Makes the item at the specified index selected.
*
* @param index The index of the item to select.
*/
public synchronized void
select(int index)
{
ListPeer lp = (ListPeer)getPeer();
if (lp != null)
lp.select(index);
}
/*************************************************************************/
/**
* Makes the item at the specified index not selected.
*
* @param index The index of the item to unselect.
*/
public synchronized void
deselect(int index)
{
ListPeer lp = (ListPeer)getPeer();
if (lp != null)
lp.deselect(index);
}
/*************************************************************************/
/**
* Notifies this object to create its native peer.
*/
public void
addNotify()
{
if (peer != null)
peer = getToolkit ().createList (this);
super.addNotify ();
}
/*************************************************************************/
/**
* Notifies this object to destroy its native peer.
*/
public void
removeNotify()
{
super.removeNotify();
}
/*************************************************************************/
/**
* Adds the specified <code>ActionListener</code> to the list of
* registered listeners for this object.
*
* @param listener The listener to add.
*/
public synchronized void
addActionListener(ActionListener listener)
{
action_listeners = AWTEventMulticaster.add(action_listeners, listener);
}
/*************************************************************************/
/**
* Removes the specified <code>ActionListener</code> from the list of
* registers listeners for this object.
*
* @param listener The listener to remove.
*/
public synchronized void
removeActionListener(ActionListener listener)
{
action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
}
/*************************************************************************/
/**
* Adds the specified <code>ItemListener</code> to the list of
* registered listeners for this object.
*
* @param listener The listener to add.
*/
public synchronized void
addItemListener(ItemListener listener)
{
item_listeners = AWTEventMulticaster.add(item_listeners, listener);
}
/*************************************************************************/
/**
* Removes the specified <code>ItemListener</code> from the list of
* registers listeners for this object.
*
* @param listener The listener to remove.
*/
public synchronized void
removeItemListener(ItemListener listener)
{
item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
}
/*************************************************************************/
/**
* Processes the specified event for this object. If the event is an
* instance of <code>ActionEvent</code> then the
* <code>processActionEvent()</code> method is called. Similarly, if the
* even is an instance of <code>ItemEvent</code> then the
* <code>processItemEvent()</code> method is called. Otherwise the
* superclass method is called to process this event.
*
* @param event The event to process.
*/
protected void
processEvent(AWTEvent event)
{
if (event instanceof ActionEvent)
processActionEvent((ActionEvent)event);
if (event instanceof ItemEvent)
processItemEvent((ItemEvent)event);
super.processEvent(event);
}
/*************************************************************************/
/**
* This method processes the specified event by dispatching it to any
* registered listeners. Note that this method will only get called if
* action events are enabled. This will happen automatically if any
* listeners are added, or it can be done "manually" by calling
* the <code>enableEvents()</code> method.
*
* @param event The event to process.
*/
protected void
processActionEvent(ActionEvent event)
{
if (action_listeners != null)
action_listeners.actionPerformed(event);
}
/*************************************************************************/
/**
* This method processes the specified event by dispatching it to any
* registered listeners. Note that this method will only get called if
* item events are enabled. This will happen automatically if any
* listeners are added, or it can be done "manually" by calling
* the <code>enableEvents()</code> method.
*
* @param event The event to process.
*/
protected void
processItemEvent(ItemEvent event)
{
if (item_listeners != null)
item_listeners.itemStateChanged(event);
}
/*************************************************************************/
/**
* Returns a debugging string for this object.
*
* @return A debugging string for this object.
*/
protected String
paramString()
{
return "multiple=" + multipleMode + ",rows=" + rows + super.paramString();
}
} // class List
/* MediaEntry.java -- An entry in a MediaTracker
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package java.awt;
/**
* This is an entry in the media tracker
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
abstract class MediaEntry implements java.io.Serializable
{
protected static final int LOADING = 1;
protected static final int ABORTED = 2;
protected static final int ERRORED = 4;
protected static final int COMPLETE = 8;
protected static final int LOADSTARTED = 16;
protected static final int DONE = 32;
private MediaTracker tracker;
private int ID;
private int status;
private boolean cancelled;
private MediaEntry next;
static MediaEntry
insert(MediaEntry a, MediaEntry b)
{
while (a.next != null)
a = a.next;
a.next = b;
return(b);
}
MediaEntry(MediaTracker tracker, int ID)
{
this.tracker = tracker;
this.ID = ID;
}
public int
getID()
{
return(ID);
}
public int
getStatus()
{
return(status);
}
public void
setStatus(int status)
{
this.status = status;
}
public MediaEntry
getNext()
{
return(next);
}
public void
cancel()
{
cancelled = true;
if ((status == LOADING) || (status == LOADSTARTED))
setStatus(ABORTED);
}
abstract void
startLoad();
abstract Object
getMedia();
} // class MediaEntry
/* MediaTracker.java -- Class used for keeping track of images
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package java.awt;
/**
* This class is used for keeping track of the status of various media
* objects.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class MediaTracker implements java.io.Serializable
{
} // class MediaTracker
/* Copyright (C) 1999, 2000, 2001 Free Software Foundation /* Menu.java -- A Java AWT Menu
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libjava. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.peer.MenuPeer;
import java.awt.peer.MenuItemPeer;
import java.awt.peer.MenuComponentPeer;
import java.io.Serializable;
import java.util.Vector; import java.util.Vector;
import java.util.Enumeration;
/**
* This class represents a pull down or tear off menu in Java's AWT.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class Menu extends MenuItem implements MenuContainer, Serializable
{
/*
* Static Variables
*/
// Serialization Constant
private static final long serialVersionUID = -8809584163345499784L;
/*************************************************************************/
/*
* Instance Variables
*/
/**
* @serial The actual items in the menu
*/
private Vector items = new Vector();
/**
* @serial Flag indicating whether or not this menu is a tear off
*/
private boolean isTearOff;
/**
* @serial Indicates whether or not this is a help menu.
*/
private boolean isHelpMenu;
// From the serialization spec. FIXME: what should it be?
private int menuSerializedDataVersion;
static final MenuItem separator = new MenuItem("-");
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>Menu</code> with no label and that
* is not a tearoff;
*/
public
Menu()
{
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Menu</code> that is not a tearoff and
* that has the specified label.
*
* @param label The menu label.
*/
public
Menu(String label)
{
this(label, false);
}
/*************************************************************************/
/* Status: Incomplete. */ /**
* Initializes a new instance of <code>Menu</code> with the specified
public class Menu extends MenuItem implements MenuContainer * label and tearoff status.
{ *
// Fields from the serialization spec. Decalare others "transient". * @param label The label for this menu
Vector items = new Vector(); * @param isTearOff <code>true</code> if this menu is a tear off menu,
boolean tearOff; * <code>false</code> otherwise.
boolean isHelpMenu; */
int menuSerializedDataVersion; public
Menu(String label, boolean isTearOff)
static final MenuItem separator = new MenuItem("-"); {
super(label);
public Menu()
{ this.isTearOff = isTearOff;
this(null, false);
} if (label.equals("Help"))
isHelpMenu = true;
public Menu(String label)
{
this(label, false);
}
public Menu(String label, boolean tearOff)
{
super(label);
this.tearOff = tearOff;
}
public void addNotify()
{
if (peer != null)
{
// This choice of toolkit seems unsatisfying, but I'm not sure
// what else to do.
peer = Toolkit.getDefaultToolkit ().createMenu (this);
}
super.addNotify ();
}
public void removeNotify()
{
// FIXME
}
public boolean isTearOff()
{
return tearOff;
}
public int getItemCount()
{
return items.size();
}
/** @deprecated Use getItemCount() instead. */
public int countItems()
{
return getItemCount();
}
public MenuItem getItem(int index)
{
return (MenuItem) items.elementAt(index);
}
public synchronized MenuItem add(MenuItem mi)
{
items.addElement(mi);
if (mi.parent != null)
{
mi.parent.remove(mi);
}
mi.parent = this;
return mi;
}
public void add(String label)
{
MenuItem mi = new MenuItem(label);
this.add(mi);
}
public synchronized void insert(MenuItem menuitem, int index)
{
if (index < 0)
throw new IllegalArgumentException();
items.insertElementAt(menuitem, index);
}
public void insert(String label, int index)
{
MenuItem mi = new MenuItem(label);
this.insert(mi, index);
}
public void addSeparator()
{
this.add(separator);
}
public void insertSeparator(int index)
{
this.insert(separator, index);
}
public synchronized void remove(int index)
{
items.removeElementAt(index);
}
public synchronized void remove(MenuComponent item)
{
items.removeElement(item);
}
public synchronized void removeAll()
{
items.removeAllElements();
}
public String paramString()
{
return getName() + ",label" + label + ",tearOff=" + tearOff +
",isHelpMenu=" + isHelpMenu;
}
// Accessibility API not yet implemented.
// public AccessibleContext getAccessibleContext()
} }
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Tests whether or not this menu is a tearoff.
*
* @return <code>true</code> if this menu is a tearoff, <code>false</code>
* otherwise.
*/
public boolean
isTearOff()
{
return(isTearOff);
}
/*************************************************************************/
/**
* Returns the number of items in this menu.
*
* @return The number of items in this menu.
*/
public int
getItemCount()
{
return(items.size());
}
/*************************************************************************/
/**
* Returns the number of items in this menu.
*
* @return The number of items in this menu.
*
* @deprecated This method is deprecated in favor of <code>getItemCount()</code>.
*/
public int
count()
{
return(items.size());
}
/*************************************************************************/
/**
* Returns the item at the specified index.
*
* @return The item at the specified index.
*
* @exception ArrayIndexOutOfBoundsException If the index value is not valid.
*/
public MenuItem
getItem(int index)
{
return((MenuItem)items.elementAt(index));
}
/*************************************************************************/
/**
* Adds the specified item to this menu. If it was previously part of
* another menu, it is first removed from that menu.
*
* @param item The new item to add.
*
* @return The item that was added.
*/
public MenuItem
add(MenuItem item)
{
items.addElement(item);
if (item.parent != null)
{
item.parent.remove(item);
}
item.parent = this;
if (peer != null)
{
MenuPeer mp = (MenuPeer) peer;
mp.addItem(item);
}
return item;
}
/*************************************************************************/
/**
* Add an item with the specified label to this menu.
*
* @param label The label of the menu item to add.
*/
public void
add(String label)
{
add(new MenuItem(label));
}
/*************************************************************************/
/**
* Inserts the specified menu item into this menu at the specified index.
*
* @param item The menu item to add.
* @param index The index of the menu item.
*
* XXX: FIXME
*
* @exception IllegalArgumentException If the index is less than zero.
* @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
*/
public void
insert(MenuItem item, int index)
{
if (index < 0)
throw new IllegalArgumentException("Index is less than zero");
items.insertElementAt(item, index);
MenuPeer mp = (MenuPeer)getPeer();
// FIXME: Need to add a peer method here.
// if (mp != null)
// mp.insertItem(item, index);
}
/*************************************************************************/
/**
* Inserts an item with the specified label into this menu at the specified index.
*
* @param label The label of the item to add.
* @param index The index of the menu item.
*
* @exception IllegalArgumentException If the index is less than zero.
* @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
*/
public void
insert(String label, int index)
{
insert(new MenuItem(label), index);
}
/*************************************************************************/
/**
* Adds a separator bar at the current menu location.
*/
public void
addSeparator()
{
add(separator);
}
/*************************************************************************/
/**
* Inserts a separator bar at the specified index value.
*
* @param index The index at which to insert a separator bar.
*
* XXX: FIXME
*
* @exception IllegalArgumentException If the index is less than zero.
* @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
*/
public void
insertSeparator(int index)
{
insert(separator, index);
}
/*************************************************************************/
/**
* Deletes the item at the specified index from this menu.
*
* @param index The index of the item to remove.
*
* @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
*/
public synchronized void
remove(int index)
{
items.removeElementAt(index);
MenuPeer mp = (MenuPeer)getPeer();
if (mp != null)
mp.delItem(index);
}
/*************************************************************************/
/**
* Removes the specifed item from the menu. If the specified component
* does not exist, this method does nothing. // FIXME: Right?
*
* @param item The component to remove.
*/
public void
remove(MenuComponent item)
{
int index = items.indexOf(item);
if (index == -1)
return;
remove(index);
}
/*************************************************************************/
/**
* Removes all the elements from this menu.
*/
public synchronized void
removeAll()
{
int count = getItemCount();
for(int i = 0; i < count; i++)
{
// We must always remove item 0.
remove(0);
}
}
/*************************************************************************/
/**
* Creates the native peer for this object.
*/
public void
addNotify()
{
if (peer != null)
peer = getToolkit().createMenu(this);
super.addNotify ();
}
/*************************************************************************/
/**
* Destroys the native peer for this object.
*/
public void
removeNotify()
{
super.removeNotify();
}
/*************************************************************************/
/**
* Returns a debugging string for this menu.
*
* @return A debugging string for this menu.
*/
public String
paramString()
{
return (",isTearOff=" + isTearOff + ",isHelpMenu=" + isHelpMenu
+ super.paramString());
}
// Accessibility API not yet implemented.
// public AccessibleContext getAccessibleContext()
} // class Menu
/* Copyright (C) 1999, 2000, 2001 Free Software Foundation /* MenuBar.java -- An AWT menu bar class
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of libjava. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.peer.MenuBarPeer; import java.awt.peer.MenuBarPeer;
import java.util.Vector; import java.awt.peer.MenuComponentPeer;
import java.io.Serializable;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.NoSuchElementException; import java.util.Vector;
/**
* This class implements a menu bar in the AWT system.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@redhat.com>
*/
public class MenuBar extends MenuComponent
implements MenuContainer, Serializable
{
/*
* Static Variables
*/
// Serialization Constant
private static final long serialVersionUID = -4930327919388951260L;
/*************************************************************************/
/*
* Instance Variables
*/
/** This class implements a MenuBar, such as might appear across the /**
* top of a window. * @serial The menu used for providing help information
* @author Tom Tromey <tromey@redhat.com> */
* @date December 25, 2000 private Menu helpMenu;
/**
* @serial The menus contained in this menu bar.
*/
private Vector menus = new Vector();
/*************************************************************************/
/*
* Constructors
*/ */
public class MenuBar extends MenuComponent implements MenuContainer
/**
* Initializes a new instance of <code>MenuBar</code>.
*/
public
MenuBar()
{ {
/** Create a new MenuBar. */ }
public MenuBar ()
{ /*************************************************************************/
menus = new Vector ();
} /*
* Instance Methods
/** Add a menu to this MenuBar. If the menu has already has a */
* parent, it is first removed from its old parent before being
* added.
* @param menu The menu to add.
* @returns menu
*/
public synchronized Menu add (Menu menu)
{
if (menu.parent != null)
menu.parent.remove (menu);
menu.parent = this;
menus.add (menu);
if (peer != null)
{
MenuBarPeer mp = (MenuBarPeer) peer;
mp.add (menu);
}
return menu;
}
/** 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 ().createMenuBar (this);
}
}
/** @deprecated Use getMenuCount() instead. */
public int countMenus ()
{
return getMenuCount ();
}
/** Delete a keyboard shortcut.
* @param shortcut The short cut which should be deleted from all
* menus on this MenuBar.
*/
public void deleteShortcut (MenuShortcut shortcut)
{
MenuItem it;
// This is a slow implementation, but it probably doesn't matter.
while ((it = getShortcutMenuItem (shortcut)) != null)
it.deleteShortcut ();
}
/** Returns the current Help menu. */
public Menu getHelpMenu ()
{
return help_menu;
}
/** Returns a menu from this object.
* @param index Index of menu to return.
*/
public Menu getMenu (int index)
{
return (Menu) menus.get (index);
}
/** Returns the number of menus on this MenuBar. */
public int getMenuCount ()
{
return menus.size ();
}
/** Returns the menu item on this MenuBar with the specified
* shortcut.
* @param shortcut Shortcut to look for
*/
public MenuItem getShortcutMenuItem (MenuShortcut shortcut)
{
Enumeration m = new MenuEnumeration (this);
while (m.hasMoreElements ())
{
MenuItem item = (MenuItem) m.nextElement ();
if (item.getShortcut () == shortcut)
return item;
}
return null;
}
/** Remove a menu from the menu bar. If the menu is specified by
* component (and not index), and does not exist on the menu, then
* the method does nothing. If the removed menu has a peer, it is
* destroyed.
* @param menu The menu to remove
* @param index The index of the menu to remove
*/
public synchronized void remove (MenuComponent menu)
{
int s = menus.size ();
for (int i = 0; i < s; ++i)
{
if (menus.get (i) == menu)
{
remove (i);
break;
}
}
}
public synchronized void remove (int index)
{
Menu m = (Menu) menus.get (index);
menus.remove (index);
m.removeNotify ();
m.parent = null;
if (peer != null)
{
MenuBarPeer mp = (MenuBarPeer) peer;
mp.remove (index);
}
}
/** Set the Help menu for this MenuBar. If a Help menu already
* exists, it is first removed.
* @param menu The new Help menu.
*/
public synchronized void setHelpMenu (Menu menu)
{
if (help_menu != null)
{
help_menu.removeNotify ();
help_menu.parent = null;
}
if (menu.parent != null)
menu.parent.remove (menu);
if (menu.parent != null)
menu.parent.remove (menu);
menu.parent = this;
if (peer != null)
{
MenuBarPeer mp = (MenuBarPeer) peer;
mp.addHelpMenu (menu);
}
}
/** Returns an Enumeration which lists the keyboard shortcuts
* associated with menu items on this MenuBar.
*/
public synchronized Enumeration shortcuts ()
{
return new ShortcutEnumeration (new MenuEnumeration (this));
}
// Iterate over the items of a menu.
private static class MenuEnumeration implements Enumeration
{
// Enumerate over the menu's items.
Enumeration main;
// Enumerate over a submenu.
Enumeration sub;
// Menubar so we can keep track of help menu too.
MenuBar menubar;
MenuEnumeration (Menu m)
{
sub = null;
menubar = null;
main = m.items.elements ();
}
MenuEnumeration (MenuBar mb) /**
* Returns the help menu for this menu bar. This may be <code>null</code>.
*
* @return The help menu for this menu bar.
*/
public Menu
getHelpMenu()
{
return(helpMenu);
}
/*************************************************************************/
/**
* Sets the help menu for this menu bar.
*
* @param helpMenu The new help menu for this menu bar.
*/
public synchronized void
setHelpMenu(Menu menu)
{
if (helpMenu != null)
{ {
sub = null; helpMenu.removeNotify ();
menubar = mb; helpMenu.parent = null;
main = mb.menus.elements ();
} }
public boolean hasMoreElements () if (menu.parent != null)
menu.parent.remove (menu);
if (menu.parent != null)
menu.parent.remove (menu);
menu.parent = this;
if (peer != null)
{ {
boolean r = false; MenuBarPeer mp = (MenuBarPeer) peer;
if (sub != null) mp.addHelpMenu (menu);
r = sub.hasMoreElements ();
if (! r)
r = main.hasMoreElements ();
if (! r && menubar != null)
{
if (menubar.help_menu != null)
{
main = new MenuEnumeration (menubar.help_menu);
r = main.hasMoreElements ();
}
menubar = null;
}
return r;
} }
}
/*************************************************************************/
public Object nextElement () throws NoSuchElementException /** Add a menu to this MenuBar. If the menu has already has a
* parent, it is first removed from its old parent before being
* added.
*
* @param menu The menu to add.
*
* @return The menu that was added.
*/
public synchronized Menu
add(Menu menu)
{
if (menu.parent != null)
menu.parent.remove (menu);
menu.parent = this;
menus.addElement(menu);
if (peer != null)
{ {
while (true) MenuBarPeer mp = (MenuBarPeer) peer;
{ mp.addMenu (menu);
if (! sub.hasMoreElements ())
sub = null;
else
return sub.nextElement ();
if (! main.hasMoreElements () && menubar != null
&& menubar.help_menu != null)
{
main = new MenuEnumeration (menubar.help_menu);
menubar = null;
}
Object r = main.nextElement ();
if (r instanceof Menu)
{
sub = new MenuEnumeration ((Menu) r);
continue;
}
return r;
}
} }
}
// This is an enumeration that shadows another enumeration and return(menu);
// returns the shortcut for each item returned. I wonder if we're }
// only supposed to return unique shortcuts? If so then we could
// keep a hash table here and remove duplicates. /*************************************************************************/
private static class ShortcutEnumeration implements Enumeration
{
Enumeration back;
ShortcutEnumeration (Enumeration back) /**
* Removes the menu at the specified index.
*
* @param index The index of the menu to remove from the menu bar.
*/
public synchronized void
remove(int index)
{
Menu m = (Menu) menus.get (index);
menus.remove (index);
m.removeNotify ();
m.parent = null;
if (peer != null)
{ {
this.back = back; MenuBarPeer mp = (MenuBarPeer) peer;
mp.delMenu (index);
} }
}
/*************************************************************************/
/**
* Removes the specified menu from the menu bar.
*
* @param menu The menu to remove from the menu bar.
*/
public void
remove(MenuComponent menu)
{
int index = menus.indexOf(menu);
if (index == -1)
return;
remove(index);
}
/*************************************************************************/
/**
* Returns the number of elements in this menu bar.
*
* @return The number of elements in the menu bar.
*/
public int
getMenuCount()
{
// FIXME: How does the help menu fit in here?
return(menus.size());
}
/*************************************************************************/
/**
* Returns the number of elements in this menu bar.
*
* @return The number of elements in the menu bar.
*
* @deprecated This method is deprecated in favor of <code>getMenuCount()</code>.
*/
public int
countMenus()
{
return(getMenuCount());
}
/*************************************************************************/
/**
* Returns the menu at the specified index.
*
* @return The requested menu.
*
* @exception ArrayIndexOutOfBoundsException If the index is not valid.
*/
public Menu
getMenu(int index)
{
return((Menu)menus.elementAt(index));
}
/*************************************************************************/
public boolean hasMoreElements () /**
* Creates this object's native peer.
*/
public void
addNotify()
{
if (getPeer() == null)
setPeer((MenuComponentPeer)getToolkit().createMenuBar(this));
}
/*************************************************************************/
/**
* Destroys this object's native peer.
*/
public void
removeNotify()
{
super.removeNotify();
}
/*************************************************************************/
/**
* Returns a list of all shortcuts for the menus in this menu bar.
*
* @return A list of all shortcuts for the menus in this menu bar.
*/
public synchronized Enumeration
shortcuts()
{
Vector shortcuts = new Vector();
Enumeration e = menus.elements();
while (e.hasMoreElements())
{ {
return back.hasMoreElements (); Menu menu = (Menu)e.nextElement();
if (menu.getShortcut() != null)
shortcuts.addElement(menu.getShortcut());
} }
public Object nextElement () throws NoSuchElementException return(shortcuts.elements());
}
/*************************************************************************/
/**
* Returns the menu item for the specified shortcut, or <code>null</code>
* if no such item exists.
*
* @param shortcut The shortcut to return the menu item for.
*
* @return The menu item for the specified shortcut.
*/
public MenuItem
getShortcutMenuItem(MenuShortcut shortcut)
{
Enumeration e = menus.elements();
while (e.hasMoreElements())
{ {
while (true) Menu menu = (Menu)e.nextElement();
{ MenuShortcut s = menu.getShortcut();
MenuItem item = (MenuItem) back.nextElement (); if ((s != null) && (s.equals(shortcut)))
if (item.getShortcut () != null) return(menu);
return item.getShortcut ();
}
} }
}
// We use Vector because it makes enumerating easier than ArrayList return(null);
// in this case.
Vector menus;
Menu help_menu;
} }
/*************************************************************************/
/**
* Deletes the specified menu shortcut.
*
* @param shortcut The shortcut to delete.
*/
public void
deleteShortcut(MenuShortcut shortcut)
{
MenuItem it;
// This is a slow implementation, but it probably doesn't matter.
while ((it = getShortcutMenuItem (shortcut)) != null)
it.deleteShortcut ();
}
} // class MenuBar
...@@ -221,7 +221,7 @@ getToolkit() ...@@ -221,7 +221,7 @@ getToolkit()
* *
* @return The synchronization lock for this component. * @return The synchronization lock for this component.
*/ */
public final Object protected final Object
getTreeLock() getTreeLock()
{ {
return(tree_lock); return(tree_lock);
...@@ -292,7 +292,7 @@ processEvent(AWTEvent event) ...@@ -292,7 +292,7 @@ processEvent(AWTEvent event)
public String public String
toString() toString()
{ {
return(getClass().getName() + "(" + getName() + ")"); return this.getClass().getName() + "[" + paramString() + "]";
} }
/*************************************************************************/ /*************************************************************************/
...@@ -303,7 +303,7 @@ toString() ...@@ -303,7 +303,7 @@ toString()
protected String protected String
paramString() paramString()
{ {
return(toString()); return "name=" + getName();
} }
// Accessibility API not yet implemented. // Accessibility API not yet implemented.
......
/* Copyright (C) 1999, 2000 Free Software Foundation /* MenuContainer.java -- Container for menu items.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libjava. This file is part of GNU Classpath.
This software is copyrighted work licensed under the terms of the GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package java.awt;
/* Written using "Java Class Libraries", 2nd edition, plus online package java.awt;
* API docs for JDK 1.2 beta from http://www.javasoft.com.
* Status: Believed complete and correct.
*/
/**
* This interface is a container for menu components.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface MenuContainer public interface MenuContainer
{ {
public Font getFont();
/** /**
* @deprecated * Returns the font in use by this container.
*/ *
public boolean postEvent(Event evt); * @return The font in use by this container.
*/
public abstract Font
getFont();
/*************************************************************************/
/**
* Removes the specified menu component from the menu.
*
* @param component The menu component to remove.
*/
public abstract void
remove(MenuComponent component);
/*************************************************************************/
public void remove(MenuComponent comp); /**
} * Posts and event to the listeners. This is replaced by
* <code>dispatchEvent</code>.
*
* @param event The event to dispatch.
*
* @deprecated
*/
public abstract boolean
postEvent(Event event);
} // interface MenuContainer
...@@ -437,8 +437,8 @@ processActionEvent(ActionEvent event) ...@@ -437,8 +437,8 @@ processActionEvent(ActionEvent event)
public String public String
paramString() paramString()
{ {
return(getClass().getName() + "(label+" + label + ",enabled=" + enabled + return ("label=" + label + ",enabled=" + enabled +
",actionCommand=" + actionCommand + ")"); ",actionCommand=" + actionCommand + "," + super.paramString());
} }
// Accessibility API not yet implemented. // Accessibility API not yet implemented.
......
/* Copyright (C) 2000 Free Software Foundation /* MenuShortcut.java -- A class for menu accelerators
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
This software is copyrighted work licensed under the terms of the GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
package java.awt; GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
import java.awt.event.KeyEvent;
/* Status: Complete, except for hashCode(). Untested. */ package java.awt;
/**
* This class implements a keyboard accelerator for a menu item.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class MenuShortcut implements java.io.Serializable public class MenuShortcut implements java.io.Serializable
{ {
// Fields from the serialization spec. Decalare others "transient".
int key; /*
boolean usesShift; * Static Variables
*/
public MenuShortcut(int key)
{ // Serialization Constant
this.key = key; private static final long serialVersionUID = 143448358473180225L;
}
/*************************************************************************/
public MenuShortcut(int key, boolean useShiftModifier)
{ /*
this.key = key; * Instance Variables
this.usesShift = useShiftModifier; */
}
/**
public int getKey() * @serial The virtual keycode for the shortcut.
{ */
return key; private int key;
}
/**
public boolean usesShiftModifier() * @serial <code>true</code> if the shift key was used with this shortcut,
{ * or <code>false</code> otherwise.
return usesShift; */
} private boolean usesShift;
public boolean equals(MenuShortcut ms) /*************************************************************************/
{
return (ms.key == key && ms.usesShift == usesShift); /**
} * Initializes a new instance of <code>MenuShortcut</code> with the
* specified virtual key value.
public boolean equals(Object obj) *
{ * @param key The virtual keycode for the shortcut.
if (obj instanceof MenuShortcut) */
{ public
MenuShortcut ms = (MenuShortcut) obj; MenuShortcut(int key)
return (ms.key == key && ms.usesShift == usesShift); {
} this(key, false);
return false; }
}
/*************************************************************************/
public int hashCode()
{ /**
// FIXME: find/implement the correct algorithm for this * Initializes a new instance of <code>MenuShortcut</code> with the
if (usesShift) * specified virtual key value and shift setting.
return (2 * key); *
else * @param key The virtual keycode for the shortcut.
return key; * @param usesShift <code>true</code> if the shift key was pressed,
} * <code>false</code> otherwise.
*/
public String toString() public
{ MenuShortcut(int key, boolean usesShift)
return paramString(); // ? {
} this.key = key;
this.usesShift = usesShift;
protected String paramString() }
{
return KeyEvent.getKeyText(key); /*************************************************************************/
}
/*
* Instance Methods
*/
/**
* Returns the virtual keycode for this shortcut.
*
* @return The virtual keycode for this shortcut.
*/
public int
getKey()
{
return(key);
}
/*************************************************************************/
/**
* Returns the shift setting for this shortcut.
*
* @return <code>true</code> if the shift key was pressed, <code>false</code>
* otherwise.
*/
public boolean
usesShiftModifier()
{
return(usesShift);
}
/*************************************************************************/
/**
* Tests this object for equality against the specified object. The two
* objects will be considered equal if and only if the specified object
* is an instance of <code>MenuShortcut</code> and has the same key value
* and shift setting as this object.
*
* @param obj The object to test for equality against.
*
* @return <code>true</code> if the two objects are equal, <code>false</code>
* otherwise.
*/
public boolean
equals(MenuShortcut obj)
{
if (obj == null)
return(false);
if (obj.key != this.key)
return(false);
if (obj.usesShift != this.usesShift)
return(false);
return(true);
}
public boolean
equals(Object obj)
{
if (obj instanceof MenuShortcut)
{
MenuShortcut ms = (MenuShortcut) obj;
return (ms.key == key && ms.usesShift == usesShift);
}
return false;
} }
/*************************************************************************/
/**
* Returns a string representation of this shortcut.
*
* @return A string representation of this shortcut.
*/
public String
toString()
{
return(getClass().getName() + "[" + paramString () + "]");
}
public int
hashCode()
{
// Arbitrary.
return key + (usesShift ? 23 : 57);
}
/*************************************************************************/
/**
* Returns a debugging string for this object.
*
* @return A debugging string for this object.
*/
protected String
paramString()
{
return "key=" + key + ",usesShift=" + usesShift;
}
} // class MenuShortcut
/* Copyright (C) 2000 Free Software Foundation /* Copyright (C) 2000, 2002 Free Software Foundation
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
......
/* Copyright (C) 2000 Free Software Foundation /* Panel.java -- Simple container object.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.peer.PanelPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.ComponentPeer; import java.awt.peer.ComponentPeer;
/* This class is complete to 1.2. */ /**
* A panel is a simple container class.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class Panel extends Container implements java.io.Serializable
{
public class Panel extends Container /*
* Constructors
*/
/**
* Initializes a new instance of <code>Panel</code> that has a default
* layout manager of <code>FlowLayout</code>.
*/
public
Panel()
{ {
public Panel() this(new FlowLayout());
{
this (new FlowLayout ());
}
public Panel(LayoutManager layout)
{
super();
setLayout (layout);
}
//public AccessibleContext getAccessibleContext()
public void addNotify()
{
if (peer == null)
peer = getToolkit().createPanel(this);
super.addNotify();
}
} }
/*************************************************************************/
/**
* Initializes a new instance of <code>Panel</code> with the specified
* layout manager.
*
* @param layoutManager The layout manager for this object.
*/
public
Panel(LayoutManager layoutManager)
{
setLayout(layoutManager);
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Notifies this object to create its native peer.
*/
public void
addNotify()
{
if (peer == null)
peer = getToolkit().createPanel(this);
super.addNotify();
}
} // class Panel
/* Copyright (C) 2000, 2001 Free Software Foundation /* PopupMenu.java -- An AWT popup menu
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of libjava. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt; package java.awt;
import java.awt.peer.PopupMenuPeer; import java.awt.peer.PopupMenuPeer;
import java.awt.peer.MenuPeer;
import java.awt.peer.MenuItemPeer;
import java.awt.peer.MenuComponentPeer;
/**
* This class implement an AWT popup menu widget
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class PopupMenu extends Menu implements java.io.Serializable
{
/*
* Static Variables
*/
// Serialization Constant
private static final long serialVersionUID = -4620452533522760060L;
/*************************************************************************/
/*
* Constructors
*/
/**
* Initializes a new instance of <code>PopupMenu</code>.
*/
public
PopupMenu()
{
}
/* Status: Incomplete. */ /*************************************************************************/
public class PopupMenu extends Menu /**
* Initializes a new instance of <code>PopupMenu</code> with the specified
* label.
*
* @param label The label for this popup menu.
*/
public
PopupMenu(String label)
{ {
public PopupMenu() super(label);
{
super();
}
public PopupMenu(String label)
{
super(label);
}
public void addNotify()
{
if (peer != null)
{
// This choice of toolkit seems unsatisfying, but I'm not sure
// what else to do.
peer = Toolkit.getDefaultToolkit ().createPopupMenu (this);
}
super.addNotify ();
}
public void show(Component origin, int x, int y)
{
if (! origin.isShowing ()
// FIXME: or ! parent is showing -- but how?
)
{
// This is an invalid call which we choose to ignore.
return;
}
addNotify (); // FIXME?
Event e = new Event (origin, 0, 0, x, y, 0, 0);
PopupMenuPeer p = (PopupMenuPeer) peer;
p.show (e);
}
// Accessibility API not yet implemented.
// public AccessibleContext getAccessibleContext()
} }
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Creates this object's native peer.
*/
public void
addNotify()
{
if (peer != null)
peer = getToolkit ().createPopupMenu (this);
super.addNotify ();
}
/*************************************************************************/
/**
* Displays this popup menu at the specified coordinates relative to
* the specified component.
*
* @param component The component to which the display coordinates are relative.
* @param x The X coordinate of the menu.
* @param y The Y coordinate of the menu.
*/
public void
show(Component component, int x, int y)
{
PopupMenuPeer pmp = (PopupMenuPeer)getPeer();
if (pmp != null)
{
/* XXX
Event e = new Event (component, Event.ACTION_EVENT, component);
e.x = x;
e.y = y;*/
pmp.show (component, x, y);
}
}
} // class PopupMenu
/* Copyright (C) 2000 Free Software Foundation /* SystemColor.java -- Class to access system color values.
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt; package java.awt;
/** This class contains most of the colors used by the native /**
* windowing sytem to draw native components. * This class contains the various "system colors" in use by the
* @author Tom Tromey <tromey@redhat.com> * native windowing system.
* @date December 25, 2000 *
*/ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
public final class SystemColor extends Color implements java.io.Serializable public final class SystemColor extends Color implements java.io.Serializable
{ {
/** The background color for the title bar of an active window. */
public static final SystemColor activeCaption /*
= new SystemColor (ACTIVE_CAPTION); * Static Variables
/** The border color of an active window. */ */
public static final SystemColor activeCaptionBorder
= new SystemColor (ACTIVE_CAPTION_BORDER); /**
/** The color of text in the title bar of an active window. */ * Array index of the desktop color. Used by
public static final SystemColor activeCaptionText * <code>Toolkit.loadSystemColors()</code>.
= new SystemColor (ACTIVE_CAPTION_TEXT); */
/** The background color. */ public static final int DESKTOP = 0;
public static final SystemColor control = new SystemColor (CONTROL);
/** The darkest color of an outline. */ /**
public static final SystemColor controlDkShadow * Array index of the active caption color. Used by
= new SystemColor (CONTROL_DK_SHADOW); * <code>Toolkit.loadSystemColors()</code>.
/** The second brightest color of an outline. */ */
public static final SystemColor controlHighlight public static final int ACTIVE_CAPTION = 1;
= new SystemColor (CONTROL_HIGHLIGHT);
/** The brightest color of an outline. */ /**
public static final SystemColor controlLtHighlight * Array index of the active caption text color. Used by
= new SystemColor (CONTROL_LT_HIGHLIGHT); * <code>Toolkit.loadSystemColors()</code>.
/** The second darkest color of an outline. */ */
public static final SystemColor controlShadow public static final int ACTIVE_CAPTION_TEXT = 2;
= new SystemColor (CONTROL_SHADOW);
/** The color of text in a label. */ /**
public static final SystemColor controlText = new SystemColor (CONTROL_TEXT); * Array index of the active caption border color. Used by
/** The background color of the desktop. */ * <code>Toolkit.loadSystemColors()</code>.
public static final SystemColor desktop = new SystemColor (DESKTOP); */
/** The background color for the title bar of an inactive window. */ public static final int ACTIVE_CAPTION_BORDER = 3;
public static final SystemColor inactiveCaption
= new SystemColor (INACTIVE_CAPTION); /**
/** The border color of an inactive window. */ * Array index of the inactive caption color. Used by
public static final SystemColor inactiveCaptionBorder * <code>Toolkit.loadSystemColors()</code>.
= new SystemColor (INACTIVE_CAPTION_BORDER); */
/** The color of text in the title ar of an inactive window. */ public static final int INACTIVE_CAPTION = 4;
public static final SystemColor inactiveCaptionText
= new SystemColor (INACTIVE_CAPTION_TEXT); /**
/** The background color of tooltips. */ * Array index of the inactive caption text color. Used by
public static final SystemColor info = new SystemColor (INFO); * <code>Toolkit.loadSystemColors()</code>.
/** The color of text in tooltips. */ */
public static final SystemColor infoText = new SystemColor (INFO_TEXT); public static final int INACTIVE_CAPTION_TEXT = 5;
/** The background color of a menu. */
public static final SystemColor menu = new SystemColor (MENU); /**
/** The color of text in a menu. */ * Array index of the inactive caption border color. Used by
public static final SystemColor menuText = new SystemColor (MENU_TEXT); * <code>Toolkit.loadSystemColors()</code>.
/** The background color of a scrollbar. */ */
public static final SystemColor scrollbar = new SystemColor (SCROLLBAR); public static final int INACTIVE_CAPTION_BORDER = 6;
/** The background color of text components. */
public static final SystemColor text = new SystemColor (TEXT); /**
/** The background color of highlighted text. */ * Array index of the window background color. Used by
public static final SystemColor textHighlight * <code>Toolkit.loadSystemColors()</code>.
= new SystemColor (TEXT_HIGHLIGHT); */
/** The color of highlighted text. */ public static final int WINDOW = 7;
public static final SystemColor textHighlightText
= new SystemColor (TEXT_HIGHLIGHT_TEXT); /**
/** The color of inactive text. */ * Array index of the window border color. Used by
public static final SystemColor textInactiveText * <code>Toolkit.loadSystemColors()</code>.
= new SystemColor (TEXT_INACTIVE_TEXT); */
/** The color of text in text components. */ public static final int WINDOW_BORDER = 8;
public static final SystemColor textText = new SystemColor (TEXT_TEXT);
/** The background color of a window. */ /**
public static final SystemColor window = new SystemColor (WINDOW); * Array index of the window text color. Used by
/** The border color of a window. */ * <code>Toolkit.loadSystemColors()</code>.
public static final SystemColor windowBorder */
= new SystemColor (WINDOW_BORDER); public static final int WINDOW_TEXT = 9;
/** The color of text in a window. */
public static final SystemColor windowText = new SystemColor (WINDOW_TEXT); /**
* Array index of the menu background color. Used by
public static final int DESKTOP = 0; * <code>Toolkit.loadSystemColors()</code>.
public static final int ACTIVE_CAPTION = 1; */
public static final int ACTIVE_CAPTION_TEXT = 2; public static final int MENU = 10;
public static final int ACTIVE_CAPTION_BORDER = 3;
public static final int INACTIVE_CAPTION = 4; /**
public static final int INACTIVE_CAPTION_TEXT = 5; * Array index of the menu text color. Used by
public static final int INACTIVE_CAPTION_BORDER = 6; * <code>Toolkit.loadSystemColors()</code>.
public static final int WINDOW = 7; */
public static final int WINDOW_BORDER = 8; public static final int MENU_TEXT = 11;
public static final int WINDOW_TEXT = 9;
public static final int MENU = 10; /**
public static final int MENU_TEXT = 11; * Array index of the text background color. Used by
public static final int TEXT = 12; * <code>Toolkit.loadSystemColors()</code>.
public static final int TEXT_TEXT = 13; */
public static final int TEXT_HIGHLIGHT = 14; public static final int TEXT = 12;
public static final int TEXT_HIGHLIGHT_TEXT = 15;
public static final int TEXT_INACTIVE_TEXT = 16; /**
public static final int CONTROL = 17; * Array index of the text foreground color. Used by
public static final int CONTROL_TEXT = 18; * <code>Toolkit.loadSystemColors()</code>.
public static final int CONTROL_HIGHLIGHT = 19; */
public static final int CONTROL_LT_HIGHLIGHT = 20; public static final int TEXT_TEXT = 13;
public static final int CONTROL_SHADOW = 21;
public static final int CONTROL_DK_SHADOW = 22; /**
public static final int SCROLLBAR = 23; * Array index of the highlighted text background color. Used by
public static final int INFO = 24; * <code>Toolkit.loadSystemColors()</code>.
public static final int INFO_TEXT = 25; */
public static final int TEXT_HIGHLIGHT = 14;
public static final int NUM_COLORS = 26;
/**
private static final int rgbs[] = * Array index of the highlighted text foreground color. Used by
{ * <code>Toolkit.loadSystemColors()</code>.
0x005c5c, */
0x000080, public static final int TEXT_HIGHLIGHT_TEXT = 15;
0xffffff,
0xc0c0c0, /**
0x808080, * Array index of the inactive text foreground color. Used by
0xc0c0c0, * <code>Toolkit.loadSystemColors()</code>.
0xc0c0c0, */
0xffffff, public static final int TEXT_INACTIVE_TEXT = 16;
0x000000,
0x000000, /**
0xc0c0c0, * Array index of the control background color. Used by
0x000000, * <code>Toolkit.loadSystemColors()</code>.
0xc0c0c0, */
0x000000, public static final int CONTROL = 17;
0x000080,
0xffffff, /**
0x808080, * Array index of the control text color. Used by
0xc0c0c0, * <code>Toolkit.loadSystemColors()</code>.
0x000000, */
0xffffff, public static final int CONTROL_TEXT = 18;
0xe0e0e0,
0x808080, /**
0x000000, * Array index of the highlighted control background color. Used by
0xe0e0e0, * <code>Toolkit.loadSystemColors()</code>.
0xe0e000, */
0x000000 public static final int CONTROL_HIGHLIGHT = 19;
};
/**
public int getRGB () * Array index of the lightly highlighted control background color. Used by
{ * <code>Toolkit.loadSystemColors()</code>.
return rgbs[rgba]; */
} public static final int CONTROL_LT_HIGHLIGHT = 20;
public String toString () /**
{ * Array index of the shadowed control background color. Used by
return "[" + getClass ().getName () + " " + rgba + "]"; * <code>Toolkit.loadSystemColors()</code>.
} */
public static final int CONTROL_SHADOW = 21;
private SystemColor (int index)
{ /**
super (index, true); * Array index of the darkly shadowed control background color. Used by
} * <code>Toolkit.loadSystemColors()</code>.
*/
public static final int CONTROL_DK_SHADOW = 22;
/**
* Array index of the scrollbar background color. Used by
* <code>Toolkit.loadSystemColors()</code>.
*/
public static final int SCROLLBAR = 23;
/**
* Array index of the info background color. Used by
* <code>Toolkit.loadSystemColors()</code>.
*/
public static final int INFO = 24;
/**
* Array index of the info text color. Used by
* <code>Toolkit.loadSystemColors()</code>.
*/
public static final int INFO_TEXT = 25;
/**
* The number of system colors. Used by
* <code>Toolkit.loadSystemColors()</code>.
*/
public static final int NUM_COLORS = 26;
/**
* The desktop color.
*/
public static final SystemColor desktop;
/**
* The active caption background color.
*/
public static final SystemColor activeCaption;
/**
* The active caption text color.
*/
public static final SystemColor activeCaptionText;
/**
* The active caption border color.
*/
public static final SystemColor activeCaptionBorder;
/**
* The inactive caption background color.
*/
public static final SystemColor inactiveCaption;
/**
* The inactive caption text color.
*/
public static final SystemColor inactiveCaptionText;
/**
* The inactive caption border color.
*/
public static final SystemColor inactiveCaptionBorder;
/**
* The window background color.
*/
public static final SystemColor window;
/**
* The window border color.
*/
public static final SystemColor windowBorder;
/**
* The window text color.
*/
public static final SystemColor windowText;
/**
* The menu background color.
*/
public static final SystemColor menu;
/**
* The menu text color.
*/
public static final SystemColor menuText;
/**
* The text background color.
*/
public static final SystemColor text;
/**
* The text foreground color.
*/
public static final SystemColor textText;
/**
* The highlighted text background color.
*/
public static final SystemColor textHighlight;
/**
* The highlighted text foreground color.
*/
public static final SystemColor textHighlightText;
/**
* The inactive text color.
*/
public static final SystemColor textInactiveText;
/**
* The control background color.
*/
public static final SystemColor control;
/**
* The control text color.
*/
public static final SystemColor controlText;
/**
* The control highlight color.
*/
public static final SystemColor controlHighlight;
/**
* The control light highlight color.
*/
public static final SystemColor controlLtHighlight;
/**
* The control shadow color.
*/
public static final SystemColor controlShadow;
/**
* The control dark shadow color.
*/
public static final SystemColor controlDkShadow;
/**
* The scrollbar color.
*/
public static final SystemColor scrollbar;
/**
* The info text background color.
*/
public static final SystemColor info;
/**
* The info text foreground color.
*/
public static final SystemColor infoText;
// Serialization version constant
private static final long serialVersionUID = 4503142729533789064L;
static
{
int[] sys_color_rgbs = new int[NUM_COLORS];
Toolkit.getDefaultToolkit().loadSystemColors(sys_color_rgbs);
desktop = new SystemColor(sys_color_rgbs[DESKTOP]);
activeCaption= new SystemColor(sys_color_rgbs[ACTIVE_CAPTION]);
activeCaptionText= new SystemColor(sys_color_rgbs[ACTIVE_CAPTION_TEXT]);
activeCaptionBorder = new SystemColor(sys_color_rgbs[ACTIVE_CAPTION_BORDER]);
inactiveCaption = new SystemColor(sys_color_rgbs[INACTIVE_CAPTION]);
inactiveCaptionText = new SystemColor(sys_color_rgbs[INACTIVE_CAPTION_TEXT]);
inactiveCaptionBorder =
new SystemColor(sys_color_rgbs[INACTIVE_CAPTION_BORDER]);
window = new SystemColor(sys_color_rgbs[WINDOW]);
windowBorder = new SystemColor(sys_color_rgbs[WINDOW_BORDER]);
windowText = new SystemColor(sys_color_rgbs[WINDOW_TEXT]);
menu = new SystemColor(sys_color_rgbs[MENU]);
menuText = new SystemColor(sys_color_rgbs[MENU_TEXT]);
text = new SystemColor(sys_color_rgbs[TEXT]);
textText = new SystemColor(sys_color_rgbs[TEXT_TEXT]);
textHighlight = new SystemColor(sys_color_rgbs[TEXT_HIGHLIGHT]);
textHighlightText = new SystemColor(sys_color_rgbs[TEXT_HIGHLIGHT_TEXT]);
textInactiveText = new SystemColor(sys_color_rgbs[TEXT_INACTIVE_TEXT]);
control = new SystemColor(sys_color_rgbs[CONTROL]);
controlText = new SystemColor(sys_color_rgbs[CONTROL_TEXT]);
controlHighlight = new SystemColor(sys_color_rgbs[CONTROL_HIGHLIGHT]);
controlLtHighlight = new SystemColor(sys_color_rgbs[CONTROL_LT_HIGHLIGHT]);
controlShadow = new SystemColor(sys_color_rgbs[CONTROL_SHADOW]);
controlDkShadow = new SystemColor(sys_color_rgbs[CONTROL_DK_SHADOW]);
scrollbar = new SystemColor(sys_color_rgbs[SCROLLBAR]);
info = new SystemColor(sys_color_rgbs[INFO]);
infoText = new SystemColor(sys_color_rgbs[INFO_TEXT]);
}
/*************************************************************************/
/*
* Constructors
*/
private
SystemColor(int rgb)
{
super(rgb);
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Returns the RGB value for this color as an <code>int</code>. The first
* byte is the blue value, the second the green value, the third the
* red value and the fourth is set to 0xFF.
*
* @return The RGB value.
*/
public int
getRGB()
{
// Override only to be spec consistent.
return(super.getRGB());
}
/*************************************************************************/
/**
* Returns a string describing this color.
*
* @return A string describing this color.
*/
public String
toString()
{
return("SystemColor(R=" + getRed() + ",G=" + getGreen() + ",B=" +
getBlue() + ")");
} }
} // class SystemColor
/* Copyright (C) 2000 Free Software Foundation /* ButtonPeer.java -- Peer interface for buttons
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface ButtonPeer extends ComponentPeer public interface ButtonPeer extends ComponentPeer
{ {
void setLabel(String label);
} public abstract void setLabel(String label);
} // interface ButtonPeer
/* Copyright (C) 2000 Free Software Foundation /* CanvasPeer.java -- Peer interface for a canvas
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface CanvasPeer extends ComponentPeer public interface CanvasPeer extends ComponentPeer
{ {
}
} // interface CanvasPeer
/* Copyright (C) 2000 Free Software Foundation /* CheckboxMenuItemPeer.java -- Peer interface for checkbox menu items
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface CheckboxMenuItemPeer extends MenuItemPeer public interface CheckboxMenuItemPeer extends MenuItemPeer
{ {
void setState(boolean state);
} public abstract void setState(boolean state);
} // interface CheckboxMenuItemPeer
/* Copyright (C) 2000 Free Software Foundation /* CheckboxPeer.java -- Interface for checkbox peer
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface CheckboxPeer extends ComponentPeer public interface CheckboxPeer extends ComponentPeer
{ {
void setCheckboxGroup(java.awt.CheckboxGroup group);
void setLabel(String label); public abstract void setCheckboxGroup(java.awt.CheckboxGroup group);
void setState(boolean state); public abstract void setLabel(String label);
} public abstract void setState(boolean state);
} // interface CheckboxPeer
/* Copyright (C) 2000 Free Software Foundation /* ChoicePeer.java -- Peer for choice box
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface ChoicePeer extends ComponentPeer public interface ChoicePeer extends ComponentPeer
{ {
void add(String item, int index);
void remove(int index); public abstract void add(String item, int index);
void select(int index); public abstract void addItem(String item, int index);
} public abstract void remove(int index);
public abstract void select(int index);
} // interface ChoicePeer
/* Copyright (C) 2000 Free Software Foundation /* ComponentPeer.java -- Toplevel component peer
Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -13,10 +32,42 @@ import java.awt.image.*; ...@@ -13,10 +32,42 @@ import java.awt.image.*;
public interface ComponentPeer public interface ComponentPeer
{ {
int checkImage(Image img, int width, int height, ImageObserver o); public int checkImage(Image img, int width, int height,
Image createImage(ImageProducer prod); ImageObserver ob);
Image createImage(int width, int height); public Image createImage(ImageProducer prod);
void dispose(); public Image createImage(int width, int height);
public void disable();
public void dispose();
public void enable();
public ColorModel getColorModel();
public FontMetrics getFontMetrics(Font f);
public Graphics getGraphics();
public Point getLocationOnScreen();
public Dimension getMinimumSize();
public Dimension getPreferredSize();
public Toolkit getToolkit();
// The JCL says that handleEvent returns boolean. However, we've
// experimentally determined that it in fact actually returns void.
public void handleEvent(AWTEvent e);
public void hide();
public boolean isFocusTraversable();
public Dimension minimumSize();
public Dimension preferredSize();
public void paint(Graphics graphics);
public boolean prepareImage(Image img, int width, int height,
ImageObserver ob);
public void print(Graphics graphics);
public void repaint(long tm, int x, int y, int width, int height);
public void requestFocus();
public void reshape(int x, int y, int width, int height);
public void setBackground(Color color);
public void setBounds(int x, int y, int width, int height);
public void setCursor(Cursor cursor);
public void setEnabled(boolean enabled);
public void setFont(Font font);
public void setForeground(Color color);
public void setVisible(boolean visible);
public void show();
/** /**
* Get the graphics configuration of the component. The color model * Get the graphics configuration of the component. The color model
...@@ -24,27 +75,5 @@ public interface ComponentPeer ...@@ -24,27 +75,5 @@ public interface ComponentPeer
*/ */
GraphicsConfiguration getGraphicsConfiguration(); GraphicsConfiguration getGraphicsConfiguration();
FontMetrics getFontMetrics(Font f); public void setEventMask (long mask);
Graphics getGraphics();
Point getLocationOnScreen();
Dimension getMinimumSize();
Dimension getPreferredSize();
Toolkit getToolkit();
// The JCL says that handleEvent returns boolean. However, we've
// experimentally determined that it in fact actually returns void.
void handleEvent(AWTEvent e);
boolean isFocusTraversable();
void paint(Graphics graphics);
boolean prepareImage(Image img, int width, int height, ImageObserver o);
void print(Graphics graphics);
void repaint(long tm, int x, int y, int width, int height);
void requestFocus();
void setBackground(Color color);
void setBounds(int x, int y, int width, int height);
void setCursor(Cursor cursor);
void setEnabled(boolean enabled);
void setEventMask(long eventMask);
void setFont(Font font);
void setForeground(Color color);
void setVisible(boolean visible);
} }
/* Copyright (C) 2000 Free Software Foundation /* ContainerPeer.java -- Interface for container peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,7 +31,11 @@ import java.awt.Insets; ...@@ -12,7 +31,11 @@ import java.awt.Insets;
public interface ContainerPeer extends ComponentPeer public interface ContainerPeer extends ComponentPeer
{ {
Insets getInsets();
void beginValidate(); public abstract Insets insets();
void endValidate(); public abstract Insets getInsets();
} public abstract void beginValidate();
public abstract void endValidate();
} // interface ContainerPeer
/* Copyright (C) 2000 Free Software Foundation /* DialogPeer.java -- Interface for dialog box peer
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface DialogPeer extends WindowPeer public interface DialogPeer extends WindowPeer
{ {
void setResizable(boolean resizeable);
void setTitle(String title); public abstract void setResizable(boolean resizeable);
} public abstract void setTitle(String title);
} // interface DialogPeer
/* Copyright (C) 2000 Free Software Foundation /* FileDialogPeer.java -- Interface for file selection dialog box peer
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,7 +31,10 @@ import java.io.FilenameFilter; ...@@ -12,7 +31,10 @@ import java.io.FilenameFilter;
public interface FileDialogPeer extends DialogPeer public interface FileDialogPeer extends DialogPeer
{ {
void setDirectory(String dir);
void setFile(String file); public abstract void setFile(String file);
void setFilenameFilter(FilenameFilter filter); public abstract void setDirectory(String dir);
} public abstract void setFilenameFilter(FilenameFilter ff);
} // interface FileDialogPeer
/* Copyright (C) 2000 Free Software Foundation /* FontPeer.java -- Interface for font peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface FontPeer public interface FontPeer
{ {
}
} // interface FontPeer
/* Copyright (C) 2000 Free Software Foundation /* FramePeer.java -- Interface for frame peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -13,8 +32,11 @@ import java.awt.MenuBar; ...@@ -13,8 +32,11 @@ import java.awt.MenuBar;
public interface FramePeer extends WindowPeer public interface FramePeer extends WindowPeer
{ {
void setIconImage(Image image);
void setMenuBar(MenuBar mb); public abstract void setIconImage(Image image);
void setResizable(boolean resizable); public abstract void setMenuBar(MenuBar mb);
void setTitle(String title); public abstract void setResizable(boolean resizable);
} public abstract void setTitle(String title);
} // interface FramePeer
/* Copyright (C) 2000 Free Software Foundation /* LabelPeer.java -- Interface for simple text lable peer
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface LabelPeer extends ComponentPeer public interface LabelPeer extends ComponentPeer
{ {
void setAlignment(int alignment);
void setText(String text); public abstract void setAlignment(int alignment);
} public abstract void setText(String text);
} // interface LabelPeer
/* Copyright (C) 2000 Free Software Foundation /* LightweightPeer.java -- Interface for lightweight peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface LightweightPeer extends ComponentPeer public interface LightweightPeer extends ComponentPeer
{ {
}
} // interface LightweightPeer
/* Copyright (C) 2000 Free Software Foundation /* ListPeer.java -- Interface for list box peer
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,12 +31,20 @@ import java.awt.Dimension; ...@@ -12,12 +31,20 @@ import java.awt.Dimension;
public interface ListPeer extends ComponentPeer public interface ListPeer extends ComponentPeer
{ {
void add(String item, int index);
void delItems(int start_index, int end_index); public abstract void add(String item, int index);
void deselect(int index); public abstract void addItem(String item, int index);
int[] getSelectedIndexes(); public abstract void clear();
void makeVisible(int index); public abstract void delItems(int start_index, int end_index);
void removeAll(); public abstract void deselect(int index);
void select(int index); public abstract int[] getSelectedIndexes();
void setMultipleMode(boolean multipleMode); public abstract void makeVisible(int index);
} public abstract Dimension minimumSize(int s);
public abstract Dimension preferredSize(int s);
public abstract void removeAll();
public abstract void select(int index);
public abstract void setMultipleMode(boolean multi);
public abstract void setMultipleSelections(boolean multi);
} // interface ListPeer
/* Copyright (C) 2000 Free Software Foundation /* MenuBarPeer.java -- Interface for menu bar peer
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,7 +31,10 @@ import java.awt.Menu; ...@@ -12,7 +31,10 @@ import java.awt.Menu;
public interface MenuBarPeer extends MenuComponentPeer public interface MenuBarPeer extends MenuComponentPeer
{ {
void addHelpMenu(Menu menu);
void add(Menu menu); public abstract void addHelpMenu(Menu menu);
void remove(int index); public abstract void addMenu(Menu menu);
} public abstract void delMenu(int index);
} // interface MenuBarPeer
/* Copyright (C) 2000 Free Software Foundation /* MenuComponentPeer.java --
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface MenuComponentPeer public interface MenuComponentPeer
{ {
void dispose();
} public abstract void dispose();
} // interface MenuComponentPeer
/* Copyright (C) 2000 Free Software Foundation /* MenuItemPeer.java -- Interface for menu item peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface MenuItemPeer extends MenuComponentPeer public interface MenuItemPeer extends MenuComponentPeer
{ {
void setEnabled(boolean enabled);
void setLabel(String text); public abstract void disable();
} public abstract void enable();
public abstract void setEnabled(boolean enabled);
public abstract void setLabel(String text);
} // interface MenuItemPeer
/* Copyright (C) 2000 Free Software Foundation /* MenuPeer.java -- Interface for menu peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,7 +31,8 @@ import java.awt.MenuItem; ...@@ -12,7 +31,8 @@ import java.awt.MenuItem;
public interface MenuPeer extends MenuItemPeer public interface MenuPeer extends MenuItemPeer
{ {
void add(MenuItem item); public abstract void addItem (MenuItem item);
void addSeparator(); public abstract void addSeparator ();
void remove(int index); public abstract void delItem (int index);
} }
/* Copyright (C) 2000 Free Software Foundation /* PanelPeer.java -- Interface for panel peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface PanelPeer extends ContainerPeer public interface PanelPeer extends ContainerPeer
{ {
}
} // interface PanelPeer
/* Copyright (C) 2000 Free Software Foundation /* PopupMenuPeer.java -- Interface for popup menu peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
This software is copyrighted work licensed under the terms of the GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package java.awt.peer;
import java.awt.Event; package java.awt.peer;
import java.awt.Component;
public interface PopupMenuPeer extends MenuPeer public interface PopupMenuPeer extends MenuPeer
{ {
void show(Event e);
} public abstract void show (Component origin, int x, int y);
} // interface PopupMenuPeer
/* Copyright (C) 2000 Free Software Foundation /* ScrollPanePeer.java -- Interface for scrollable panes
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,10 +31,13 @@ import java.awt.Adjustable; ...@@ -12,10 +31,13 @@ import java.awt.Adjustable;
public interface ScrollPanePeer extends ContainerPeer public interface ScrollPanePeer extends ContainerPeer
{ {
void childResized(int width, int height);
int getHScrollbarHeight(); public abstract int getHScrollbarHeight();
int getVScrollbarWidth(); public abstract int getVScrollbarWidth();
void setScrollPosition(int x, int y); public abstract void setScrollPosition(int h, int v);
void setUnitIncrement(Adjustable adj, int increment); public abstract void childResized(int width, int height);
void setValue(Adjustable adj, int value); public abstract void setUnitIncrement(Adjustable item, int inc);
} public abstract void setValue(Adjustable item, int value);
} // interface ScollPanePeer
/* Copyright (C) 2000 Free Software Foundation /* ScrollbarPeer.java -- Interface for scrollbar peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface ScrollbarPeer extends ComponentPeer public interface ScrollbarPeer extends ComponentPeer
{ {
void setLineIncrement(int increment);
void setPageIncrement(int increment); public abstract void setLineIncrement(int inc);
void setValues(int value, int visible, int minimum, int maximum); public abstract void setPageIncrement(int inc);
} public abstract void setValues(int value, int visible, int min, int max);
} // interface ScrollbarPeer
/* Copyright (C) 2000 Free Software Foundation /* TextAreaPeer.java -- Interface for text area peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,6 +31,14 @@ import java.awt.Dimension; ...@@ -12,6 +31,14 @@ import java.awt.Dimension;
public interface TextAreaPeer extends TextComponentPeer public interface TextAreaPeer extends TextComponentPeer
{ {
void insert(String text, int pos);
void replaceRange(String text, int start, int end); public abstract void insert(String text, int pos);
} public abstract void insertText(String text, int pos);
public abstract Dimension minimumSize(int rows, int cols);
public abstract Dimension getMinimumSize(int rows, int cols);
public abstract Dimension preferredSize(int rows, int cols);
public abstract Dimension getPreferredSize(int rows, int cols);
public abstract void replaceRange(String text, int start_pos, int end_pos);
public abstract void replaceText(String text, int start_pos, int end_pos);
} // interface TextAreaPeer
/* Copyright (C) 2000 Free Software Foundation /* TextComponentPeer.java -- Superclass interface for text components
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface TextComponentPeer extends ComponentPeer public interface TextComponentPeer extends ComponentPeer
{ {
int getCaretPosition();
int getSelectionEnd(); public abstract int getSelectionEnd();
int getSelectionStart(); public abstract int getSelectionStart();
String getText(); public abstract String getText();
void select(int start, int end); public abstract void setText(String text);
void setCaretPosition(int pos); public abstract void select(int start_pos, int end_pos);
void setEditable(boolean editable); public abstract void setEditable(boolean editable);
void setText(String text); public abstract int getCaretPosition();
} public abstract void setCaretPosition(int pos);
} // interface TextComponentPeer
/* Copyright (C) 2000 Free Software Foundation /* TextFieldPeer.java -- Interface for text field peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
...@@ -12,5 +31,13 @@ import java.awt.Dimension; ...@@ -12,5 +31,13 @@ import java.awt.Dimension;
public interface TextFieldPeer extends TextComponentPeer public interface TextFieldPeer extends TextComponentPeer
{ {
void setEchoChar(char echo);
} public abstract Dimension minimumSize(int len);
public abstract Dimension preferredSize(int len);
public abstract Dimension getMinimumSize(int len);
public abstract Dimension getPreferredSize(int len);
public abstract void setEchoChar(char echo_char);
public abstract void setEchoCharacter(char echo_char);
} // interface TextFieldPeer
/* Copyright (C) 2000 Free Software Foundation /* WindowPeer.java -- Interface for window peers
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt.peer; package java.awt.peer;
public interface WindowPeer extends ContainerPeer public interface WindowPeer extends ContainerPeer
{ {
void toBack();
void toFront(); public abstract void toBack();
} public abstract void toFront();
} // interface WindowPeer
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment