AWT/Swing merge from GNU Classpath.

From-SVN: r56147
This commit is contained in:
Bryce McKinlay
2002-08-09 04:26:17 +00:00
committed by Bryce McKinlay
parent 097684ce62
commit 7bde45b2eb
490 changed files with 86038 additions and 9753 deletions
+56 -14
View File
@@ -1,22 +1,64 @@
/* Copyright (C) 2000 Free Software Foundation
/* AWTEventListener.java -- listen for all events in the AWT system
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.AWTEvent;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This listener is for classes that need to listen to all events in the AWT
* system. In general, this should not be used except for classes like
* javax.accessibility or by event recorders.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see AWTEvent
* @see Toolkit#addAWTEventListener(AWTEventListener, long)
* @see Toolkit#removeAWTEventListener(AWTEventListener)
* @since 1.2
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface AWTEventListener extends java.util.EventListener
public interface AWTEventListener extends EventListener
{
public void eventDispatched (AWTEvent e);
}
/**
* This method is called when any event in the AWT system is dispatched.
*
* @param event the AWTEvent that was dispatched
*/
void eventDispatched(AWTEvent event);
} // interface AWTEventListener
@@ -0,0 +1,154 @@
/* AWTEventListenerProxy.java -- wrapper/filter for AWTEventListener
Copyright (C) 2002 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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.event;
import java.awt.AWTEvent;
import java.util.EventListenerProxy;
/**
* This class allows adding an AWTEventListener which only pays attention to
* a specific event mask.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @see Toolkit
* @see EventListenerProxy
* @since 1.4
* @status updated to 1.4
*/
public class AWTEventListenerProxy extends EventListenerProxy
implements AWTEventListener
{
/** The event mask. */
private final long mask;
/**
* Construct an AWT Event Listener which only listens to events in the given
* mask, passing the work on to the real listener.
*
* @param eventMask the mask of events to listen to
* @param listener the wrapped listener
*/
public AWTEventListenerProxy(long eventMask, AWTEventListener listener)
{
super(listener);
mask = eventMask;
}
/**
* Forwards events on to the delegate if they meet the event mask.
*
* @param event the property change event to filter
* @throws NullPointerException if the delegate this was created with is null
*/
public void eventDispatched(AWTEvent event)
{
int id = event == null ? 0 : event.getID();
if (((mask & AWTEvent.ACTION_EVENT_MASK) != 0
&& event instanceof ActionEvent)
|| ((mask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0
&& event instanceof AdjustmentEvent)
|| ((mask & AWTEvent.COMPONENT_EVENT_MASK) != 0
&& event instanceof ComponentEvent
&& (id >= ComponentEvent.COMPONENT_FIRST
&& id <= ComponentEvent.COMPONENT_LAST))
|| ((mask & AWTEvent.CONTAINER_EVENT_MASK) != 0
&& event instanceof ContainerEvent)
|| ((mask & AWTEvent.FOCUS_EVENT_MASK) != 0
&& event instanceof FocusEvent)
|| ((mask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0
&& event instanceof HierarchyEvent
&& (id == HierarchyEvent.ANCESTOR_MOVED
|| id == HierarchyEvent.ANCESTOR_RESIZED))
|| ((mask & AWTEvent.HIERARCHY_EVENT_MASK) != 0
&& event instanceof HierarchyEvent
&& id == HierarchyEvent.HIERARCHY_CHANGED)
|| ((mask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0
&& event instanceof InputMethodEvent)
|| ((mask & AWTEvent.INVOCATION_EVENT_MASK) != 0
&& event instanceof InvocationEvent)
|| ((mask & AWTEvent.ITEM_EVENT_MASK) != 0
&& event instanceof ItemEvent)
|| ((mask & AWTEvent.KEY_EVENT_MASK) != 0
&& event instanceof KeyEvent)
|| ((mask & AWTEvent.MOUSE_EVENT_MASK) != 0
&& event instanceof MouseEvent
&& (id == MouseEvent.MOUSE_PRESSED
|| id == MouseEvent.MOUSE_RELEASED
|| id == MouseEvent.MOUSE_CLICKED
|| id == MouseEvent.MOUSE_ENTERED
|| id == MouseEvent.MOUSE_EXITED))
|| ((mask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0
&& event instanceof MouseEvent
&& (id == MouseEvent.MOUSE_MOVED
|| id == MouseEvent.MOUSE_DRAGGED))
|| ((mask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0
&& event instanceof MouseWheelEvent)
|| ((mask & AWTEvent.PAINT_EVENT_MASK) != 0
&& event instanceof PaintEvent)
|| ((mask & AWTEvent.TEXT_EVENT_MASK) != 0
&& event instanceof TextEvent)
|| ((mask & AWTEvent.WINDOW_EVENT_MASK) != 0
&& event instanceof WindowEvent
&& (id == WindowEvent.WINDOW_OPENED
|| id == WindowEvent.WINDOW_CLOSING
|| id == WindowEvent.WINDOW_CLOSED
|| id == WindowEvent.WINDOW_ICONIFIED
|| id == WindowEvent.WINDOW_DEICONIFIED
|| id == WindowEvent.WINDOW_ACTIVATED
|| id == WindowEvent.WINDOW_DEACTIVATED))
|| ((mask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0
&& event instanceof WindowEvent
&& (id == WindowEvent.WINDOW_GAINED_FOCUS
|| id == WindowEvent.WINDOW_LOST_FOCUS))
|| ((mask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0
&& event instanceof WindowEvent
&& id == WindowEvent.WINDOW_STATE_CHANGED))
((AWTEventListener) getListener()).eventDispatched(event);
}
/**
* This returns the event mask associated with this listener.
*
* @return the event mask
*/
public long getEventMask()
{
return mask;
}
} // class AWTEventListenerProxy
+196 -36
View File
@@ -1,66 +1,226 @@
/* Copyright (C) 1999, 2000 Free Software Foundation
/* ActionEvent.java -- an action has been triggered
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
/* Status: Believed complete and correct to JDK 1.2. */
import java.awt.AWTEvent;
import java.awt.EventQueue;
/**
* This event is generated when an action on a component (such as a
* button press) occurs.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ActionListener
* @since 1.1
* @status updated to 1.4
*/
public class ActionEvent extends AWTEvent
{
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -7671078796273832149L;
/** Bit mask indicating the shift key was pressed. */
public static final int SHIFT_MASK = InputEvent.SHIFT_MASK;
/** Bit mask indicating the control key was pressed. */
public static final int CTRL_MASK = InputEvent.CTRL_MASK;
/** Bit mask indicating the that meta key was pressed. */
public static final int META_MASK = InputEvent.META_MASK;
/** Bit mask indicating that the alt key was pressed. */
public static final int ALT_MASK = InputEvent.ALT_MASK;
/** The first id number in the range of action id's. */
public static final int ACTION_FIRST = 1001;
/** The last id number in the range of action id's. */
public static final int ACTION_LAST = 1001;
/** An event id indicating that an action has occurred. */
public static final int ACTION_PERFORMED = 1001;
public static final int ALT_MASK = 8;
public static final int CTRL_MASK = 2;
public static final int META_MASK = 4;
public static final int SHIFT_MASK = 1;
String cmd;
int modifiers;
/**
* A nonlocalized string that gives more specific details of the event cause.
*
* @see #getActionCommand()
* @serial the command for this event
*/
private final String actionCommand;
public ActionEvent (Object source, int id, String command)
/**
* The bitmask of the modifiers that were pressed during the action.
*
* @see #getModifiers()
* @serial modifiers for this event
*/
private final int modifiers;
/**
* The timestamp of this event; usually the same as the underlying input
* event.
*
* @see #getWhen()
* @serial the timestamp of the event
* @since 1.4
*/
private final long when;
/**
* Initializes a new instance of <code>ActionEvent</code> with the
* specified source, id, and command. Note that an invalid id leads to
* unspecified results.
*
* @param source the event source
* @param id the event id
* @param command the command string for this action
* @throws IllegalArgumentException if source is null
*/
public ActionEvent(Object source, int id, String command)
{
super(source, id);
cmd = command;
this(source, id, command, EventQueue.getMostRecentEventTime(), 0);
}
public ActionEvent (Object source, int id, String command, int modifiers)
/**
* Initializes a new instance of <code>ActionEvent</code> with the
* specified source, id, command, and modifiers. Note that an invalid id
* leads to unspecified results.
*
* @param source the event source
* @param id the event id
* @param command the command string for this action
* @param modifiers the bitwise or of modifier keys down during the action
* @throws IllegalArgumentException if source is null
*/
public ActionEvent(Object source, int id, String command, int modifiers)
{
this(source, id, command, EventQueue.getMostRecentEventTime(), modifiers);
}
/**
* Initializes a new instance of <code>ActionEvent</code> with the
* specified source, id, command, and modifiers, and timestamp. Note that
* an invalid id leads to unspecified results.
*
* @param source the event source
* @param id the event id
* @param command the command string for this action
* @param when the timestamp of the event
* @param modifiers the bitwise or of modifier keys down during the action
* @throws IllegalArgumentException if source is null
* @since 1.4
*/
public ActionEvent(Object source, int id, String command, long when,
int modifiers)
{
super(source, id);
cmd = command;
actionCommand = command;
this.when = when;
this.modifiers = modifiers;
}
public String getActionCommand ()
/**
* Returns the command string associated with this action.
*
* @return the command string associated with this action
*/
public String getActionCommand()
{
return cmd;
return actionCommand;
}
public int getModifiers ()
/**
* Gets the timestamp of when this action took place. Usually, this
* corresponds to the timestamp of the underlying InputEvent.
*
* @return the timestamp of this action
* @since 1.4
*/
public long getWhen()
{
return when;
}
/**
* Returns the keys held down during the action. This value will be a
* combination of the bit mask constants defined in this class, or 0 if no
* modifiers were pressed.
*
* @return the modifier bits
*/
public int getModifiers()
{
return modifiers;
}
public String paramString ()
/**
* Returns a string that identifies the action event. This is in the format
* <code>"ACTION_PERFORMED,cmd=" + getActionCommand() + ",when=" + getWhen()
* + ",modifiers=" + &lt;modifier string&gt;</code>, where the modifier
* string is in the order "Meta", "Ctrl", "Alt", "Shift", "Alt Graph", and
* "Button1", separated by '+', according to the bits set in getModifiers().
*
* @return a string identifying the event
*/
public String paramString()
{
String r;
switch (id)
{
case ACTION_PERFORMED:
r = "ACTION_PERFORMED";
break;
default:
r = "unknown type";
break;
}
r += ",cmd=" + cmd;
return r;
StringBuffer s = new StringBuffer(id == ACTION_PERFORMED
? "ACTION_PERFORMED,cmd="
: "unknown type,cmd=");
s.append(actionCommand).append(",when=").append(when).append("modifiers");
int len = s.length();
s.setLength(len + 1);
if ((modifiers & META_MASK) != 0)
s.append("+Meta");
if ((modifiers & CTRL_MASK) != 0)
s.append("+Ctrl");
if ((modifiers & ALT_MASK) != 0)
s.append("+Alt");
if ((modifiers & SHIFT_MASK) != 0)
s.append("+Shift");
if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0)
s.append("+Alt Graph");
if ((modifiers & InputEvent.BUTTON1_MASK) != 0)
s.append("+Button1");
s.setCharAt(len, '=');
return s.toString();
}
}
} // class ActionEvent
+51 -13
View File
@@ -1,21 +1,59 @@
/* Copyright (C) 1999 Free Software Foundation
/* ActionListener.java -- listens for action events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Per Bothner <bothner@cygnus.com>
* @date Fenruary, 1999.
* This interface is for classes that listen for action events.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ActionEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public interface ActionListener extends java.util.EventListener
public interface ActionListener extends EventListener
{
public void actionPerformed (ActionEvent e);
}
/**
* This method is invoked when an action occurs.
*
* @param event the <code>ActionEvent</code> that occurred
*/
void actionPerformed(ActionEvent e);
} // interface ActionListener
+194 -67
View File
@@ -1,95 +1,222 @@
/* Copyright (C) 2000 Free Software Foundation
/* AdjustmentEvent.java -- an adjustable value was changed
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.Adjustable;
import java.awt.AWTEvent;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class represents an event that is generated when an adjustable
* value is changed.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see Adjustable
* @see AdjustmentListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public class AdjustmentEvent extends AWTEvent
{
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = 5700290645205279921L;
/** This is the first id in the range of ids used by adjustment events. */
public static final int ADJUSTMENT_FIRST = 601;
/** This is the last id in the range of ids used by adjustment events. */
public static final int ADJUSTMENT_LAST = 601;
/** This is the id indicating an adjustment value changed. */
public static final int ADJUSTMENT_VALUE_CHANGED = 601;
public static final int BLOCK_DECREMENT = 3;
public static final int BLOCK_INCREMENT = 4;
public static final int TRACK = 5;
public static final int UNIT_DECREMENT = 2;
/** Adjustment type for unit increments. */
public static final int UNIT_INCREMENT = 1;
public AdjustmentEvent (Adjustable source, int id, int type, int value)
/** Adjustment type for unit decrements. */
public static final int UNIT_DECREMENT = 2;
/** Adjustment type for block decrements. */
public static final int BLOCK_DECREMENT = 3;
/** Adjustment type for block increments. */
public static final int BLOCK_INCREMENT = 4;
/** Adjustment type for tracking adjustments. */
public static final int TRACK = 5;
/**
* The adjustable object that caused the event.
*
* @see #getAdjustable()
* @serial the cause
*/
private final Adjustable adjustable;
/**
* The type of adjustment, one of {@link #UNIT_INCREMENT},
* {@link #UNIT_DECREMENT}, {@link #BLOCK_INCREMENT},
* {@link #BLOCK_DECREMENT}, or {@link #TRACK}.
*
* @see #getAdjustmentType()
* @serial the adjustment type
*/
private final int adjustmentType;
/**
* The new value of the adjustable; it should be in the range of the
* adjustable cause.
*
* @see #getValue()
* @serial the adjustment value
*/
private final int value;
/**
* True if this is in a series of multiple adjustment events.
*
* @see #getValueIsAdjusting()
* @serial true if this is not the last adjustment
* @since 1.4
*/
private final boolean isAdjusting;
/**
* Initializes an instance of <code>AdjustmentEvent</code> with the
* specified source, id, type, and value. Note that an invalid id leads to
* unspecified results.
*
* @param source the source of the event
* @param id the event id
* @param type the event type, one of the constants of this class
* @param value the value of the adjustment
* @throws IllegalArgumentException if source is null
*/
public AdjustmentEvent(Adjustable source, int id, int type, int value)
{
super (source, id);
this.adjType = type;
this(source, id, type, value, false);
}
/**
* Initializes an instance of <code>AdjustmentEvent</code> with the
* specified source, id, type, and value. Note that an invalid id leads to
* unspecified results.
*
* @param source the source of the event
* @param id the event id
* @param type the event type, one of the constants of this class
* @param value the value of the adjustment
* @param isAdjusting if this event is in a chain of adjustments
* @throws IllegalArgumentException if source is null
* @since 1.4
*/
public AdjustmentEvent(Adjustable source, int id, int type, int value,
boolean isAdjusting)
{
super(source, id);
this.adjustmentType = type;
this.value = value;
adjustable = source;
this.isAdjusting = isAdjusting;
}
public Adjustable getAdjustable ()
/**
* This method returns the source of the event as an <code>Adjustable</code>.
*
* @return the <code>Adjustable</code> source of the event
*/
public Adjustable getAdjustable()
{
return (Adjustable) source;
return adjustable;
}
public int getAdjustmentType ()
{
return adjType;
}
public int getValue ()
/**
* Returns the new value of the adjustable object.
*
* @return the value of the event
*/
public int getValue()
{
return value;
}
public String paramString ()
/**
* Returns the type of the event, which will be one of
* {@link #UNIT_INCREMENT}, {@link #UNIT_DECREMENT},
* {@link #BLOCK_INCREMENT}, {@link #BLOCK_DECREMENT}, or {@link #TRACK}.
*
* @return the type of the event
*/
public int getAdjustmentType()
{
String r;
switch (id)
{
case ADJUSTMENT_VALUE_CHANGED:
r = "ADJUSTMENT_VALUE_CHANGED";
break;
default:
r = "unknown id";
break;
}
r += ",adjType=";
switch (adjType)
{
case BLOCK_DECREMENT:
r += "BLOCK_DECREMENT";
break;
case BLOCK_INCREMENT:
r += "BLOCK_INCREMENT";
break;
case TRACK:
r += "TRACK";
break;
case UNIT_DECREMENT:
r += "UNIT_DECREMENT";
break;
case UNIT_INCREMENT:
r += "UNIT_INCREMENT";
break;
default:
r += "unknown type";
break;
}
r += ",value=" + value;
return r;
return adjustmentType;
}
private int adjType;
private int value;
}
/**
* Test if this event is part of a sequence of multiple adjustements.
*
* @return true if this is not the last adjustment
* @since 1.4
*/
public boolean getValueIsAdjusting()
{
return isAdjusting;
}
/**
* Returns a string that describes the event. This is in the format
* <code>"ADJUSTMENT_VALUE_CHANGED,adjType=" + &lt;type&gt; + ",value="
* + getValue() + ",isAdjusting=" + getValueIsAdjusting()</code>, where
* type is the name of the constant returned by getAdjustmentType().
*
* @return a string that describes the event
*/
public String paramString()
{
return (id == ADJUSTMENT_VALUE_CHANGED
? "ADJUSTMENT_VALUE_CHANGED,adjType=" : "unknown type,adjType=")
+ (adjustmentType == UNIT_INCREMENT ? "UNIT_INCREMENT,value="
: adjustmentType == UNIT_DECREMENT ? "UNIT_DECREMENT,value="
: adjustmentType == BLOCK_INCREMENT ? "BLOCK_INCREMENT,value="
: adjustmentType == BLOCK_DECREMENT ? "BLOCK_DECREMENT,value="
: adjustmentType == TRACK ? "TRACK,value=" : "unknown type,value=")
+ value + ",isAdjusting=" + isAdjusting;
}
} // class AdjustmentEvent
+50 -13
View File
@@ -1,21 +1,58 @@
/* Copyright (C) 2000 Free Software Foundation
/* AdjustmentListener.java -- listen for adjustment events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* Interface for classes that listen for adjustment events.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface AdjustmentListener extends java.util.EventListener
public interface AdjustmentListener extends EventListener
{
public void adjustmentValueChanged (AdjustmentEvent e);
}
/**
* This method is called when an adjustable value changes.
*
* @param event the <code>AdjustmentEvent</code> that occurred
*/
void adjustmentValueChanged(AdjustmentEvent event);
} // interface AdjustmentListener
+77 -15
View File
@@ -1,35 +1,97 @@
/* Copyright (C) 2000 Free Software Foundation
/* ComponentAdapter.java -- convenience class for writing component listeners
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class implements <code>ComponentListener</code> and implements
* all methods with empty bodies. This allows a listener interested in
* implementing only a subset of the <code>ComponentListener</code>
* interface to extend this class and override only the desired methods.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ComponentEvent
* @see ComponentListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public abstract class ComponentAdapter implements ComponentListener
{
public void componentHidden (ComponentEvent e)
/**
* Do nothing default constructor for subclasses.
*/
public ComponentAdapter()
{
}
public void componentMoved (ComponentEvent e)
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void componentResized(ComponentEvent event)
{
}
public void componentResized (ComponentEvent e)
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void componentMoved(ComponentEvent event)
{
}
public void componentShown (ComponentEvent e)
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void componentShown(ComponentEvent event)
{
}
}
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void componentHidden(ComponentEvent event)
{
}
} // class ComponentAdapter
+111 -35
View File
@@ -1,61 +1,137 @@
/* Copyright (C) 1999, 2000 Free Software Foundation
/* ComponentEvent.java -- notification of events for components
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.AWTEvent;
import java.awt.Component;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class is for events generated when a component is moved, resized,
* hidden, or shown. These events normally do not need to be handled by the
* application, since the AWT system automatically takes care of them. This
* is also the superclass for other events on components, but
* ComponentListeners ignore such subclasses.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ComponentAdapter
* @see ComponentListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public class ComponentEvent extends AWTEvent
{
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = 8101406823902992965L;
/** This is the first id in the range of ids used by this class. */
public static final int COMPONENT_FIRST = 100;
public static final int COMPONENT_HIDDEN = 103;
/** This is the last id in the range of ids used by this class. */
public static final int COMPONENT_LAST = 103;
/** This id indicates that a component was moved. */
public static final int COMPONENT_MOVED = 100;
/** This id indicates that a component was resized. */
public static final int COMPONENT_RESIZED = 101;
/** This id indicates that a component was shown. */
public static final int COMPONENT_SHOWN = 102;
public ComponentEvent (Component source, int id)
/** This id indicates that a component was hidden. */
public static final int COMPONENT_HIDDEN = 103;
/**
* Initializes a new instance of <code>ComponentEvent</code> with the
* specified source and id. Note that an invalid id leads to unspecified
* results.
*
* @param source the source of the event
* @param id the event id
* @throws IllegalArgumentException if source is null
*/
public ComponentEvent(Component source, int id)
{
super(source, id);
}
public Component getComponent ()
/**
* This method returns the event source as a <code>Component</code>. If the
* source has subsequently been modified to a non-Component, this returns
* null.
*
* @return the event source as a <code>Component</code>, or null
*/
public Component getComponent()
{
return (Component) source;
return source instanceof Component ? (Component) source : null;
}
public String paramString ()
/**
* This method returns a string identifying this event. This is the field
* name of the id type, and for COMPONENT_MOVED or COMPONENT_RESIZED, the
* new bounding box of the component.
*
* @return a string identifying this event
*/
public String paramString()
{
String r;
// Unlike Sun, we don't throw NullPointerException or ClassCastException
// when source was illegally changed.
switch (id)
{
case COMPONENT_HIDDEN:
r = "COMPONENT_HIDDEN";
break;
case COMPONENT_MOVED:
r = "COMPONENT_MOVED";
break;
case COMPONENT_RESIZED:
r = "COMPONENT_RESIZED";
break;
case COMPONENT_SHOWN:
r = "COMPONENT_SHOWN";
break;
default:
r = "unknown id";
break;
}
return r;
case COMPONENT_MOVED:
return "COMPONENT_MOVED "
+ (source instanceof Component
? ((Component) source).getBounds() : (Object) "");
case COMPONENT_RESIZED:
return "COMPONENT_RESIZED "
+ (source instanceof Component
? ((Component) source).getBounds() : (Object) "");
case COMPONENT_SHOWN:
return "COMPONENT_SHOWN";
case COMPONENT_HIDDEN:
return "COMPONENT_HIDDEN";
default:
return "unknown type";
}
}
}
} // class ComponentEvent
+76 -16
View File
@@ -1,24 +1,84 @@
/* Copyright (C) 2000 Free Software Foundation
/* ComponentListener.java -- receive all events for a component
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This interface is for classes that receive all events from a component.
* Normally it is not necessary to process these events since the AWT
* handles them internally, taking all appropriate actions. To watch a subset
* of these events, use a ComponentAdapter.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ComponentAdapter
* @see ComponentEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface ComponentListener extends java.util.EventListener
public interface ComponentListener extends EventListener
{
public void componentHidden (ComponentEvent e);
public void componentMoved (ComponentEvent e);
public void componentResized (ComponentEvent e);
public void componentShown (ComponentEvent e);
}
/**
* This method is called when the component is resized.
*
* @param event the <code>ComponentEvent</code> indicating the resize
*/
void componentResized(ComponentEvent event);
/**
* This method is called when the component is moved.
*
* @param event the <code>ComponentEvent</code> indicating the move
*/
void componentMoved(ComponentEvent event);
/**
* This method is called when the component is made visible.
*
* @param event the <code>ComponentEvent</code> indicating the visibility
*/
void componentShown(ComponentEvent event);
/**
* This method is called when the component is hidden.
*
* @param event the <code>ComponentEvent</code> indicating the visibility
*/
void componentHidden(ComponentEvent event);
} // interface ComponentListener
+65 -13
View File
@@ -1,27 +1,79 @@
/* Copyright (C) 2000 Free Software Foundation
/* ContainerAdapter.java -- convenience class for writing container listeners
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class implements <code>ContainerListener</code> and implements
* all methods with empty bodies. This allows a listener interested in
* implementing only a subset of the <code>ContainerListener</code>
* interface to extend this class and override only the desired methods.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ContainerEvent
* @see ContainerListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public abstract class ContainerAdapter implements ContainerListener
{
public void componentAdded (ContainerEvent e)
/**
* Do nothing default constructor for subclasses.
*/
public ContainerAdapter()
{
}
public void componentRemoved (ContainerEvent e)
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void componentAdded(ContainerEvent event)
{
}
}
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void componentRemoved(ContainerEvent event)
{
}
} // class ContainerAdapter
+112 -41
View File
@@ -1,64 +1,135 @@
/* Copyright (C) 2000, 2001 Free Software Foundation
/* ContainerEvent.java -- components added/removed from a container
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.Component;
import java.awt.Container;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This event is generated when a component is added or removed from a
* container. Applications do not ordinarily need to handle these events
* since the AWT system handles them internally.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ContainerAdapter
* @see ContainerListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public class ContainerEvent extends ComponentEvent
{
public static final int COMPONENT_ADDED = 300;
public static final int COMPONENT_REMOVED = 301;
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -4114942250539772041L;
/** This is the first id in the id range used by this class. */
public static final int CONTAINER_FIRST = 300;
/** This is the last id in the id range used by this class. */
public static final int CONTAINER_LAST = 301;
/** @specnote In JDK1.2 and 1.3, source is a Component. */
public ContainerEvent (Component source, int id, Component child)
/** This id indicates a component was added to the container. */
public static final int COMPONENT_ADDED = 300;
/** This id indicates a component was removed from the container. */
public static final int COMPONENT_REMOVED = 301;
/**
* The non-null child component that was added or removed.
*
* @serial the child component that changed
*/
private final Component child;
/**
* Initializes a new instance of <code>ContainerEvent</code> with the
* specified source and id. Additionally, the affected child component
* is also passed as a parameter. Note that an invalid id leads to
* unspecified results.
*
* @param source the source container of the event
* @param id the event id
* @param child the child component affected by this event
* @throws IllegalArgumentException if source is null
*/
public ContainerEvent(Component source, int id, Component child)
{
super (source, id);
super(source, id);
this.child = child;
}
public Component getChild ()
{
return child;
}
public Container getContainer ()
/**
* Returns the source of this event as a <code>Container</code>.
*
* @return the source of the event
* @throws ClassCastException if the source is changed to a non-Container
*/
public Container getContainer()
{
return (Container) source;
}
public String paramString ()
/**
* This method returns the child object that was added or removed from
* the container.
*
* @return the child object added or removed
*/
public Component getChild()
{
String r;
switch (id)
{
case COMPONENT_ADDED:
r = "COMPONENT_ADDED";
break;
case COMPONENT_REMOVED:
r = "COMPONENT_REMOVED";
break;
default:
r = "unknown id";
break;
}
r += ",child=" + child;
return r;
return child;
}
private Component child;
}
/**
* This method returns a string identifying this event. It is formatted as:
* <code>(getID() == COMPONENT_ADDED ? "COMPONENT_ADDED"
* : "COMPONENT_REMOVED") + ",child=" + getChild().getName()</code>.
*
* @return a string identifying this event
*/
public String paramString()
{
// Unlike Sun, we don't throw NullPointerException if child is illegally
// null.
return (id == COMPONENT_ADDED ? "COMPONENT_ADDED,child="
: id == COMPONENT_REMOVED ? "COMPONENT_REMOVED,child="
: "unknown type,child=") + (child == null ? "" : child.getName());
}
} // class ContainerEvent
+62 -14
View File
@@ -1,22 +1,70 @@
/* Copyright (C) 2000 Free Software Foundation
/* ContainerListener.java -- listen for container events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This interface is for classes that wish to listen for all events from
* container objects. This is normally not necessary since the AWT system
* listens for and processes these events. To watch a subset of these events,
* use a ContainerAdapter.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ContainerAdapter
* @see ContainerEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface ContainerListener extends java.util.EventListener
public interface ContainerListener extends EventListener
{
public void componentAdded (ContainerEvent e);
public void componentRemoved (ContainerEvent e);
}
/**
* This method is called when a component is added to the container.
*
* @param event the <code>ContainerEvent</code> indicating component addition
*/
void componentAdded(ContainerEvent event);
/**
* This method is called when a component is removed from the container.
*
* @param event the <code>ContainerEvent</code> indicating component removal
*/
void componentRemoved(ContainerEvent event);
} // interface ContainerListener
+65 -13
View File
@@ -1,27 +1,79 @@
/* Copyright (C) 2000 Free Software Foundation
/* FocusAdapter.java -- convenience class for writing focus listeners
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class implements <code>FocusListener</code> and implements all
* methods with empty bodies. This allows a listener interested in
* implementing only a subset of the <code>FocusListener</code> interface to
* extend this class and override only the desired methods.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see FocusEvent
* @see FocusListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public abstract class FocusAdapter implements FocusListener
{
public void focusGained (FocusEvent e)
/**
* Do nothing default constructor for subclasses.
*/
public FocusAdapter()
{
}
public void focusLost (FocusEvent e)
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void focusGained(FocusEvent event)
{
}
}
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void focusLost(FocusEvent event)
{
}
} // class FocusAdapter
+156 -38
View File
@@ -1,63 +1,181 @@
/* Copyright (C) 2000 Free Software Foundation
/* FocusEvent.java -- generated for a focus change
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.Component;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class represents an event generated when a focus change occurs for a
* component. There are both temporary changes, such as when focus is stolen
* during a sroll then returned, and permanent changes, such as when the user
* TABs through focusable components.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see FocusAdapter
* @see FocusListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public class FocusEvent extends ComponentEvent
{
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = 523753786457416396L;
/** This is the first id in the range of ids used by this class. */
public static final int FOCUS_FIRST = 1004;
public static final int FOCUS_GAINED = 1004;
/** This is the last id in the range of ids used by this class. */
public static final int FOCUS_LAST = 1005;
/** This is the event id for a focus gained event. */
public static final int FOCUS_GAINED = 1004;
/** This is the event id for a focus lost event. */
public static final int FOCUS_LOST = 1005;
public FocusEvent (Component source, int id)
{
super (source, id);
this.temporary = false;
}
/**
* Indicates whether or not the focus change is temporary.
*
* @see #isTemporary()
* @serial true if the focus change is temporary
*/
private final boolean temporary;
public FocusEvent (Component source, int id, boolean temporary)
/**
* The other component which is giving up or stealing focus from this
* component, if known.
*
* @see #getOppositeComponent()
* @serial the component with the opposite focus event, or null
* @since 1.4
*/
private final Component opposite;
/**
* Initializes a new instance of <code>FocusEvent</code> with the
* specified source, id, temporary status, and opposite counterpart. Note
* that an invalid id leads to unspecified results.
*
* @param source the component that is gaining or losing focus
* @param id the event id
* @param temporary true if the focus change is temporary
* @param opposite the component receiving the opposite focus event, or null
* @throws IllegalArgumentException if source is null
*/
public FocusEvent(Component source, int id, boolean temporary,
Component opposite)
{
super (source, id);
super(source, id);
this.temporary = temporary;
this.opposite = opposite;
}
public boolean isTemporary ()
/**
* Initializes a new instance of <code>FocusEvent</code> with the
* specified source, id, and temporary status. Note that an invalid id
* leads to unspecified results.
*
* @param source the component that is gaining or losing focus
* @param id the event id
* @param temporary true if the focus change is temporary
* @throws IllegalArgumentException if source is null
*/
public FocusEvent(Component source, int id, boolean temporary)
{
this(source, id, temporary, null);
}
/**
* Initializes a new instance of <code>FocusEvent</code> with the
* specified source and id. Note that an invalid id leads to unspecified
* results.
*
* @param source the component that is gaining or losing focus
* @param id the event id
* @throws IllegalArgumentException if source is null
*/
public FocusEvent(Component source, int id)
{
this(source, id, false, null);
}
/**
* This method tests whether or not the focus change is temporary or
* permanent.
*
* @return true if the focus change is temporary
*/
public boolean isTemporary()
{
return temporary;
}
public String paramString ()
/**
* Returns the component which received the opposite focus event. If this
* component gained focus, the opposite lost focus; likewise if this
* component is giving up focus, the opposite is gaining it. If this
* information is unknown, perhaps because the opposite is a native
* application, this returns null.
*
* @return the component with the focus opposite, or null
* @since 1.4
*/
public Component getOppositeComponent()
{
String r = "";
switch (id)
{
case FOCUS_GAINED:
r += "FOCUS_GAINED";
break;
case FOCUS_LOST:
r += "FOCUS_LOST";
break;
default:
r += "unknown id";
break;
}
r += (temporary ? "temporary" : "permanent");
return r;
return opposite;
}
private boolean temporary;
}
/**
* Returns a string identifying this event. This is formatted as:
* <code>(getID() == FOCUS_GAINED ? "FOCUS_GAINED" : "FOCUS_LOST")
* + (isTemporary() ? ",temporary," : ",permanent,") + "opposite="
* + getOppositeComponent()</code>.
*
* @return a string identifying this event
*/
public String paramString()
{
return (id == FOCUS_GAINED ? "FOCUS_GAINED"
: id == FOCUS_LOST ? "FOCUS_LOST" : "unknown type")
+ (temporary ? ",temporary,opposite=" : ",permanent,opposite=")
+ opposite;
}
} // class FocusEvent
+61 -14
View File
@@ -1,22 +1,69 @@
/* Copyright (C) 2000 Free Software Foundation
/* FocusListener.java -- listen for focus changes
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This interface is for classes that wish to be notified of changes of
* keyboard focus for a component. To watch a subset of these events, use a
* FocusAdapter.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see FocusAdapter
* @see FocusEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface FocusListener extends java.util.EventListener
public interface FocusListener extends EventListener
{
public void focusGained (FocusEvent e);
public void focusLost (FocusEvent e);
}
/**
* This method is called when a component gains the keyboard focus.
*
* @param event the <code>FocusEvent</code> indicating that focus was gained
*/
void focusGained(FocusEvent event);
/**
* This method is invoked when a component loses the keyboard focus.
*
* @param event the <code>FocusEvent</code> indicating that focus was lost
*/
void focusLost(FocusEvent event);
} // interface FocusListener
@@ -1,4 +1,5 @@
/* Copyright (C) 2000, 2002 Free Software Foundation
/* HierarchyBoundsAdapter.java -- convenience class for writing listeners
Copyright (C) 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
@@ -37,19 +38,41 @@ exception statement from your version. */
package java.awt.event;
/**
* @since 1.3
* This class implements <code>HierarchyBoundsListener</code> and implements
* all methods with empty bodies. This allows a listener interested in
* implementing only a subset of the <code>HierarchyBoundsListener</code>
* interface to extend this class and override only the desired methods.
*
* @author Bryce McKinlay
* @see HierarchyBoundsListener
* @see HierarchyEvent
* @since 1.3
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public abstract class HierarchyBoundsAdapter implements HierarchyBoundsListener
{
/**
* Do nothing default constructor for subclasses.
*/
public HierarchyBoundsAdapter()
{
}
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void ancestorMoved(HierarchyEvent e)
{
}
/**
* Implements this method from the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void ancestorResized(HierarchyEvent e)
{
}
}
} // class HierarchyBoundsAdapter
@@ -1,4 +1,5 @@
/* Copyright (C) 2000, 2002 Free Software Foundation
/* HierarchyBoundsListener.java -- listens to bounds changes of parents
Copyright (C) 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
@@ -34,17 +35,36 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.event;
import java.util.EventListener;
/**
* @since 1.3
* This listens for changes in an ancestors size or location. Normally it is
* not necessary to process these events since the AWT handles them
* internally, taking all appropriate actions. To watch a subset of these
* events, use a HierarchyBoundsAdapter.
*
* @author Bryce McKinlay
* @see HierarchyBoundsAdapter
* @see HierarchyEvent
* @since 1.3
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public interface HierarchyBoundsListener extends java.util.EventListener
public interface HierarchyBoundsListener extends EventListener
{
public void ancestorMoved(HierarchyEvent e);
public void ancestorResized(HierarchyEvent e);
}
/**
* Called when an ancestor component of the source is moved.
*
* @param e the event describing the ancestor's motion
*/
void ancestorMoved(HierarchyEvent e);
/**
* Called when an ancestor component is resized.
*
* @param e the event describing the ancestor's resizing
*/
void ancestorResized(HierarchyEvent e);
} // interface HierarchyBoundsListener
+178 -53
View File
@@ -1,4 +1,5 @@
/* Copyright (C) 2000, 2002 Free Software Foundation
/* HierarchyEvent.java -- generated for a change in hierarchy
Copyright (C) 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
@@ -38,87 +39,211 @@ package java.awt.event;
import java.awt.*;
/**
* @since 1.3
* This class represents an event generated for an ancestor component which
* may affect this component. These events normally do not need to be handled
* by the application, since the AWT system automatically takes care of them.
*
* <p>There are two types of hierarchy events. The first type is handled by
* HierarchyListener, and includes addition or removal of an ancestor, or
* an ancestor changing its on-screen status (visible and/or displayble). The
* second type is handled by HierarchyBoundsListener, and includes resizing
* or moving of an ancestor.
*
* @author Bryce McKinlay
* @see HierarchyListener
* @see HierarchyBoundsAdapter
* @see HierarchyBoundsListener
* @since 1.3
* @status updated to 1.4
*/
/* Status: thought to be complete and correct. */
public class HierarchyEvent extends AWTEvent
{
public static final int PARENT_CHANGED = 1 << 0,
DISPLAYABILITY_CHANGED = 1 << 1,
SHOWING_CHANGED = 1 << 2,
HIERARCHY_FIRST = 1400,
HIERARCHY_CHANGED = 1400,
ANCESTOR_MOVED = 1401,
ANCESTOR_RESIZED = 1402,
HIERARCHY_LAST = 1402;
/* Serialized fields from the serialization spec. */
Component changed;
Container changedParent;
long changeFlags = 0;
/**
* Compatible with JDK 1.3+.
*/
private static final long serialVersionUID = -5337576970038043990L;
/** This is the first id in the range of ids used by this class. */
public static final int HIERARCHY_FIRST = 1400;
/** This id indicates that the hierarchy tree changed. */
public static final int HIERARCHY_CHANGED = 1400;
/** This id indicates that an ancestor was moved. */
public static final int ANCESTOR_MOVED = 1401;
/** This id indicates that an ancestor was resized. */
public static final int ANCESTOR_RESIZED = 1402;
/** This is the last id in the range of ids used by this class. */
public static final int HIERARCHY_LAST = 1402;
/** This indicates that the HIERARCHY_CHANGED is a changed parent. */
public static final int PARENT_CHANGED = 1;
/**
* This indicates that the HIERARCHY_CHANGED is caused by a change in
* displayability.
*
* @see Component#isDisplayable()
* @see Component#addNotify()
* @see Component#removeNotify()
*/
public static final int DISPLAYABILITY_CHANGED = 2;
/**
* This indicates that the HIERARCHY_CHANGED is a changed visibility.
*
* @see Component#isShowing()
* @see Component#addNotify()
* @see Component#removeNotify()
* @see Component#show()
* @see Component#hide()
*/
public static final int SHOWING_CHANGED = 4;
/**
* The component at the top of the changed hierarchy.
*
* @serial the top component changed
*/
private final Component changed;
/**
* The parent of this component, either before or after the change depending
* on the type of change.
*
* @serial the parent component changed
*/
private final Container changedParent;
/**
* The bitmask of HIERARCHY_CHANGED event types.
*
* @serial the change flags
*/
private final long changeFlags;
/**
* Initializes a new instance of <code>HierarchyEvent</code> with the
* specified parameters. Note that an invalid id leads to unspecified
* results.
*
* @param source the component whose hierarchy changed
* @param id the event id
* @param changed the top component in the tree of changed hierarchy
* @param changedParent the updated parent of this object
* @throws IllegalArgumentException if source is null
*/
public HierarchyEvent(Component source, int id, Component changed,
Container changedParent)
Container changedParent)
{
this(source, id, changed, changedParent, 0);
}
/**
* Initializes a new instance of <code>HierarchyEvent</code> with the
* specified parameters. Note that an invalid id leads to unspecified
* results.
*
* @param source the component whose hierarchy changed
* @param id the event id
* @param changed the top component in the tree of changed hierarchy
* @param changedParent the updated parent of this object
* @param changeFlags the bitmask of specific HIERARCHY_CHANGED events
* @throws IllegalArgumentException if source is null
*/
public HierarchyEvent(Component source, int id, Component changed,
Container changedParent, long changeFlags)
{
super(source, id);
this.changed = changed;
this.changedParent = changedParent;
}
public HierarchyEvent(Component source, int id, Component changed,
Container changedParent, long changeFlags)
{
super(source,id);
this.changed = changed;
this.changedParent = changedParent;
this.changeFlags = changeFlags;
}
/**
* This method returns the event source as a <code>Component</code>. If the
* source has subsequently been modified to a non-Component, this returns
* null.
*
* @return the event source as a <code>Component</code>, or null
*/
public Component getComponent()
{
return (Component) source;
return source instanceof Component ? (Component) source : null;
}
/**
* Returns the component at the top of the hierarchy which changed.
*
* @return the top changed component
*/
public Component getChanged()
{
return changed;
}
/**
* Returns the parent of the component listed in <code>getChanged()</code>.
* If the cause of this event was <code>Container.add</code>, this is the
* new parent; if the cause was <code>Container.remove</code>, this is the
* old parent; otherwise it is the unchanged parent.
*
* @return the parent container of the changed component
*/
public Container getChangedParent()
{
return changedParent;
}
/**
* If this is a HIERARCHY_CHANGED event, this returns a bitmask of the
* types of changes that took place.
*
* @return the bitwise or of hierarchy change types, or 0
* @see #PARENT_CHANGED
* @see #DISPLAYABILITY_CHANGED
* @see #SHOWING_CHANGED
*/
public long getChangeFlags()
{
return changeFlags;
}
/**
* This method returns a string identifying this event. This is the field
* name of the id type, followed by a parenthesized listing of the changed
* component and its parent container. In addition, if the type is
* HIERARCHY_CHANGED, the flags preceed the changed component, in the
* order PARENT_CHANGED, DISPLAYABILITY_CHANGED, and SHOWING_CHANGED.
*
* @return a string identifying this event
*/
public String paramString()
{
String r;
StringBuffer r = new StringBuffer();
switch (id)
{
case HIERARCHY_CHANGED:
r = "HIERARCHY_CHANGED";
break;
case ANCESTOR_MOVED:
r = "ANCESTOR_MOVED";
break;
case ANCESTOR_RESIZED:
r = "ANCESTOR_RESIZED";
break;
default:
return "unknown type";
case HIERARCHY_CHANGED:
r.append("HIERARCHY_CHANGED (");
if ((changeFlags & PARENT_CHANGED) != 0)
r.append("PARENT_CHANGED,");
if ((changeFlags & DISPLAYABILITY_CHANGED) != 0)
r.append("DISPLAYABILITY_CHANGED,");
if ((changeFlags & SHOWING_CHANGED) != 0)
r.append("SHOWING_CHANGED,");
break;
case ANCESTOR_MOVED:
r.append("ANCESTOR_MOVED (");
break;
case ANCESTOR_RESIZED:
r.append("ANCESTOR_RESIZED (");
break;
default:
return "unknown type";
}
r += "(" + changed + "," + changedParent + ")";
return r;
r.append(changed).append(',').append(changedParent).append(')');
return r.toString();
}
}
} // class HierarchyEvent
+21 -8
View File
@@ -1,4 +1,5 @@
/* Copyright (C) 2000, 2002 Free Software Foundation
/* HierarchyListener.java -- listens to changes in the component hierarchy
Copyright (C) 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
@@ -34,16 +35,28 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.event;
import java.util.EventListener;
/**
* @since 1.3
* This listens for changes in the hierarchy tree of components. Normally it is
* not necessary to process these events since the AWT handles them
* internally, taking all appropriate actions.
*
* @author Bryce McKinlay
* @see HierarchyEvent
* @since 1.3
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public interface HierarchyListener extends java.util.EventListener
public interface HierarchyListener extends EventListener
{
public void hierarchyChanged(HierarchyEvent e);
}
/**
* Called when the hierarchy of this component changes. Use
* <code>getChangeFlags()</code> on the event to see what exactly changed.
*
* @param e the event describing the change
*/
void hierarchyChanged(HierarchyEvent e);
} // interface HierarchyListener
+336 -35
View File
@@ -1,78 +1,379 @@
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
/* InputEvent.java -- common superclass of component input events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
/* Status: Believed complete and correct to JDK 1.2. */
import java.awt.Component;
import gnu.java.awt.EventModifier;
/**
* This is the common superclass for all component input classes. These are
* passed to listeners before the component, so that listeners can consume
* the event before it does its default behavior.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see KeyEvent
* @see KeyAdapter
* @see MouseEvent
* @see MouseAdapter
* @see MouseMotionAdapter
* @see MouseWheelEvent
* @since 1.1
* @status updated to 1.4
*/
public abstract class InputEvent extends ComponentEvent
{
public static final int ALT_GRAPH_MASK = 32;
public static final int ALT_MASK = 8;
public static final int BUTTON1_MASK = 16;
public static final int BUTTON2_MASK = 8;
public static final int BUTTON3_MASK = 4;
public static final int CTRL_MASK = 2;
public static final int META_MASK = 4;
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -2482525981698309786L;
/**
* This is the bit mask which indicates the shift key is down. It is
* recommended that SHIFT_DOWN_MASK be used instead.
*
* @see #SHIFT_DOWN_MASK
*/
public static final int SHIFT_MASK = 1;
InputEvent (Component source, int id) // Not public
/**
* This is the bit mask which indicates the control key is down. It is
* recommended that CTRL_DOWN_MASK be used instead.
*
* @see #CTRL_DOWN_MASK
*/
public static final int CTRL_MASK = 2;
/**
* This is the bit mask which indicates the meta key is down. It is
* recommended that META_DOWN_MASK be used instead.
*
* @see #META_DOWN_MASK
*/
public static final int META_MASK = 4;
/**
* This is the bit mask which indicates the alt key is down. It is
* recommended that ALT_DOWN_MASK be used instead.
*
* @see #ALT_DOWN_MASK
*/
public static final int ALT_MASK = 8;
/**
* This is the bit mask which indicates the alt-graph modifier is in effect.
* It is recommended that ALT_GRAPH_DOWN_MASK be used instead.
*
* @see #ALT_GRAPH_DOWN_MASK
*/
public static final int ALT_GRAPH_MASK = 0x20;
/**
* This bit mask indicates mouse button one is down. It is recommended that
* BUTTON1_DOWN_MASK be used instead.
*
* @see #BUTTON1_DOWN_MASK
*/
public static final int BUTTON1_MASK = 0x10;
/**
* This bit mask indicates mouse button two is down. It is recommended that
* BUTTON2_DOWN_MASK be used instead.
*
* @see #BUTTON2_DOWN_MASK
*/
public static final int BUTTON2_MASK = 8;
/**
* This bit mask indicates mouse button three is down. It is recommended
* that BUTTON3_DOWN_MASK be used instead.
*
* @see #BUTTON3_DOWN_MASK
*/
public static final int BUTTON3_MASK = 4;
/**
* The SHIFT key extended modifier.
*
* @since 1.4
*/
public static final int SHIFT_DOWN_MASK = 0x0040;
/**
* The CTRL key extended modifier.
*
* @since 1.4
*/
public static final int CTRL_DOWN_MASK = 0x0080;
/**
* The META key extended modifier.
*
* @since 1.4
*/
public static final int META_DOWN_MASK = 0x0100;
/**
* The ALT key extended modifier.
*
* @since 1.4
*/
public static final int ALT_DOWN_MASK = 0x0200;
/**
* The mouse button1 key extended modifier.
*
* @since 1.4
*/
public static final int BUTTON1_DOWN_MASK = 0x0400;
/**
* The mouse button2 extended modifier.
*
* @since 1.4
*/
public static final int BUTTON2_DOWN_MASK = 0x0800;
/**
* The mouse button3 extended modifier.
*
* @since 1.4
*/
public static final int BUTTON3_DOWN_MASK = 0x1000;
/**
* The ALT_GRAPH key extended modifier.
*
* @since 1.4
*/
public static final int ALT_GRAPH_DOWN_MASK = 0x2000;
/** The mask to convert new to old, package visible for use in subclasses. */
static final int CONVERT_MASK
= EventModifier.NEW_MASK & ~(BUTTON2_DOWN_MASK | BUTTON3_DOWN_MASK);
/**
* The timestamp when this event occurred.
*
* @see #getWhen()
* @serial the timestamp
*/
private final long when;
/**
* The modifiers in effect for this event. Package visible for use by
* subclasses. The old style (bitmask 0x3f) should not be mixed with the
* new style (bitmasks 0xffffffc0).
*
* @see #getModifiers()
* @see MouseEvent
* @serial the modifier state, stored in the new style
*/
int modifiers;
/**
* Initializes a new instance of <code>InputEvent</code> with the specified
* source, id, timestamp, and modifiers. Note that an invalid id leads to
* unspecified results.
*
* @param source the source of the event
* @param id the event id
* @param when the timestamp when the event occurred
* @param modifiers the modifiers in effect for this event, old or new style
* @throws IllegalArgumentException if source is null
*/
InputEvent(Component source, int id, long when, int modifiers)
{
super(source, id);
this.when = when;
this.modifiers = EventModifier.extend(modifiers);
}
public boolean isShiftDown ()
/**
* This method tests whether or not the shift key was down during the event.
*
* @return true if the shift key is down
*/
public boolean isShiftDown()
{
return (modifiers & SHIFT_MASK) != 0;
return (modifiers & SHIFT_DOWN_MASK) != 0;
}
public boolean isControlDown ()
/**
* This method tests whether or not the control key was down during the
* event.
*
* @return true if the control key is down
*/
public boolean isControlDown()
{
return (modifiers & CTRL_MASK) != 0;
return (modifiers & CTRL_DOWN_MASK) != 0;
}
public boolean isMetaDown ()
/**
* This method tests whether or not the meta key was down during the event.
*
* @return true if the meta key is down
*/
public boolean isMetaDown()
{
return (modifiers & META_MASK) != 0;
return (modifiers & META_DOWN_MASK) != 0;
}
public boolean isAltDown ()
/**
* This method tests whether or not the alt key was down during the event.
*
* @return true if the alt key is down
*/
public boolean isAltDown()
{
return (modifiers & ALT_MASK) != 0;
return (modifiers & ALT_DOWN_MASK) != 0;
}
public boolean isAltGraphDown ()
/**
* This method tests whether or not the alt-graph modifier was in effect
* during the event.
*
* @return true if the alt-graph modifier is down
*/
public boolean isAltGraphDown()
{
return (modifiers & ALT_GRAPH_MASK) != 0;
return (modifiers & ALT_GRAPH_DOWN_MASK) != 0;
}
public long getWhen ()
/**
* This method returns the timestamp when this event occurred.
*
* @return the timestamp when this event occurred
*/
public long getWhen()
{
return when;
}
public int getModifiers ()
/**
* This method returns the old-style modifiers in effect for this event.
* Note that this is ambiguous between button2 and alt, and between
* button3 and meta. Also, code which generated these modifiers tends to
* only list the modifier that just changed, even if others were down at
* the time. Consider using getModifiersEx instead. This will be a union
* of the bit masks defined in this class that are applicable to the event.
*
* @return the modifiers in effect for this event
* @see #getModifiersEx()
*/
public int getModifiers()
{
return EventModifier.revert(modifiers);
}
/**
* Returns the extended modifiers (new-style) for this event. This represents
* the state of all modal keys and mouse buttons at the time of the event,
* and does not suffer from the problems mentioned in getModifiers.
*
* <p>For an example of checking multiple modifiers, this code will return
* true only if SHIFT and BUTTON1 were pressed and CTRL was not:
* <pre>
* int onmask = InputEvent.SHIFT_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK;
* int offmask = InputEvent.CTRL_DOWN_MASK;
* return (event.getModifiersEx() & (onmask | offmask)) == onmask;
* </pre>
*
* @return the bitwise or of all modifiers pressed during the event
* @since 1.4
*/
public int getModifiersEx()
{
return modifiers;
}
public boolean isConsumed ()
/**
* Consumes this event. A consumed event is not processed further by the AWT
* system.
*/
public void consume()
{
consumed = true;
}
/**
* This method tests whether or not this event has been consumed.
*
* @return true if this event has been consumed
*/
public boolean isConsumed()
{
return consumed;
}
public void consume ()
/**
* Convert the extended modifier bitmask into a String, such as "Shift" or
* "Ctrl+Button1".
*
* XXX Sun claims this can be localized via the awt.properties file - how
* do we implement that?
*
* @return a string representation of the modifiers in this bitmask
* @since 1.4
*/
public static String getModifiersExText(int modifiers)
{
/* FIXME */
consumed = true;
modifiers &= EventModifier.NEW_MASK;
if (modifiers == 0)
return "";
StringBuffer s = new StringBuffer();
if ((modifiers & META_DOWN_MASK) != 0)
s.append("Meta+");
if ((modifiers & CTRL_DOWN_MASK) != 0)
s.append("Ctrl+");
if ((modifiers & ALT_DOWN_MASK) != 0)
s.append("Alt+");
if ((modifiers & SHIFT_DOWN_MASK) != 0)
s.append("Shift+");
if ((modifiers & ALT_GRAPH_DOWN_MASK) != 0)
s.append("Alt Graph+");
if ((modifiers & BUTTON1_DOWN_MASK) != 0)
s.append("Button1+");
if ((modifiers & BUTTON2_DOWN_MASK) != 0)
s.append("Button2+");
if ((modifiers & BUTTON3_DOWN_MASK) != 0)
s.append("Button3+");
return s.substring(0, s.length() - 1);
}
long when;
int modifiers;
}
} // class InputEvent
+282 -47
View File
@@ -1,68 +1,303 @@
/* Copyright (C) 1999, 2000 Free Software Foundation
/* InputMethodEvent.java -- events from a text input method
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
/* A very incomplete placeholder. */
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.font.TextHitInfo;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.text.AttributedCharacterIterator;
/**
* This class is for event generated by change in a text input method.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see InputMethodListener
* @since 1.2
* @status updated to 1.4
*/
public class InputMethodEvent extends AWTEvent
{
public static final int CARET_POSITION_CHANGED = 1101;
/**
* Compatible with JDK 1.2+.
*/
private static final long serialVersionUID = 4727190874778922661L;
/** This is the first id in the range of event ids used by this class. */
public static final int INPUT_METHOD_FIRST = 1100;
public static final int INPUT_METHOD_LAST = 1101;
/** This event id indicates that the text in the input method has changed. */
public static final int INPUT_METHOD_TEXT_CHANGED = 1100;
/*
public InputMethodEvent (Component source, int id,
AttributedCharacterIterator text,
int committedCharacterCount, TextHitInfo caret,
TextHitInfo visiblePosition)
/** This event id indicates that the input method curor point has changed. */
public static final int CARET_POSITION_CHANGED = 1101;
/** This is the last id in the range of event ids used by this class. */
public static final int INPUT_METHOD_LAST = 1101;
/**
* The timestamp when this event was created.
*
* @serial the timestamp
* @since 1.4
*/
private long when;
/** The input method text. */
private final transient AttributedCharacterIterator text;
/** The number of committed characters in the text. */
private final transient int committedCharacterCount;
/** The caret. */
private final transient TextHitInfo caret;
/** The most important position to be visible. */
private final transient TextHitInfo visiblePosition;
/**
* Initializes a new instance of <code>InputMethodEvent</code> with the
* specified source, id, timestamp, text, char count, caret, and visible
* position.
*
* @param source the source that generated the event
* @param id the event id
* @param when the timestamp of the event
* @param text the input text
* @param committedCharacterCount the number of committed characters
* @param caret the caret position
* @param visiblePosition the position most important to make visible
* @throws IllegalArgumentException if source is null, id is invalid, id is
* CARET_POSITION_CHANGED and text is non-null, or if
* committedCharacterCount is out of range
* @since 1.4
*/
public InputMethodEvent(Component source, int id, long when,
AttributedCharacterIterator text,
int committedCharacterCount, TextHitInfo caret,
TextHitInfo visiblePosition)
{
if (id < INPUT_METHOD_FIRST
|| id > INPUT_METHOD_LAST
|| (id == CARET_POSITION_CHANGED && text != null)
|| committedCharacterCount < 0
|| (committedCharacterCount
> text.getEndIndex () - text.getBeginIndex ()))
throw new IllegalArgumentException ();
super(source, id);
this.when = when;
this.text = text;
this.committedCharacterCount = committedCharacterCount;
this.caret = caret;
this.visiblePosition = visiblePosition;
if (id < INPUT_METHOD_FIRST || id > INPUT_METHOD_LAST
|| (id == CARET_POSITION_CHANGED && text != null)
|| committedCharacterCount < 0
|| (committedCharacterCount
> (text == null ? 0 : text.getEndIndex() - text.getBeginIndex())))
throw new IllegalArgumentException();
}
public InputMethodEvent (Component source, int id, TextHitInfo caret,
TextHitInfo visiblePosition);
public void consume ();
public TextHitInfo getCaret ();
public int getCommittedCharacterCount ();
public AttributedCharacterIterator getText ();
public TextHitInfo getVisiblePosition ();
public boolean isConsumed ();
public String paramString ()
/**
* Initializes a new instance of <code>InputMethodEvent</code> with the
* specified source, id, text, char count, caret, and visible position.
*
* @param source the source that generated the event
* @param id the event id
* @param text the input text
* @param committedCharacterCount the number of committed characters
* @param caret the caret position
* @param visiblePosition the position most important to make visible
* @throws IllegalArgumentException if source is null, id is invalid, id is
* CARET_POSITION_CHANGED and text is non-null, or if
* committedCharacterCount is out of range
* @since 1.4
*/
public InputMethodEvent(Component source, int id,
AttributedCharacterIterator text,
int committedCharacterCount, TextHitInfo caret,
TextHitInfo visiblePosition)
{
String r;
switch (id)
this(source, id, EventQueue.getMostRecentEventTime(), text,
committedCharacterCount, caret, visiblePosition);
}
/**
* Initializes a new instance of <code>InputMethodEvent</code> with the
* specified source, id, caret, and visible position, and with a null
* text and char count.
*
* @param source the source that generated the event
* @param id the event id
* @param caret the caret position
* @param visiblePosition the position most important to make visible
* @throws IllegalArgumentException if source is null or id is invalid
* @since 1.4
*/
public InputMethodEvent(Component source, int id, TextHitInfo caret,
TextHitInfo visiblePosition)
{
this(source, id, EventQueue.getMostRecentEventTime(), null, 0, caret,
visiblePosition);
}
/**
* This method returns the input method text. This can be <code>null</code>,
* and will always be null for <code>CARET_POSITION_CHANGED</code> events.
* Characters from 0 to <code>getCommittedCharacterCount()-1</code> have
* been committed, the remaining characters are composed text.
*
* @return the input method text, or null
*/
public AttributedCharacterIterator getText()
{
return text;
}
/**
* Returns the number of committed characters in the input method text.
*
* @return the number of committed characters in the input method text
*/
public int getCommittedCharacterCount()
{
return committedCharacterCount;
}
/**
* Returns the caret position. The caret offset is relative to the composed
* text of the most recent <code>INPUT_METHOD_TEXT_CHANGED</code> event.
*
* @return the caret position, or null
*/
public TextHitInfo getCaret()
{
return caret;
}
/**
* Returns the position that is most important to be visible, or null if
* such a hint is not necessary. The caret offset is relative to the composed
* text of the most recent <code>INPUT_METHOD_TEXT_CHANGED</code> event.
*
* @return the position that is most important to be visible
*/
public TextHitInfo getVisiblePosition()
{
return visiblePosition;
}
/**
* This method consumes the event. A consumed event is not processed
* in the default manner by the component that generated it.
*/
public void consume()
{
consumed = true;
}
/**
* This method tests whether or not this event has been consumed.
*
* @return true if the event has been consumed
*/
public boolean isConsumed()
{
return consumed;
}
/**
* Return the timestamp of this event.
*
* @return the timestamp
* @since 1.4
*/
public long getWhen()
{
return when;
}
/**
* This method returns a string identifying the event. This contains the
* event ID, the committed and composed characters separated by '+', the
* number of committed characters, the caret, and the visible position.
*
* @return a string identifying the event
*/
public String paramString()
{
StringBuffer s
= new StringBuffer(80 + (text == null ? 0
: text.getEndIndex() - text.getBeginIndex()));
s.append(id == INPUT_METHOD_TEXT_CHANGED ? "INPUT_METHOD_TEXT_CHANGED, "
: "CARET_POSITION_CHANGED, ");
if (text == null)
s.append("no text, 0 characters committed, caret: ");
else
{
case CARET_POSITION_CHANGED:
r = "CARET_POSITION_CHANGED";
break;
case INPUT_METHOD_TEXT_CHANGED:
r = "INPUT_METHOD_TEXT_CHANGED";
break;
s.append('"');
int i = text.getBeginIndex();
int j = committedCharacterCount;
while (--j >= 0)
s.append(text.setIndex(i++));
s.append("\" + \"");
j = text.getEndIndex() - i;
while (--j >= 0)
s.append(text.setIndex(i++));
s.append("\", ").append(committedCharacterCount)
.append(" characters committed, caret: ");
}
r += ""; // FIXME
return r;
s.append(caret == null ? (Object) "no caret" : caret).append(", ")
.append(visiblePosition == null ? (Object) "no visible position"
: visiblePosition);
return s.toString();
}
*/
// FIXME: this is just to let it compile.
private InputMethodEvent ()
/**
* Reads in the object from a serial stream, updating when to
* {@link EventQueue#getMostRecentEventTime()} if necessary.
*
* @param s the stream to read from
* @throws IOException if deserialization fails
* @throws ClassNotFoundException if deserialization fails
* @serialData default, except for updating when
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
super (null, -1);
s.defaultReadObject();
if (when == 0)
when = EventQueue.getMostRecentEventTime();
}
}
} // class InputMethodEvent
+61 -14
View File
@@ -1,22 +1,69 @@
/* Copyright (C) 2000 Free Software Foundation
/* InputMethodListener.java -- listen for input method events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This interface is for classes that wish to receive events from an input
* method. For a text component to use input methods, it must also install
* an InputMethodRequests handler.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see InputMethodEvent
* @see InputMethodRequests
* @since 1.2
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface InputMethodListener extends java.util.EventListener
public interface InputMethodListener extends EventListener
{
public void caretPositionChanged (InputMethodEvent e);
public void inputMethodTextChanged (InputMethodEvent e);
}
/**
* This method is called when the text is changed.
*
* @param event the <code>InputMethodEvent</code> indicating the text change
*/
void inputMethodTextChanged(InputMethodEvent event);
/**
* This method is called when the cursor position within the text is changed.
*
* @param event the <code>InputMethodEvent</code> indicating the change
*/
void caretPositionChanged(InputMethodEvent event);
} // interface InputMethodListener
+196 -60
View File
@@ -1,96 +1,232 @@
/* Copyright (C) 2000 Free Software Foundation
/* InvocationEvent.java -- call a runnable when dispatched
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.ActiveEvent;
import java.awt.AWTEvent;
import java.awt.EventQueue;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This event executes {@link Runnable#run()} of a target object when it is
* dispatched. This class is used by calls to <code>invokeLater</code> and
* <code>invokeAndWait</code>, so client code can use this fact to avoid
* writing special-casing AWTEventListener objects.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ActiveEvent
* @see EventQueue#invokeLater(Runnable)
* @see EventQueue#invokeAndWait(Runnable)
* @see AWTEventListener
* @since 1.2
* @status updated to 1.4
*/
/* Status: Believed to be complete and correct. */
public class InvocationEvent extends AWTEvent implements ActiveEvent
{
public static final int INVOCATION_DEFAULT = 1200;
/**
* Compatible with JDK 1.2+.
*/
private static final long serialVersionUID = 436056344909459450L;
/** This is the first id in the range of event ids used by this class. */
public static final int INVOCATION_FIRST = 1200;
/** This is the default id for this event type. */
public static final int INVOCATION_DEFAULT = 1200;
/** This is the last id in the range of event ids used by this class. */
public static final int INVOCATION_LAST = 1200;
protected InvocationEvent (Object source, int id, Runnable runnable,
Object notifier, boolean catchExceptions)
/**
* This is the <code>Runnable</code> object to call when dispatched.
*
* @serial the runnable to execute
*/
protected Runnable runnable;
/**
* This is the object to call <code>notifyAll()</code> on when
* the call to <code>run()</code> returns, or <code>null</code> if no
* object is to be notified.
*
* @serial the object to notify
*/
protected Object notifier;
/**
* This variable is set to <code>true</code> if exceptions are caught
* and stored in a variable during the call to <code>run()</code>, otherwise
* exceptions are ignored and propagate up.
*
* @serial true to catch exceptions
*/
protected boolean catchExceptions;
/**
* This is the caught exception thrown in the <code>run()</code> method. It
* is null if exceptions are ignored, the run method hasn't completed, or
* there were no exceptions.
*
* @serial the caught exception, if any
*/
private Exception exception;
/**
* The timestamp when this event was created.
*
* @see #getWhen()
* @serial the timestamp
* @since 1.4
*/
private final long when = EventQueue.getMostRecentEventTime();
/**
* Initializes a new instance of <code>InvocationEvent</code> with the
* specified source and runnable.
*
* @param source the source of the event
* @param runnable the <code>Runnable</code> object to invoke
* @throws IllegalArgumentException if source is null
*/
public InvocationEvent(Object source, Runnable runnable)
{
super (source, id);
this.runnable = runnable;
this.notifier = notifier;
this.catchExceptions = catchExceptions;
}
public InvocationEvent (Object source, Runnable runnable)
{
super (source, INVOCATION_DEFAULT);
this.runnable = runnable;
this(source, INVOCATION_DEFAULT, runnable, null, false);
}
/**
* Initializes a new instance of <code>InvocationEvent</code> with the
* specified source, runnable, and notifier. It will also catch exceptions
* if specified. If notifier is non-null, this will call notifyAll() on
* the object when the runnable is complete. If catchExceptions is true,
* this traps any exception in the runnable, otherwise it lets the exception
* propagate up the Event Dispatch thread.
*
* @param source the source of the event
* @param runnable the <code>Runnable</code> object to invoke
* @param notifier the object to notify, or null
* @param catchExceptions true to catch exceptions from the runnable
*/
public InvocationEvent(Object source, Runnable runnable, Object notifier,
boolean catchExceptions)
boolean catchExceptions)
{
super (source, INVOCATION_DEFAULT);
this(source, INVOCATION_DEFAULT, runnable, notifier, catchExceptions);
}
/**
* Initializes a new instance of <code>InvocationEvent</code> with the
* specified source, runnable, and notifier. It will also catch exceptions
* if specified. If notifier is non-null, this will call notifyAll() on
* the object when the runnable is complete. If catchExceptions is true,
* this traps any exception in the runnable, otherwise it lets the exception
* propagate up the Event Dispatch thread. Note that an invalid id leads to
* unspecified results.
*
* @param source the source of the event
* @param id the event id
* @param runnable the <code>Runnable</code> object to invoke
* @param notifier the object to notify, or null
* @param catchExceptions true to catch exceptions from the runnable
*/
protected InvocationEvent(Object source, int id, Runnable runnable,
Object notifier, boolean catchExceptions)
{
super(source, id);
this.runnable = runnable;
this.notifier = notifier;
this.catchExceptions = catchExceptions;
}
public void dispatch ()
/**
* This method calls the <code>run()</code> method of the runnable, traps
* exceptions if instructed to do so, and calls <code>notifyAll()</code>
* on any notifier if all worked successfully.
*/
public void dispatch()
{
Exception e = null;
if (catchExceptions)
try
{
runnable.run ();
}
catch (Exception x)
{
exception = x;
}
{
runnable.run();
}
catch (Exception e)
{
exception = e;
}
else
runnable.run ();
runnable.run();
if (notifier != null)
{
synchronized (notifier)
{
notifier.notifyAll ();
}
}
notifier.notifyAll();
}
public Exception getException ()
/**
* This method returns the exception that occurred during the execution of
* the runnable, or <code>null</code> if not exception was thrown or
* exceptions were not caught.
*
* @return the exception thrown by the runnable
*/
public Exception getException()
{
return exception;
}
public String paramString ()
/**
* Gets the timestamp of when this event was created.
*
* @return the timestamp of this event
* @since 1.4
*/
public long getWhen()
{
String r;
if (id == INVOCATION_DEFAULT)
r = "INVOCATION_DEFAULT";
else
r = "unknown type";
r += ",runnable=" + runnable + ",notifier=" + notifier +
",catchExceptions=" + catchExceptions;
return r;
return when;
}
protected boolean catchExceptions;
protected Object notifier;
protected Runnable runnable;
private Exception exception;
}
/**
* This method returns a string identifying this event. This is formatted as:
* <code>"INVOCATION_DEFAULT,runnable=" + runnable + ",notifier=" + notifier
* + ",catchExceptions=" + catchExceptions + ",when=" + getWhen()</code>.
*
* @return a string identifying this event
*/
public String paramString()
{
return (id == INVOCATION_DEFAULT ? "INVOCATION_DEFAULT,runnable="
: "unknown type,runnable=") + runnable + ",notifier=" + notifier
+ ",catchExceptions=" + catchExceptions + ",when=" + when;
}
} // class InvocationEvent
+127 -53
View File
@@ -1,81 +1,155 @@
/* Copyright (C) 2000 Free Software Foundation
/* ItemEvent.java -- event for item state changes
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.AWTEvent;
import java.awt.ItemSelectable;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This event is generated when a selection item changes state. This is an
* abstraction that distills a large number of individual mouse or keyboard
* events into a simpler "item selected" and "item deselected" events.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ItemSelectable
* @see ItemListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public class ItemEvent extends AWTEvent
{
public static final int DESELECTED = 2;
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -608708132447206933L;
/** This is the first id in the event id range used by this class. */
public static final int ITEM_FIRST = 701;
/** This is the last id in the event id range used by this class. */
public static final int ITEM_LAST = 701;
/** This event id indicates a state change occurred. */
public static final int ITEM_STATE_CHANGED = 701;
/** This type indicates that the item was selected. */
public static final int SELECTED = 1;
public ItemEvent (ItemSelectable source, int id, Object item, int sc)
/** This type indicates that the item was deselected. */
public static final int DESELECTED = 2;
/**
* The item affected by this event.
*
* @serial the item of the selection
*/
private final Object item;
/**
* The state change direction, one of {@link #SELECTED} or
* {@link #DESELECTED}.
*
* @serial the selection state
*/
private final int stateChange;
/**
* Initializes a new instance of <code>ItemEvent</code> with the specified
* source, id, and state change constant. Note that an invalid id leads to
* unspecified results.
*
* @param source the source of the event
* @param id the event id
* @param item the item affected by the state change
* @param stateChange one of {@link #SELECTED} or {@link #DESELECTED}
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange)
{
super (source, id);
super(source, id);
this.item = item;
this.stateChange = sc;
this.stateChange = stateChange;
}
public Object getItem ()
{
return item;
}
public ItemSelectable getItemSelectable ()
/**
* This method returns the event source as an <code>ItemSelectable</code>.
*
* @return the event source as an <code>ItemSelected</code>
* @throws ClassCastException if source is changed to a non-ItemSelectable
*/
public ItemSelectable getItemSelectable()
{
return (ItemSelectable) source;
}
public int getStateChange ()
/**
* Returns the item affected by this state change.
*
* @return the item affected by this state change
*/
public Object getItem()
{
return item;
}
/**
* Returns the type of state change, either {@link #SELECTED} or
* {@link #DESELECTED}.
*
* @return the type of state change
*/
public int getStateChange()
{
return stateChange;
}
public String paramString ()
/**
* Returns a string identifying this event. This is in the format:
* <code>"ITEM_STATE_CHANGED,item=" + item + ",stateChange="
* + (getStateChange() == DESELECTED ? "DESELECTED" : "SELECTED")</code>.
*
* @return a string identifying this event
*/
public String paramString()
{
String r;
switch (id)
{
case ITEM_STATE_CHANGED:
r = "ITEM_STATE_CHANGED";
break;
default:
r = "unknown id";
break;
}
r += ",item=" + item + ",stateChange=";
switch (stateChange)
{
case SELECTED:
r += "SELECTED";
break;
case DESELECTED:
r += "DESELECTED";
break;
default:
r += "unknown";
break;
}
return r;
return (id == ITEM_STATE_CHANGED ? "ITEM_STATE_CHANGED,item="
: "unknown type,item=") + item + ",stateChange="
+ (stateChange == SELECTED ? "SELECTED"
: stateChange == DESELECTED ? "DESELECTED" : "unknown type");
}
private Object item;
private int stateChange;
}
} // class ItemEvent
+53 -13
View File
@@ -1,21 +1,61 @@
/* Copyright (C) 2000 Free Software Foundation
/* ItemListener.java -- listen for item events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This interface is for classes that wish to receive events when an
* item's selection state changes.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ItemSelectable
* @see ItemEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface ItemListener extends java.util.EventListener
public interface ItemListener extends EventListener
{
public void itemStateChanged (ItemEvent e);
}
/**
* This method is called when an item's state is changed.
*
* @param event the <code>ItemEvent</code> indicating the change
*/
void itemStateChanged(ItemEvent event);
} // interface ItemListener
+71 -14
View File
@@ -1,31 +1,88 @@
/* Copyright (C) 2000 Free Software Foundation
/* KeyAdapter.java -- convenience class for writing key listeners
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class implements <code>KeyListener</code> and implements all methods
* with empty bodies. This allows a listener interested in implementing only
* a subset of the <code>KeyListener</code> interface to extend this class
* and override only the desired methods.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see KeyEvent
* @see KeyListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public abstract class KeyAdapter implements KeyListener
{
public void keyPressed (KeyEvent w)
/**
* Do nothing default constructor for subclasses.
*/
public KeyAdapter()
{
}
public void keyReleased (KeyEvent w)
/**
* Implements this method in the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void keyTyped(KeyEvent event)
{
}
public void keyTyped (KeyEvent w)
/**
* Implements this method in the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void keyPressed(KeyEvent event)
{
}
}
/**
* Implements this method in the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void keyReleased(KeyEvent event)
{
}
} // class KeyAdapter
File diff suppressed because it is too large Load Diff
+69 -15
View File
@@ -1,23 +1,77 @@
/* Copyright (C) 1999 Free Software Foundation
/* KeyListener.java -- listen for keyboard presses
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Per Bothner <bothner@cygnus.com>
* @date Fenruary, 1999.
* This interface is for classes that wish to receive keyboard events. To
* watch a subset of these events, use a KeyAdapter.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see KeyAdapter
* @see KeyEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public interface KeyListener extends java.util.EventListener
public interface KeyListener extends EventListener
{
public void keyPressed (KeyEvent w);
public void keyReleased (KeyEvent w);
public void keyTyped (KeyEvent w);
}
/**
* This method is called when a key is typed. A key is considered typed
* when it and all modifiers have been pressed and released, mapping to
* a single virtual key.
*
* @param event the <code>KeyEvent</code> indicating that a key was typed
*/
void keyTyped(KeyEvent event);
/**
* This method is called when a key is pressed.
*
* @param event the <code>KeyEvent</code> indicating the key press
*/
void keyPressed(KeyEvent event);
/**
* This method is called when a key is released.
*
* @param event the <code>KeyEvent</code> indicating the key release
*/
void keyReleased(KeyEvent event);
} // interface KeyListener
+83 -16
View File
@@ -1,39 +1,106 @@
/* Copyright (C) 2000 Free Software Foundation
/* MouseAdapter.java -- convenience class for writing mouse listeners
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class implements <code>MouseListener</code> and implements all methods
* with empty bodies. This allows a listener interested in implementing only
* a subset of the <code>MouseListener</code> interface to extend this class
* and override only the desired methods.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see MouseEvent
* @see MouseListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public abstract class MouseAdapter implements MouseListener
{
public void mouseClicked (MouseEvent e)
/**
* Do nothing default constructor for subclasses.
*/
public MouseAdapter()
{
}
public void mouseEntered (MouseEvent e)
/**
* Implements this method in the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void mouseClicked(MouseEvent event)
{
}
public void mouseExited (MouseEvent e)
/**
* Implements this method in the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void mousePressed(MouseEvent event)
{
}
public void mousePressed (MouseEvent e)
/**
* Implements this method in the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void mouseReleased(MouseEvent event)
{
}
public void mouseReleased (MouseEvent e)
/**
* Implements this method in the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void mouseEntered(MouseEvent event)
{
}
}
/**
* Implements this method in the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void mouseExited(MouseEvent event)
{
}
} // class MouseAdapter
+388 -70
View File
@@ -1,113 +1,431 @@
/* Copyright (C) 2000, 2002 Free Software Foundation
/* MouseEvent.java -- a mouse event
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.Component;
import java.awt.Point;
import java.io.IOException;
import java.io.ObjectInputStream;
import gnu.java.awt.EventModifier;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This event is generated for a mouse event. There are three main categories
* of mouse events: Regular events include pressing, releasing, and clicking
* buttons, as well as moving over the boundary of the unobscured portion of
* a component. Motion events include movement and dragging. Wheel events are
* covered separately by the subclass MouseWheelEvent.
*
* <p>A mouse event is tied to the unobstructed visible component that the
* mouse cursor was over at the time of the action. The button that was
* most recently pressed is the only one that shows up in
* <code>getModifiers</code>, and is returned by <code>getButton</code>,
* while all buttons that are down show up in <code>getModifiersEx</code>.
*
* <p>Drag events may be cut short if native drag-and-drop operations steal
* the event. Likewise, if a mouse drag exceeds the bounds of a window or
* virtual device, some platforms may clip the path to fit in the bounds of
* the component.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @author Eric Blake <ebb9@email.byu.edu>
* @see MouseAdapter
* @see MouseListener
* @see MouseMotionAdapter
* @see MouseMotionListener
* @see MouseWheelListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public class MouseEvent extends InputEvent
{
public static final int MOUSE_CLICKED = 500;
public static final int MOUSE_DRAGGED = 506;
public static final int MOUSE_ENTERED = 504;
public static final int MOUSE_EXITED = 505;
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -991214153494842848L;
/** This is the first id in the range of event ids used by this class. */
public static final int MOUSE_FIRST = 500;
public static final int MOUSE_LAST = 506;
public static final int MOUSE_MOVED = 503;
/** This is the last id in the range of event ids used by this class. */
public static final int MOUSE_LAST = 507;
/** This event id indicates that the mouse was clicked. */
public static final int MOUSE_CLICKED = 500;
/** This event id indicates that the mouse was pressed. */
public static final int MOUSE_PRESSED = 501;
/** This event id indicates that the mouse was released. */
public static final int MOUSE_RELEASED = 502;
public MouseEvent (Component source, int id, long when, int modifiers,
int x, int y, int clickCount, boolean popupTrigger)
/** This event id indicates that the mouse was moved. */
public static final int MOUSE_MOVED = 503;
/** This event id indicates that the mouse entered a component. */
public static final int MOUSE_ENTERED = 504;
/** This event id indicates that the mouse exited a component. */
public static final int MOUSE_EXITED = 505;
/**
* This indicates that no button changed state.
*
* @see #getButton()
* @since 1.4
*/
public static final int NOBUTTON = 0;
/**
* This indicates that button 1 changed state.
*
* @see #getButton()
* @since 1.4
*/
public static final int BUTTON1 = 1;
/**
* This indicates that button 2 changed state.
*
* @see #getButton()
* @since 1.4
*/
public static final int BUTTON2 = 2;
/**
* This indicates that button 3 changed state.
*
* @see #getButton()
* @since 1.4
*/
public static final int BUTTON3 = 3;
/** This event id indicates that the mouse was dragged over a component. */
public static final int MOUSE_DRAGGED = 506;
/**
* This event id indicates that the mouse wheel was rotated.
*
* @since 1.4
*/
public static final int MOUSE_WHEEL = 507;
/**
* The X coordinate of the mouse cursor at the time of the event.
*
* @see #getX()
* @serial the x coordinate
*/
private int x;
/**
* The Y coordinate of the mouse cursor at the time of the event.
*
* @see #getY()
* @serial the y coordinate
*/
private int y;
/**
* The number of clicks that took place. For MOUSE_CLICKED, MOUSE_PRESSED,
* and MOUSE_RELEASED, this will be at least 1; otherwise it is 0.
*
* see #getClickCount()
* @serial the number of clicks
*/
private final int clickCount;
/**
* Indicates which mouse button changed state. Can only be one of
* {@link #NOBUTTON}, {@link #BUTTON1}, {@link #BUTTON2}, or
* {@link #BUTTON3}.
*
* @see #getButton()
* @since 1.4
*/
private int button;
/**
* Whether or not this event should trigger a popup menu.
*
* @see PopupMenu
* @see #isPopupTrigger()
* @serial true if this is a popup trigger
*/
private final boolean popupTrigger;
/**
* Initializes a new instance of <code>MouseEvent</code> with the specified
* information. Note that an invalid id leads to unspecified results.
*
* @param source the source of the event
* @param id the event id
* @param when the timestamp of when the event occurred
* @param modifiers the modifier keys during the event, in old or new style
* @param x the X coordinate of the mouse point
* @param y the Y coordinate of the mouse point
* @param clickCount the number of mouse clicks for this event
* @param popupTrigger true if this event triggers a popup menu
* @param button the most recent mouse button to change state
* @throws IllegalArgumentException if source is null or button is invalid
* @since 1.4
*/
public MouseEvent(Component source, int id, long when, int modifiers,
int x, int y, int clickCount, boolean popupTrigger,
int button)
{
super (source, id);
this.when = when;
this.modifiers = modifiers;
super(source, id, when, modifiers);
this.x = x;
this.y = y;
this.clickCount = clickCount;
this.popupTrigger = popupTrigger;
this.button = button;
if (button < NOBUTTON || button > BUTTON3)
throw new IllegalArgumentException();
if ((modifiers & EventModifier.OLD_MASK) != 0)
{
if ((modifiers & BUTTON1_MASK) != 0)
button = BUTTON1;
else if ((modifiers & BUTTON2_MASK) != 0)
button = BUTTON2;
else if ((modifiers & BUTTON3_MASK) != 0)
button = BUTTON3;
}
}
public int getClickCount ()
/**
* Initializes a new instance of <code>MouseEvent</code> with the specified
* information. Note that an invalid id leads to unspecified results.
*
* @param source the source of the event
* @param id the event id
* @param when the timestamp of when the event occurred
* @param modifiers the modifier keys during the event, in old or new style
* @param x the X coordinate of the mouse point
* @param y the Y coordinate of the mouse point
* @param clickCount the number of mouse clicks for this event
* @param popupTrigger true if this event triggers a popup menu
* @throws IllegalArgumentException if source is null
*/
public MouseEvent(Component source, int id, long when, int modifiers,
int x, int y, int clickCount, boolean popupTrigger)
{
return clickCount;
this(source, id, when, modifiers, x, y, clickCount, popupTrigger,
NOBUTTON);
}
public Point getPoint ()
{
return new Point (x, y);
}
public int getX ()
/**
* This method returns the X coordinate of the mouse position. This is
* relative to the source component.
*
* @return the x coordinate
*/
public int getX()
{
return x;
}
public int getY ()
/**
* This method returns the Y coordinate of the mouse position. This is
* relative to the source component.
*
* @return the y coordinate
*/
public int getY()
{
return y;
}
public boolean isPopupTrigger ()
/**
* This method returns a <code>Point</code> for the x,y position of
* the mouse pointer. This is relative to the source component.
*
* @return a <code>Point</code> for the event position
*/
public Point getPoint()
{
return new Point(x, y);
}
/**
* Translates the event coordinates by the specified x and y offsets.
*
* @param dx the value to add to the X coordinate of this event
* @param dy the value to add to the Y coordiante of this event
*/
public void translatePoint(int dx, int dy)
{
x += dx;
y += dy;
}
/**
* This method returns the number of mouse clicks associated with this
* event.
*
* @return the number of mouse clicks for this event
*/
public int getClickCount()
{
return clickCount;
}
/**
* Returns which button, if any, was the most recent to change state. This
* will be one of {@link #NOBUTTON}, {@link #BUTTON1}, {@link #BUTTON2}, or
* {@link #BUTTON3}.
*
* @return the button that changed state
* @since 1.4
*/
public int getButton()
{
return button;
}
/**
* This method tests whether or not the event is a popup menu trigger. This
* should be checked in both MousePressed and MouseReleased to be
* cross-platform compatible, as different systems have different popup
* triggers.
*
* @return true if the event is a popup menu trigger
*/
public boolean isPopupTrigger()
{
return popupTrigger;
}
public String paramString ()
/**
* Returns a string describing the modifiers, such as "Shift" or
* "Ctrl+Button1".
*
* XXX Sun claims this can be localized via the awt.properties file - how
* do we implement that?
*
* @param modifiers the old-style modifiers to convert to text
* @return a string representation of the modifiers in this bitmask
*/
public static String getMouseModifiersText(int modifiers)
{
String r;
modifiers &= EventModifier.OLD_MASK;
if ((modifiers & BUTTON2_MASK) != 0)
modifiers |= BUTTON2_DOWN_MASK;
if ((modifiers & BUTTON3_MASK) != 0)
modifiers |= BUTTON3_DOWN_MASK;
return getModifiersExText(EventModifier.extend(modifiers));
}
/**
* Returns a string identifying this event. This is formatted as the field
* name of the id type, followed by the (x,y) point, the most recent button
* changed, modifiers (if any), extModifiers (if any), and clickCount.
*
* @return a string identifying this event
*/
public String paramString()
{
StringBuffer s = new StringBuffer();
switch (id)
{
case MOUSE_CLICKED:
r = "MOUSE_CLICKED";
break;
case MOUSE_DRAGGED:
r = "MOUSE_DRAGGED";
break;
case MOUSE_ENTERED:
r = "MOUSE_ENTERED";
break;
case MOUSE_EXITED:
r = "MOUSE_EXITED";
break;
case MOUSE_MOVED:
r = "MOUSE_MOVED";
break;
case MOUSE_PRESSED:
r = "MOUSE_PRESSED";
break;
case MOUSE_RELEASED:
r = "MOUSE_RELEASED";
break;
default:
r = "unknown id";
break;
case MOUSE_CLICKED:
s.append("MOUSE_CLICKED,(");
break;
case MOUSE_PRESSED:
s.append("MOUSE_PRESSED,(");
break;
case MOUSE_RELEASED:
s.append("MOUSE_RELEASED,(");
break;
case MOUSE_MOVED:
s.append("MOUSE_MOVED,(");
break;
case MOUSE_ENTERED:
s.append("MOUSE_ENTERED,(");
break;
case MOUSE_EXITED:
s.append("MOUSE_EXITED,(");
break;
case MOUSE_DRAGGED:
s.append("MOUSE_DRAGGED,(");
break;
case MOUSE_WHEEL:
s.append("MOUSE_WHEEL,(");
break;
default:
s.append("unknown type,(");
}
r += ",(" + x + "," + y + "),modifiers=" + modifiers + ",clickCount=" +
clickCount;
return r;
s.append(x).append(',').append(y).append("),button=").append(button);
if ((modifiers & EventModifier.NEW_MASK) != 0)
{
int mod = modifiers;
if ((mod & (ALT_DOWN_MASK | BUTTON2_DOWN_MASK)) != 0)
mod |= ALT_DOWN_MASK | BUTTON2_DOWN_MASK;
if ((mod & (META_DOWN_MASK | BUTTON3_DOWN_MASK)) != 0)
mod |= META_DOWN_MASK | BUTTON3_DOWN_MASK;
s.append(",modifiers=").append(getModifiersExText(mod));
}
if (modifiers != 0)
s.append(",extModifiers=").append(getModifiersExText(modifiers));
return s.append(",clickCount=").append(clickCount).toString();
}
public void translatePoint (int x, int y)
/**
* Reads in the object from a serial stream.
*
* @param s the stream to read from
* @throws IOException if deserialization fails
* @throws ClassNotFoundException if deserialization fails
* @serialData default, except that the modifiers are converted to new style
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
this.x += x;
this.y += y;
s.defaultReadObject();
if ((modifiers & EventModifier.OLD_MASK) != 0)
{
if ((modifiers & BUTTON1_MASK) != 0)
button = BUTTON1;
else if ((modifiers & BUTTON2_MASK) != 0)
button = BUTTON2;
else if ((modifiers & BUTTON3_MASK) != 0)
button = BUTTON3;
modifiers = EventModifier.extend(modifiers);
}
}
private int x;
private int y;
private int clickCount;
private boolean popupTrigger;
}
} // class MouseEvent
+86 -17
View File
@@ -1,25 +1,94 @@
/* Copyright (C) 2000 Free Software Foundation
/* MouseListener.java -- listen for mouse clicks and crossing component edges
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This interface is for classes that wish to receive mouse events other than
* simple motion events. This includes clicks (but not mouse wheel events),
* and crossing component boundaries without change in button status. To
* track moves and drags, use MouseMotionListener, and to track wheel events,
* use MouseWheelListener. To watch a subset of these events, use a
* MouseAdapter.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see MouseAdapter
* @see MouseEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface MouseListener extends java.util.EventListener
public interface MouseListener extends EventListener
{
public void mouseClicked (MouseEvent e);
public void mouseEntered (MouseEvent e);
public void mouseExited (MouseEvent e);
public void mousePressed (MouseEvent e);
public void mouseReleased (MouseEvent e);
}
/**
* This method is called when the mouse is clicked (pressed and released
* in short succession) on a component.
*
* @param event the <code>MouseEvent</code> indicating the click
*/
void mouseClicked(MouseEvent event);
/**
* This method is called when the mouse is pressed over a component.
*
* @param event the <code>MouseEvent</code> for the press
*/
void mousePressed(MouseEvent event);
/**
* This method is called when the mouse is released over a component.
*
* @param event the <code>MouseEvent</code> for the release
*/
void mouseReleased(MouseEvent event);
/**
* This method is called when the mouse enters a component.
*
* @param event the <code>MouseEvent</code> for the entry
*/
void mouseEntered(MouseEvent event);
/**
* This method is called when the mouse exits a component.
*
* @param event the <code>MouseEvent</code> for the exit
*/
void mouseExited(MouseEvent event);
} // interface MouseListener
+65 -13
View File
@@ -1,27 +1,79 @@
/* Copyright (C) 2000 Free Software Foundation
/* MouseMotionAdapter.java -- convenience class for mouse motion listeners
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This class implements <code>MouseMotionListener</code> and implements all
* methods with empty bodies. This allows a listener interested in
* implementing only a subset of the <code>MouseMotionListener</code>
* interface to extend this class and override only the desired methods.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see MouseEvent
* @see MouseMotionListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public abstract class MouseMotionAdapter implements MouseMotionListener
{
public void mouseDragged (MouseEvent e)
/**
* Do nothing default constructor for subclasses.
*/
public MouseMotionAdapter()
{
}
public void mouseMoved (MouseEvent e)
/**
* Implement this method in the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void mouseDragged(MouseEvent event)
{
}
}
/**
* Implement this method in the interface with an empty body.
*
* @param event the event, ignored in this implementation
*/
public void mouseMoved(MouseEvent event)
{
}
} // class MouseMotionAdapter
+64 -14
View File
@@ -1,22 +1,72 @@
/* Copyright (C) 2000 Free Software Foundation
/* MouseMotionListener.java -- listen to mouse motion events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This interface is for classes that wish to be notified of mouse movements.
* This includes moves and drags, but not crossing component boundaries. To
* track other mouse events, use MouseListener or MouseWheelListener. To
* watch a subset of these events, use a MouseMotionAdapter.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see MouseMotionAdapter
* @see MouseEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public interface MouseMotionListener extends java.util.EventListener
public interface MouseMotionListener extends EventListener
{
public void mouseDragged (MouseEvent e);
public void mouseMoved (MouseEvent e);
}
/**
* This method is called when the mouse is moved over a component
* while a button has been pressed.
*
* @param event the <code>MouseEvent</code> indicating the motion
*/
void mouseDragged(MouseEvent event);
/**
* This method is called when the mouse is moved over a component
* while no button is pressed.
*
* @param event the <code>MouseEvent</code> indicating the motion
*/
void mouseMoved(MouseEvent event);
} // interface MouseMotionListener
+227
View File
@@ -0,0 +1,227 @@
/* MouseWheelEvent.java -- a mouse wheel event
Copyright (C) 2002 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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.event;
import java.awt.Component;
import java.awt.Point;
/**
* This event is generated for a mouse wheel rotation. The wheel (the middle
* mouse button on most modern mice) can be rotated towards or away from the
* user, and is ofteh used for scrolling.
*
* <p>Because of the special use for scrolling components, MouseWheelEvents
* often affect a different component than the one located at the point of
* the event. If the component under the mouse cursor does not accept wheel
* events, the event is passed to the first ancestor container which does. This
* is often a ScrollPane, which knows how to scroll. If an AWT component is
* built from a native widget that knows how to use mouse wheel events, that
* component will consume the event.
*
* <p>The two most common scroll types are "units" (lines at a time) or
* "blocks" (pages at a time). The initial setting is taken from the platform,
* although the user can adjust the setting at any time.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @see MouseWheelListener
* @see ScrollPane
* @see ScrollPane#setWheelScrollingEnabled(boolean)
* @see JScrollPane
* @see JScrollPane#setWheelScrollingEnabled(boolean)
* @since 1.4
* @status updated to 1.4
*/
public class MouseWheelEvent extends MouseEvent
{
/**
* Compatible with JDK 1.4+.
*/
private static final long serialVersionUID = 6459879390515399677L;
/**
* Indicates scrolling by units (lines).
*
* @see #getScrollType()
*/
public static final int WHEEL_UNIT_SCROLL = 0;
/**
* Indicates scrolling by blocks (pages).
*
* @see #getScrollType()
*/
public static final int WHEEL_BLOCK_SCROLL = 1;
/**
* Indicates what scroll type should take place. This should be limited
* to {@link #WHEEL_UNIT_SCROLL} and {@link #WHEEL_BLOCK_SCROLL}.
*
* @serial the scroll type
*/
private final int scrollType;
/**
* Indicates the scroll amount. This is only meaningful if scrollType is
* WHEEL_UNIT_SCROLL.
*
* @serial the number of lines to scroll
*/
private final int scrollAmount;
/**
* Indicates how far the mouse wheel was rotated.
*
* @serial the rotation amount
*/
private final int wheelRotation;
/**
* Initializes a new instance of <code>MouseWheelEvent</code> with the
* specified information. Note that an invalid id leads to unspecified
* results.
*
* @param source the source of the event
* @param id the event id
* @param when the timestamp of when the event occurred
* @param modifiers any modifier bits for this event
* @param x the X coordinate of the mouse point
* @param y the Y coordinate of the mouse point
* @param clickCount the number of mouse clicks for this event
* @param popupTrigger true if this event triggers a popup menu
* @param scrollType one of {@link #WHEEL_UNIT_SCROLL},
* {@link #WHEEL_BLOCK_SCROLL}
* @param scrollAmount the number of units to scroll, ignored for block type
* @param wheelRotation the number of rotation "clicks"
* @throws IllegalArgumentException if source is null
* @see MouseEvent#MouseEvent(Component, int, long, int, int, int, int,
* boolean)
*/
public MouseWheelEvent(Component source, int id, long when, int modifiers,
int x, int y, int clickCount, boolean popupTrigger,
int scrollType, int scrollAmount, int wheelRotation)
{
super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
this.scrollType = scrollType;
this.scrollAmount = scrollAmount;
this.wheelRotation = wheelRotation;
}
/**
* This method returns the scrolling pattern this event requests. Legal
* values are WHEEL_UNIT_SCROLL and WHEEL_BLOCK_SCROLL.
*
* @return the scroll type
* @see Adjustable#getUnitIncrement()
* @see Adjustable#getBlockIncrement()
* @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int)
* @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int)
*/
public int getScrollType()
{
return scrollType;
}
/**
* Returns the number of units to scroll in response to this event. This
* only makes sense when the scroll type is WHEEL_UNIT_SCROLL.
*
* @return the number of scroll units, if defined
* @see #getScrollType()
*/
public int getScrollAmount()
{
return scrollAmount;
}
/**
* Gets the number of "clicks" the wheel was rotated. Negative values move
* up (away) from the user, positive values move down (towards) the user.
*
* @return the number of rotation clicks
*/
public int getWheelRotation()
{
return wheelRotation;
}
/**
* This is a convenience method which aids in a common listener for scrolling
* a scrollpane (although this is already built into ScrollPane and
* JScrollPane). This method only makes sense when getScrollType() returns
* WHEEL_UNIT_SCROLL.
*
* <p>This accounts for direction of scroll and amount of wheel movement, as
* interpreted by the platform settings.
*
* @return the number of units to scroll
* @see #getScrollType()
* @see #getScrollAmount()
* @see MouseWheelListener
* @see Adjustable
* @see Adjustable#getUnitIncrement()
* @see Scrollable
* @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int)
* @see ScrollPane
* @see ScrollPane#setWheelScrollingEnabled(boolean)
* @see JScrollPane
* @see JScrollPane#setWheelScrollingEnabled(boolean)
*/
public int getUnitsToScroll()
{
return wheelRotation * scrollAmount;
}
/**
* Returns a string identifying this event. For mouse wheel events, this
* is <code>super.paramString() + ",scrollType=WHEEL_" +
* (getScrollType() == WHEEL_UNIT_SCROLL ? "UNIT" : "BLOCK")
* + "_SCROLL,scrollAmount=" + getScrollAmount() + ",wheelRotation="
* + getWheelRotation()</code>.
*
* @return a string identifying this event
*/
public String paramString()
{
return super.paramString() + ",scrollType="
+ (scrollType == WHEEL_UNIT_SCROLL ? "WHEEL_UNIT_SCROLL"
: scrollType == WHEEL_BLOCK_SCROLL ? "WHEEL_BLOCK_SCROLL"
: "unknown scroll type")
+ ",scrollAmount=" + scrollAmount + ",wheelRotation=" + wheelRotation;
}
} // class MouseWheelEvent
@@ -0,0 +1,60 @@
/* MouseWheelListener.java -- listen for mouse wheel events
Copyright (C) 2002 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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.event;
import java.util.EventListener;
/**
* This interface is for classes that wish to receive mouse wheel events. For
* other events, use MouseListener or MouseMotionListener.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @see MouseWheelEvent
* @since 1.4
* @status updated to 1.4
*/
public interface MouseWheelListener extends EventListener
{
/**
* This method is called when the mouse wheel is rotated.
*
* @param event the <code>MouseWheelEvent</code> indicating the rotation
*/
void mouseWheelMoved(MouseWheelEvent event);
} // interface MouseWheelListener
+102 -38
View File
@@ -1,63 +1,127 @@
/* Copyright (C) 2000 Free Software Foundation
/* PaintEvent.java -- an area of the screen needs to be repainted
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
import java.awt.Component;
import java.awt.Rectangle;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date April 8, 2000
* This event is generated when an area of the screen needs to be painted.
* This event is not meant for users, but exists to allow proper serialization
* behavior in the EventQueue with user-accessible events.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct to JDK 1.2. */
public class PaintEvent extends ComponentEvent
{
public static final int PAINT = 800;
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = 1267492026433337593L;
/** This is the first id in the range of event ids used by this class. */
public static final int PAINT_FIRST = 800;
/** This is the last id in the range of event ids used by this class. */
public static final int PAINT_LAST = 801;
/** This id is for paint event types. */
public static final int PAINT = 800;
/** This id is for update event types. */
public static final int UPDATE = 801;
public PaintEvent (Component source, int id, Rectangle updateRect)
/**
* This is the rectange to be painted or updated.
*
* @see #getUpdateRect()
* @see #setUpdateRect(Rectangle)
* @serial the non-null rectangle to be painted
*/
private Rectangle updateRect;
/**
* Initializes a new instance of <code>PaintEvent</code> with the specified
* source, id, and update region. Note that an invalid id leads to
* unspecified results.
*
* @param source the event source
* @param id the event id
* @param updateRect the rectangle to repaint
* @throws IllegalArgumentException if source is null
*/
public PaintEvent(Component source, int id, Rectangle updateRect)
{
super (source, id);
super(source, id);
this.updateRect = updateRect;
}
public Rectangle getUpdateRect ()
/**
* Returns the rectange to be updated for this event.
*
* @return the rectangle to update
*/
public Rectangle getUpdateRect()
{
return updateRect;
}
public String paramString ()
{
String r;
switch (id)
{
case UPDATE:
r = "UPDATE";
break;
case PAINT:
r = "PAINT";
break;
default:
r = "unknown id";
break;
}
r += ",updateRect=" + updateRect;
return r;
}
public void setUpdateRect (Rectangle updateRect)
/**
* Sets the rectangle to be updated for this event.
*
* @param updateRect the new update rectangle for this event
*/
public void setUpdateRect(Rectangle updateRect)
{
this.updateRect = updateRect;
}
private Rectangle updateRect;
}
/**
* Returns a string identifying this event.
*
* @return a string identifying this event
*/
public String paramString()
{
return (id == PAINT ? "PAINT,updateRect=" : id == UPDATE
? "UPDATE,updateRect=" : "unknown type,updateRect=") + updateRect;
}
} // class PaintEvent
+75 -12
View File
@@ -1,29 +1,92 @@
/* Copyright (C) 1999, 2000 Free Software Foundation
/* TextEvent.java -- event for text changes
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
/* Status: Believed complete and correct to JDK 1.2. */
import java.awt.AWTEvent;
/**
* This event is generated when a text box changes contents. This is an
* abstraction that distills a large number of individual mouse or keyboard
* events into a simpler "text changed" event.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see TextComponent
* @see TextListener
* @since 1.1
* @status updated to 1.4
*/
public class TextEvent extends AWTEvent
{
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = 6269902291250941179L;
/** This is the first id in the range of event ids used by this class. */
public static final int TEXT_FIRST = 900;
/** This is the last id in the range of event ids used by this class. */
public static final int TEXT_LAST = 900;
/** This event id indicates that the text of an object has changed. */
public static final int TEXT_VALUE_CHANGED = 900;
public TextEvent (Object source, int id)
/**
* Initializes a new instance of <code>TextEvent</code> with the specified
* source and id. Note that an invalid id leads to unspecified results.
*
* @param source the (TextComponent) object that generated this event
* @param id the event id
* @throws IllegalArgumentException if source is null
*/
public TextEvent(Object source, int id)
{
super (source, id);
super(source, id);
}
public String paramString ()
/**
* Returns a string identifying this event. This is "TEXT_VALUE_CHANGED".
*
* @return a string identifying this event
*/
public String paramString()
{
return "TEXT_VALUE_CHANGED";
return id == TEXT_VALUE_CHANGED ? "TEXT_VALUE_CHANGED" : "unknown type";
}
}
} // class TextEvent
+52 -14
View File
@@ -1,22 +1,60 @@
/* Copyright (C) 1999 Free Software Foundation
/* TextListener.java -- listen for text changes
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Per Bothner <bothner@cygnus.com>
* @date Fenruary, 1999.
* This interface is for classes that wish to be notified when text changes
* in a component.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see TextEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public interface TextListener extends java.util.EventListener
public interface TextListener extends EventListener
{
public void textValueChanged (TextEvent w);
}
/**
* This method is called when the text being monitored changes.
*
* @param event the <code>TextEvent</code> indicating the change
*/
void textValueChanged(TextEvent event);
} // interface TextListener
+148 -19
View File
@@ -1,27 +1,156 @@
/* Copyright (C) 1999, 2000 Free Software Foundation
/* WindowAdapter.java -- convenience class for writing window listeners
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
/**
* @author Per Bothner <bothner@cygnus.com>
* @date February, 1999.
* This class implements <code>WindowListener</code>,
* <code>WindowStateListener</code>, and <code>WindowFocusListener</code>, and
* implements all methods with empty bodies. This allows a listener
* interested in listening to only a subset of any <code>WindowEvent</code>
* actions to extend this class and override only the desired methods.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see ComponentEvent
* @see ComponentListener
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public abstract class WindowAdapter implements WindowListener
public abstract class WindowAdapter
implements WindowListener, WindowStateListener, WindowFocusListener
{
public void windowActivated (WindowEvent w) { }
public void windowClosed (WindowEvent w) { }
public void windowClosing (WindowEvent w) { }
public void windowDeactivated (WindowEvent w) { }
public void windowDeiconified (WindowEvent w) { }
public void windowIconified (WindowEvent w) { }
public void windowOpened (WindowEvent w) { }
}
/**
* Do nothing default constructor for subclasses.
*/
public WindowAdapter()
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void windowOpened(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void windowClosing(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void windowClosed(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void windowIconified(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void windowDeiconified(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void windowActivated(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
*/
public void windowDeactivated(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
* @since 1.4
*/
public void windowStateChanged(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
* @since 1.4
*/
public void windowGainedFocus(WindowEvent event)
{
}
/**
* Implements this method from the interface with an empty method body.
*
* @param event the event, ignored in this implementation
* @since 1.4
*/
public void windowLostFocus(WindowEvent event)
{
}
} // class WindowAdapter
+289 -43
View File
@@ -1,65 +1,311 @@
/* Copyright (C) 1999, 2000 Free Software Foundation
/* WindowEvent.java -- window change event
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.awt.*;
/* Status: Believed complete and correct to JDK 1.2. */
import java.awt.Window;
/**
* This event is generated when there is a change in a window. This includes
* creation, closing, iconification, activation, and focus changes. There
* are three listeners, for three types of events: WindowListeners deal with
* the lifecycle of a window, WindowStateListeners deal with window state
* like maximization, and WindowFocusListeners deal with focus switching to
* or from a window.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see WindowAdapter
* @see WindowListener
* @see WindowFocusListener
* @see WindowStateListener
* @since 1.1
* @status updated to 1.4
*/
public class WindowEvent extends ComponentEvent
{
public static final int WINDOW_ACTIVATED = 205;
public static final int WINDOW_CLOSED = 202;
public static final int WINDOW_CLOSING = 201;
public static final int WINDOW_DEACTIVATED = 206;
public static final int WINDOW_DEICONIFIED = 204;
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -1567959133147912127L;
/** This is the first id in the range of event ids used by this class. */
public static final int WINDOW_FIRST = 200;
public static final int WINDOW_ICONIFIED = 203;
public static final int WINDOW_LAST = 206;
/** This is the id for a window that is opened. */
public static final int WINDOW_OPENED = 200;
public WindowEvent (Window source, int id)
/** This is the id for a window that is about to close. */
public static final int WINDOW_CLOSING = 201;
/** This is the id for a window that finished closing. */
public static final int WINDOW_CLOSED = 202;
/** This is the id for a window that is iconified. */
public static final int WINDOW_ICONIFIED = 203;
/** This is the id for a window that is de-iconified. */
public static final int WINDOW_DEICONIFIED = 204;
/** This is the id for a window that is activated. */
public static final int WINDOW_ACTIVATED = 205;
/** This is the id for a window that is de-activated. */
public static final int WINDOW_DEACTIVATED = 206;
/**
* This is the id for a window becoming the focused window.
*
* @since 1.4
*/
public static final int WINDOW_GAINED_FOCUS = 207;
/**
* This is the id for a window losing all focus.
*
* @since 1.4
*/
public static final int WINDOW_LOST_FOCUS = 208;
/**
* This is the id for a window state change, such as maximization.
*
* @since 1.4
*/
public static final int WINDOW_STATE_CHANGED = 209;
/** This is the last id in the range of event ids used by this class. */
public static final int WINDOW_LAST = 207;
/**
* The other Window involved in a focus or activation change. For
* WINDOW_ACTIVATED and WINDOW_GAINED_FOCUS events, this is the window that
* lost focus; for WINDOW_DEACTIVATED and WINDOW_LOST_FOCUS, this is the
* window that stole focus; and for other events (or when native
* implementation does not have the data available), this is null.
*
* @see #getOppositeWindow()
* @serial the opposite window, or null
* @since 1.4
*/
private final Window opposite;
/**
* The former state of the window.
*
* @serial bitmask of the old window state
* @since 1.4
*/
private final int oldState;
/**
* The present state of the window.
*
* @serial bitmask of the new window state
* @since 1.4
*/
private final int newState;
/**
* Initializes a new instance of <code>WindowEvent</code> with the specified
* parameters. Note that an invalid id leads to unspecified results.
*
* @param source the window that generated this event
* @param id the event id
* @param opposite the window that received the opposite event, or null
* @param oldState the previous state of this window
* @param newState the new state of this window
* @throws IllegalArgumentException if source is null
* @since 1.4
*/
public WindowEvent(Window source, int id, Window opposite,
int oldState, int newState)
{
super (source, id);
super(source, id);
this.opposite = opposite;
this.oldState = oldState;
this.newState = newState;
}
public Window getWindow ()
/**
* Initializes a new instance of <code>WindowEvent</code> with the specified
* parameters. Note that an invalid id leads to unspecified results.
*
* @param source the window that generated this event
* @param id the event id
* @param opposite the window that received the opposite event, or null
* @throws IllegalArgumentException if source is null
* @since 1.4
*/
public WindowEvent(Window source, int id, Window opposite)
{
return (Window) source;
this(source, id, opposite, 0, 0);
}
public String paramString ()
/**
* Initializes a new instance of <code>WindowEvent</code> with the specified
* parameters. Note that an invalid id leads to unspecified results.
*
* @param source the window that generated this event
* @param id the event id
* @param oldState the previous state of this window
* @param newState the new state of this window
* @throws IllegalArgumentException if source is null
* @since 1.4
*/
public WindowEvent(Window source, int id, int oldState, int newState)
{
String r = "";
this(source, id, null, oldState, newState);
}
/**
* Initializes a new instance of <code>WindowEvent</code> with the specified
* parameters. Note that an invalid id leads to unspecified results.
*
* @param source the window that generated this event
* @param id the event id
* @throws IllegalArgumentException if source is null
*/
public WindowEvent(Window source, int id)
{
this(source, id, null, 0, 0);
}
/**
* Returns the event source as a <code>Window</code>. If the source has
* subsequently been modified to a non-Window, this returns null.
*
* @return the event source as a <code>Window</code>
*/
public Window getWindow()
{
return source instanceof Window ? (Window) source : null;
}
/**
* Returns the opposite window if this window was involved in an activation
* or focus change. For WINDOW_ACTIVATED and WINDOW_GAINED_FOCUS events,
* this is the window that lost focus; for WINDOW_DEACTIVATED and
* WINDOW_LOST_FOCUS, this is the window that stole focus; and for other
* events (or when native implementation does not have the data available),
* this is null.
*
* @return the opposite window, or null
* @since 1.4
*/
public Window getOppositeWindow()
{
return opposite;
}
/**
* Returns the state of this window before the event. This is the bitwise
* or of fields in Frame: NORMAL, ICONIFIED, MAXIMIZED_HORIZ, MAXIMIZED_VERT,
* and MAXIMIZED_BOTH.
*
* @return the former state
* @see Frame#getExtendedState()
* @since 1.4
*/
public int getOldState()
{
return oldState;
}
/**
* Returns the state of this window after the event. This is the bitwise
* or of fields in Frame: NORMAL, ICONIFIED, MAXIMIZED_HORIZ, MAXIMIZED_VERT,
* and MAXIMIZED_BOTH.
*
* @return the updated state
* @see Frame#getExtendedState()
* @since 1.4
*/
public int getNewState()
{
return newState;
}
/**
* Returns a string that identifies this event. This is formatted as the
* field name of the id, followed by the opposite window, old state, and
* new state.
*
* @return a string that identifies this event
*/
public String paramString()
{
StringBuffer s = new StringBuffer();
switch (id)
{
case WINDOW_ACTIVATED:
r = "WINDOW_ACTIVATED";
break;
case WINDOW_CLOSED:
r = "WINDOW_CLOSED";
break;
case WINDOW_CLOSING:
r = "WINDOW_CLOSING";
break;
case WINDOW_DEACTIVATED:
r = "WINDOW_DEACTIVATED";
break;
case WINDOW_DEICONIFIED:
r = "WINDOW_DEICONIFIED";
break;
case WINDOW_ICONIFIED:
r = "WINDOW_ICONIFIED";
break;
case WINDOW_OPENED:
r = "WINDOW_OPENED";
break;
case WINDOW_OPENED:
s.append("WINDOW_OPENED,opposite=");
break;
case WINDOW_CLOSING:
s.append("WINDOW_CLOSING,opposite=");
break;
case WINDOW_CLOSED:
s.append("WINDOW_CLOSED,opposite=");
break;
case WINDOW_ICONIFIED:
s.append("WINDOW_ICONIFIED,opposite=");
break;
case WINDOW_DEICONIFIED:
s.append("WINDOW_DEICONIFIED,opposite=");
break;
case WINDOW_ACTIVATED:
s.append("WINDOW_ACTIVATED,opposite=");
break;
case WINDOW_DEACTIVATED:
s.append("WINDOW_DEACTIVATED,opposite=");
break;
case WINDOW_GAINED_FOCUS:
s.append("WINDOW_GAINED_FOCUS,opposite=");
break;
case WINDOW_LOST_FOCUS:
s.append("WINDOW_LOST_FOCUS,opposite=");
break;
case WINDOW_STATE_CHANGED:
s.append("WINDOW_STATE_CHANGED,opposite=");
break;
default:
s.append("unknown type,opposite=");
}
return r;
return s.append(opposite).append(",oldState=").append(oldState)
.append(",newState=").append(newState).toString();
}
}
} // class WindowEvent
@@ -0,0 +1,68 @@
/* WindowFocusListener.java -- listens for window focus events
Copyright (C) 2002 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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.event;
import java.util.EventListener;
/**
* This interface is for classes that wish to monitor events for window
* focus changes. To watch a subset of these events, use a WindowAdapter.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @see WindowAdapter
* @see WindowEvent
* @since 1.4
* @status updated to 1.4
*/
public interface WindowFocusListener extends EventListener
{
/**
* This method is called when a window gains focus.
*
* @param event the <code>WindowEvent</code> indicating the focus change
*/
void windowGainedFocus(WindowEvent event);
/**
* This method is called when a window loses focus.
*
* @param event the <code>WindowEvent</code> indicating the focus change
*/
void windowLostFocus(WindowEvent event);
} // interface WindowFocusListener
+99 -19
View File
@@ -1,27 +1,107 @@
/* Copyright (C) 1999 Free Software Foundation
/* WindowListener.java -- listens for window events
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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
This software is copyrighted work licensed under the terms of the
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
details. */
package java.awt.event;
import java.util.EventListener;
/**
* @author Per Bothner <bothner@cygnus.com>
* @date Fenruary, 1999.
* This interface is for classes that wish to monitor events for window
* changes. To watch a subset of these events, use a WindowAdapter.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @see WindowAdapter
* @see WindowEvent
* @since 1.1
* @status updated to 1.4
*/
/* Status: Believed complete and correct. */
public interface WindowListener extends java.util.EventListener
public interface WindowListener extends EventListener
{
public void windowActivated (WindowEvent w);
public void windowClosed (WindowEvent w);
public void windowClosing (WindowEvent w);
public void windowDeactivated (WindowEvent w);
public void windowDeiconified (WindowEvent w);
public void windowIconified (WindowEvent w);
public void windowOpened (WindowEvent w);
}
/**
* This method is called when the window is made visible.
*
* @param event the <code>WindowEvent</code> indicating the change
*/
void windowOpened(WindowEvent event);
/**
* This method is called when the user calls the system menu close
* function, giving the program a chance to cancel the close.
*
* @param event the <code>WindowEvent</code> indicating the close attempt
*/
void windowClosing(WindowEvent event);
/**
* This method is called when the window is closed.
*
* @param event the <code>WindowEvent</code> indicating the dispose
*/
void windowClosed(WindowEvent event);
/**
* This method is called when the window is iconified.
*
* @param event the <code>WindowEvent</code> indicating the iconification
* @see Frame#setIconImage(Image)
*/
void windowIconified(WindowEvent event);
/**
* This method is called when the window is deiconified.
*
* @param event the <code>WindowEvent</code> indicating the deiconification
*/
void windowDeiconified(WindowEvent event);
/**
* This method is called when a window is activated. Only Frames and Dialogs
* can be active, and the active window always contains the component with
* focus.
*
* @param event the <code>WindowEvent</code> indicating the activation
*/
void windowActivated(WindowEvent event);
/**
* This method is called when the window is deactivated.
*
* @param event the <code>WindowEvent</code> indicating the deactivation
*/
void windowDeactivated(WindowEvent event);
} // interface WindowListener
@@ -0,0 +1,62 @@
/* WindowStateListener.java -- listens for window state changes
Copyright (C) 2002 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.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.event;
import java.util.EventListener;
/**
* This interface is for classes that wish to monitor events for window
* state changes.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @see WindowAdapter
* @see WindowEvent
* @since 1.4
* @status updated to 1.4
*/
public interface WindowStateListener extends EventListener
{
/**
* This method is called when the window state is changed, because of
* iconification or maximization.
*
* @param event the <code>WindowEvent</code> indicating the change
*/
void windowStateChanged(WindowEvent event);
} // interface WindowStateListener