Commit e589ede6 by Michael Koch Committed by Michael Koch

2003-03-02 Michael Koch <konqueror@gmx.de>

	* java/awt/Component.java
	(eventTypeEnabled): New method.
	(dispatchEventImpl): Moved checks for event to eventTypeEnabled.
	* java/awt/Container.java
	(changeSupport): New member variable.
	(addPropertyChangeListener): New methods.
	* java/awt/ContainerOrderFocusTraversalPolicy.java
	(ContainerOrderFocusTraversalPolicy): Added comment.
	(getComponentAfter): Throw exception, documentation added.
	(getComponentBefore): Throw exception, documentation added.
	(getFirstComponent): Throw exception, documentation added.
	(getLastComponent): Throw exception, documentation added.
	(getDefaultComponent): Throw exception, documentation added.
	* java/awt/EventQueue.java: Reindented.
	* java/awt/FocusTraversalPolicy.java:
	(FocusTraversalPolicy): Added comment.
	(getComponentAfter): Documentation added.
	(getComponentBefore): Documentation added.
	(getFirstComponent): Documentation added.
	(getLastComponent): Documentation added.
	(getDefaultComponent): Documentation added.
	(getInitialComponent): Documentation added.
	* java/awt/ScrollPane.java
	(wheelScrollingEnabled): New member variable.
	(ScrollPane): Initialize wheelScollingEnabled.
	(eventTypeEnabled): New method.
	(isWheelScrollingEnabled): New method.
	(setWheelScrollingEnabled): New method.

From-SVN: r63663
parent 37db829b
2003-03-02 Michael Koch <konqueror@gmx.de> 2003-03-02 Michael Koch <konqueror@gmx.de>
* java/awt/Component.java
(eventTypeEnabled): New method.
(dispatchEventImpl): Moved checks for event to eventTypeEnabled.
* java/awt/Container.java
(changeSupport): New member variable.
(addPropertyChangeListener): New methods.
* java/awt/ContainerOrderFocusTraversalPolicy.java
(ContainerOrderFocusTraversalPolicy): Added comment.
(getComponentAfter): Throw exception, documentation added.
(getComponentBefore): Throw exception, documentation added.
(getFirstComponent): Throw exception, documentation added.
(getLastComponent): Throw exception, documentation added.
(getDefaultComponent): Throw exception, documentation added.
* java/awt/EventQueue.java: Reindented.
* java/awt/FocusTraversalPolicy.java:
(FocusTraversalPolicy): Added comment.
(getComponentAfter): Documentation added.
(getComponentBefore): Documentation added.
(getFirstComponent): Documentation added.
(getLastComponent): Documentation added.
(getDefaultComponent): Documentation added.
(getInitialComponent): Documentation added.
* java/awt/ScrollPane.java
(wheelScrollingEnabled): New member variable.
(ScrollPane): Initialize wheelScollingEnabled.
(eventTypeEnabled): New method.
(isWheelScrollingEnabled): New method.
(setWheelScrollingEnabled): New method.
2003-03-02 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java * java/net/DatagramSocket.java
(closed): New member variable. (closed): New member variable.
(close): Use closed variable. (close): Use closed variable.
......
...@@ -4075,43 +4075,59 @@ p * <li>the set of backward traversal keys ...@@ -4075,43 +4075,59 @@ p * <li>the set of backward traversal keys
*/ */
void dispatchEventImpl(AWTEvent e) void dispatchEventImpl(AWTEvent e)
{ {
// Make use of event id's in order to avoid multiple instanceof tests. if (eventTypeEnabled (e.id))
if (e.id <= ComponentEvent.COMPONENT_LAST
&& e.id >= ComponentEvent.COMPONENT_FIRST
&& (componentListener != null
|| (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0))
processEvent(e); processEvent(e);
else if (e.id <= KeyEvent.KEY_LAST }
&& e.id >= KeyEvent.KEY_FIRST
&& (keyListener != null /**
|| (eventMask & AWTEvent.KEY_EVENT_MASK) != 0)) * Tells wether or not an event type is enabled.
processEvent(e); */
else if (e.id <= MouseEvent.MOUSE_LAST boolean eventTypeEnabled (int type)
&& e.id >= MouseEvent.MOUSE_FIRST {
&& (mouseListener != null if (type > AWTEvent.RESERVED_ID_MAX)
return true;
switch (type)
{
case ComponentEvent.COMPONENT_HIDDEN:
case ComponentEvent.COMPONENT_MOVED:
case ComponentEvent.COMPONENT_RESIZED:
case ComponentEvent.COMPONENT_SHOWN:
return (componentListener != null
|| (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0);
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
case KeyEvent.KEY_TYPED:
return (keyListener != null
|| (eventMask & AWTEvent.KEY_EVENT_MASK) != 0);
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
return (mouseListener != null
|| mouseMotionListener != null || mouseMotionListener != null
|| (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0)) || (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0);
processEvent(e);
else if (e.id <= FocusEvent.FOCUS_LAST case FocusEvent.FOCUS_GAINED:
&& e.id >= FocusEvent.FOCUS_FIRST case FocusEvent.FOCUS_LOST:
&& (focusListener != null return (focusListener != null
|| (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0)) || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0);
processEvent(e);
else if (e.id <= InputMethodEvent.INPUT_METHOD_LAST case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
&& e.id >= InputMethodEvent.INPUT_METHOD_FIRST case InputMethodEvent.CARET_POSITION_CHANGED:
&& (inputMethodListener != null return (inputMethodListener != null
|| (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0)) || (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0);
processEvent(e);
else if (e.id <= HierarchyEvent.HIERARCHY_LAST case PaintEvent.PAINT:
&& e.id >= HierarchyEvent.HIERARCHY_FIRST case PaintEvent.UPDATE:
&& (hierarchyListener != null return (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0;
|| hierarchyBoundsListener != null
|| (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0)) default:
processEvent(e); return false;
else if (e.id <= PaintEvent.PAINT_LAST }
&& e.id >= PaintEvent.PAINT_FIRST
&& (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0)
processEvent(e);
} }
/** /**
......
...@@ -45,6 +45,7 @@ import java.awt.peer.ComponentPeer; ...@@ -45,6 +45,7 @@ import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer; import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer; import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.Serializable; import java.io.Serializable;
...@@ -89,6 +90,7 @@ public class Container extends Component ...@@ -89,6 +90,7 @@ public class Container extends Component
/* Anything else is non-serializable, and should be declared "transient". */ /* Anything else is non-serializable, and should be declared "transient". */
transient ContainerListener containerListener; transient ContainerListener containerListener;
transient PropertyChangeSupport changeSupport;
/** /**
* Default constructor for subclasses. * Default constructor for subclasses.
...@@ -1125,12 +1127,27 @@ public class Container extends Component ...@@ -1125,12 +1127,27 @@ public class Container extends Component
throw new NullPointerException (); throw new NullPointerException ();
} }
public void addPropertyChangeListener(PropertyChangeListener l) public void addPropertyChangeListener (PropertyChangeListener listener)
{ {
if (listener == null)
return;
if (changeSupport == null)
changeSupport = new PropertyChangeSupport (this);
changeSupport.addPropertyChangeListener (listener);
} }
public void addPropertyChangeListener(String name, PropertyChangeListener l) public void addPropertyChangeListener (String name,
PropertyChangeListener listener)
{ {
if (listener == null)
return;
if (changeSupport == null)
changeSupport = new PropertyChangeSupport (this);
changeSupport.addPropertyChangeListener (name, listener);
} }
// Hidden helper methods. // Hidden helper methods.
......
...@@ -41,11 +41,15 @@ package java.awt; ...@@ -41,11 +41,15 @@ package java.awt;
import java.io.Serializable; import java.io.Serializable;
/** /**
* STUB CLASS ONLY * @author Michael Koch
* @since 1.4
*/ */
public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
implements Serializable implements Serializable
{ {
/**
* Compatible to JDK 1.4+
*/
static final long serialVersionUID = 486933713763926351L; static final long serialVersionUID = 486933713763926351L;
private boolean implicitDownCycleTraversal = true; private boolean implicitDownCycleTraversal = true;
...@@ -55,31 +59,77 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy ...@@ -55,31 +59,77 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
*/ */
public ContainerOrderFocusTraversalPolicy() public ContainerOrderFocusTraversalPolicy()
{ {
throw new Error("not implemented"); // Nothing to do here
} }
/**
* Returns the Component that should receive the focus after current.
* root must be a focus cycle root of current.
*
* @exception IllegalArgumentException If root is not a focus cycle
* root of current, or if either root or current is null.
*/
public Component getComponentAfter(Container root, Component current) public Component getComponentAfter(Container root, Component current)
{ {
if (root == null
|| current == null)
throw new IllegalArgumentException ();
return null; return null;
} }
/**
* Returns the Component that should receive the focus before current.
* root must be a focus cycle root of current.
*
* @exception IllegalArgumentException If root is not a focus cycle
* root of current, or if either root or current is null.
*/
public Component getComponentBefore(Container root, Component current) public Component getComponentBefore(Container root, Component current)
{ {
if (root == null
|| current == null)
throw new IllegalArgumentException ();
return null; return null;
} }
/**
* Returns the first Component of root that should receive the focus.
*
* @exception IllegalArgumentException If root is null.
*/
public Component getFirstComponent(Container root) public Component getFirstComponent(Container root)
{ {
if (root == null)
throw new IllegalArgumentException ();
return null; return null;
} }
/**
* Returns the last Component of root that should receive the focus.
*
* @exception IllegalArgumentException If root is null.
*/
public Component getLastComponent(Container root) public Component getLastComponent(Container root)
{ {
if (root == null)
throw new IllegalArgumentException ();
return null; return null;
} }
/**
* Returns the default Component of root that should receive the focus.
*
* @exception IllegalArgumentException If root is null.
*/
public Component getDefaultComponent(Container root) public Component getDefaultComponent(Container root)
{ {
if (root == null)
throw new IllegalArgumentException ();
return null; return null;
} }
......
...@@ -116,7 +116,8 @@ public class EventQueue ...@@ -116,7 +116,8 @@ public class EventQueue
if (next_in != next_out) if (next_in != next_out)
return queue[next_out]; return queue[next_out];
else return null; else
return null;
} }
/** /**
...@@ -247,7 +248,9 @@ public class EventQueue ...@@ -247,7 +248,9 @@ public class EventQueue
throw new InvocationTargetException(exception); throw new InvocationTargetException(exception);
} }
/** @since JDK1.2 */ /**
* @since 1.2
*/
public static void invokeLater(Runnable runnable) public static void invokeLater(Runnable runnable)
{ {
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
...@@ -264,7 +267,8 @@ public class EventQueue ...@@ -264,7 +267,8 @@ public class EventQueue
return (Thread.currentThread() == eq.dispatchThread); return (Thread.currentThread() == eq.dispatchThread);
} }
/** Allows a custom EventQueue implementation to replace this one. /**
* Allows a custom EventQueue implementation to replace this one.
* All pending events are transferred to the new queue. Calls to postEvent, * All pending events are transferred to the new queue. Calls to postEvent,
* getNextEvent, and peekEvent are forwarded to the pushed queue until it * getNextEvent, and peekEvent are forwarded to the pushed queue until it
* is removed with a pop(). * is removed with a pop().
...@@ -273,6 +277,9 @@ public class EventQueue ...@@ -273,6 +277,9 @@ public class EventQueue
*/ */
public synchronized void push(EventQueue newEventQueue) public synchronized void push(EventQueue newEventQueue)
{ {
if (newEventQueue == null)
throw new NullPointerException ();
int i = next_out; int i = next_out;
while (i != next_in) while (i != next_in)
{ {
......
...@@ -38,6 +38,7 @@ exception statement from your version. */ ...@@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt; package java.awt;
import java.awt.event.MouseEvent;
import java.awt.peer.ScrollPanePeer; import java.awt.peer.ScrollPanePeer;
import java.awt.peer.ContainerPeer; import java.awt.peer.ContainerPeer;
import java.awt.peer.ComponentPeer; import java.awt.peer.ComponentPeer;
...@@ -105,6 +106,8 @@ private int scrollbarDisplayPolicy; ...@@ -105,6 +106,8 @@ private int scrollbarDisplayPolicy;
// Current scroll position // Current scroll position
private Point scrollPosition = new Point(0, 0); private Point scrollPosition = new Point(0, 0);
private boolean wheelScrollingEnabled;
/*************************************************************************/ /*************************************************************************/
/* /*
...@@ -153,6 +156,8 @@ ScrollPane(int scrollbarDisplayPolicy) ...@@ -153,6 +156,8 @@ ScrollPane(int scrollbarDisplayPolicy)
hAdjustable = new ScrollPaneAdjustable(Scrollbar.HORIZONTAL); hAdjustable = new ScrollPaneAdjustable(Scrollbar.HORIZONTAL);
vAdjustable = new ScrollPaneAdjustable(Scrollbar.VERTICAL); vAdjustable = new ScrollPaneAdjustable(Scrollbar.VERTICAL);
} }
wheelScrollingEnabled = true;
} }
/*************************************************************************/ /*************************************************************************/
...@@ -470,5 +475,37 @@ paramString() ...@@ -470,5 +475,37 @@ paramString()
return(getClass().getName()); return(getClass().getName());
} }
/**
* Tells wether or not an event is enabled.
*
* @since 1.4
*/
public boolean eventTypeEnabled (int type)
{
if (type == MouseEvent.MOUSE_WHEEL)
return wheelScrollingEnabled;
return super.eventTypeEnabled (type);
}
/**
* Tells wether or not wheel scrolling is enabled.
*
* @since 1.4
*/
public boolean isWheelScrollingEnabled ()
{
return wheelScrollingEnabled;
}
/**
* Enables/disables wheel scrolling.
*
* @since 1.4
*/
public void setWheelScrollingEnabled (boolean enable)
{
wheelScrollingEnabled = enable;
}
} // class ScrollPane } // class ScrollPane
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment