|
From: <ls...@us...> - 2007-01-31 21:51:51
|
Revision: 3100
http://jnode.svn.sourceforge.net/jnode/?rev=3100&view=rev
Author: lsantha
Date: 2007-01-31 13:51:44 -0800 (Wed, 31 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java
trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java
trunk/core/src/classpath/java/java/awt/TextArea.java
trunk/core/src/classpath/java/java/awt/TextComponent.java
trunk/core/src/classpath/java/java/awt/TextField.java
trunk/core/src/classpath/java/java/awt/Toolkit.java
Modified: trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -256,6 +256,95 @@
return false;
}
+ /**
+ * Handles FOCUS_GAINED events in {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ */
+ private boolean handleFocusGained(FocusEvent fe)
+ {
+ Component target = fe.getComponent ();
+
+ // If old focus owner != new focus owner, notify old focus
+ // owner that it has lost focus.
+ Component oldFocusOwner = getGlobalFocusOwner();
+ if (oldFocusOwner != null && oldFocusOwner != target)
+ {
+ FocusEvent lost = new FocusEvent(oldFocusOwner,
+ FocusEvent.FOCUS_LOST,
+ fe.isTemporary(), target);
+ oldFocusOwner.dispatchEvent(lost);
+ }
+
+ setGlobalFocusOwner (target);
+ if (target != getGlobalFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner (target);
+ if (target != getGlobalPermanentFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ redispatchEvent(target, fe);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Handles FOCUS_LOST events for {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ *
+ * @return if the event has been handled
+ */
+ private boolean handleFocusLost(FocusEvent fe)
+ {
+ Component currentFocus = getGlobalFocusOwner();
+ if (currentFocus != fe.getOppositeComponent())
+ {
+ setGlobalFocusOwner(null);
+ if (getGlobalFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to restore
+ // the focus.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner(null);
+ if (getGlobalPermanentFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to
+ // restore the focus.
+ }
+ else
+ {
+ fe.setSource(currentFocus);
+ redispatchEvent(currentFocus, fe);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
private boolean enqueueKeyEvent (KeyEvent e)
{
Iterator i = delayRequests.iterator ();
Modified: trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -561,7 +561,9 @@
* @see #UP_CYCLE_TRAVERSAL_KEYS
* @see #DOWN_CYCLE_TRAVERSAL_KEYS
*/
- public void setDefaultFocusTraversalKeys (int id, Set keystrokes)
+ public void setDefaultFocusTraversalKeys (int id,
+ Set<? extends AWTKeyStroke>
+ keystrokes)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
@@ -633,7 +635,7 @@
* @see #UP_CYCLE_TRAVERSAL_KEYS
* @see #DOWN_CYCLE_TRAVERSAL_KEYS
*/
- public Set getDefaultFocusTraversalKeys (int id)
+ public Set<AWTKeyStroke> getDefaultFocusTraversalKeys (int id)
{
if (id < FORWARD_TRAVERSAL_KEYS || id > DOWN_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException ();
@@ -995,9 +997,9 @@
* @return A list of explicitly registered key event dispatchers.
* @see KeyboardFocusManager#addKeyEventDispatcher(java.awt.KeyEventDispatcher)
*/
- protected List getKeyEventDispatchers ()
+ protected List<KeyEventDispatcher> getKeyEventDispatchers ()
{
- return (List) keyEventDispatchers.clone ();
+ return (List<KeyEventDispatcher>) keyEventDispatchers.clone ();
}
/**
@@ -1052,9 +1054,9 @@
* @return A list of explicitly registered key event post processors.
* @see KeyboardFocusManager#addKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
*/
- protected List getKeyEventPostProcessors ()
+ protected List<KeyEventPostProcessor> getKeyEventPostProcessors ()
{
- return (List) keyEventPostProcessors.clone ();
+ return (List<KeyEventPostProcessor>) keyEventPostProcessors.clone ();
}
/**
@@ -1436,4 +1438,48 @@
}
}
}
+
+
+ /**
+ * Maps focus requests from heavyweight to lightweight components.
+ */
+ private static HashMap focusRequests = new HashMap();
+
+ /**
+ * Retargets focus events that come from the peer (which only know about
+ * heavyweight components) to go to the correct lightweight component
+ * if appropriate.
+ *
+ * @param ev the event to check
+ *
+ * @return the retargetted event
+ */
+ static AWTEvent retargetFocusEvent(AWTEvent ev)
+ {
+ if (ev instanceof FocusEvent)
+ {
+ FocusEvent fe = (FocusEvent) ev;
+ Component target = fe.getComponent();
+ if (focusRequests.containsKey(target))
+ {
+ Component lightweight = (Component) focusRequests.get(target);
+ ev = new FocusEvent(lightweight, fe.id, fe.isTemporary());
+ focusRequests.remove(target);
}
+ }
+ return ev;
+ }
+
+ /**
+ * Adds a lightweight focus request for a heavyweight component.
+ *
+ * @param heavyweight the heavyweight from which we will receive a focus
+ * event soon
+ * @param lightweight the lightweight that ultimately receives the request
+ */
+ static void addLightweightFocusRequest(Component heavyweight,
+ Component lightweight)
+ {
+ focusRequests.put(heavyweight, lightweight);
+ }
+}
Modified: trunk/core/src/classpath/java/java/awt/TextArea.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/TextArea.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/TextArea.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -125,9 +125,11 @@
* the specified text. Conceptually the <code>TextArea</code> has 0
* rows and 0 columns but its initial bounds are defined by its peer
* or by the container in which it is packed. Both horizontal and
- * veritcal scrollbars will be displayed.
+ * veritcal scrollbars will be displayed. The TextArea initially contains
+ * the specified text. If text specified as <code>null<code>, it will
+ * be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
*
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
@@ -156,9 +158,10 @@
* Initialize a new instance of <code>TextArea</code> that can
* display the specified number of rows and columns of text, without
* the need to scroll. The TextArea initially contains the
- * specified text.
+ * specified text. If text specified as <code>null<code>, it will
+ * be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
*
@@ -174,9 +177,10 @@
* contains the specified text. The TextArea can display the
* specified number of rows and columns of text, without the need to
* scroll. This constructor allows specification of the scroll bar
- * display policy.
+ * display policy. The TextArea initially contains the specified text.
+ * If text specified as <code>null<code>, it will be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
* @param scrollbarVisibility The scroll bar display policy. One of
@@ -192,17 +196,19 @@
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
- if (rows < 0 || columns < 0)
- throw new IllegalArgumentException ("Bad row or column value");
+ if (rows < 0)
+ this.rows = 0;
+ else
+ this.rows = rows;
- if (scrollbarVisibility != SCROLLBARS_BOTH
- && scrollbarVisibility != SCROLLBARS_VERTICAL_ONLY
- && scrollbarVisibility != SCROLLBARS_HORIZONTAL_ONLY
- && scrollbarVisibility != SCROLLBARS_NONE)
- throw new IllegalArgumentException ("Bad scrollbar visibility value");
+ if (columns < 0)
+ this.columns = 0;
+ else
+ this.columns = columns;
- this.rows = rows;
- this.columns = columns;
+ if (scrollbarVisibility < 0 || scrollbarVisibility > 4)
+ this.scrollbarVisibility = SCROLLBARS_BOTH;
+ else
this.scrollbarVisibility = scrollbarVisibility;
// TextAreas need to receive tab key events so we override the
@@ -278,11 +284,7 @@
}
/**
- * Retrieve the minimum size for this text area, considering the
- * text area's current row and column values. A text area's minimum
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the minimum size for this text area.
*
* @return The minimum size for this text field.
*/
@@ -292,11 +294,8 @@
}
/**
- * Retrieve the minimum size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's minimum size depends on the number of rows and columns of
- * text it would prefer to display, and on the size of the font in
- * which the text would be displayed.
+ * Retrieve the minimum size for this text area. If the minimum
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the minimum size
* calculation.
@@ -311,11 +310,7 @@
}
/**
- * Retrieve the minimum size for this text area, considering the
- * text area's current row and column values. A text area's minimum
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the minimum size for this text area.
*
* @return The minimum size for this text area.
*
@@ -328,11 +323,8 @@
}
/**
- * Retrieve the minimum size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's minimum size depends on the number of rows and columns of
- * text it would prefer to display, and on the size of the font in
- * which the text would be displayed.
+ * Retrieve the minimum size for this text area. If the minimum
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the minimum size
* calculation.
@@ -346,21 +338,18 @@
*/
public Dimension minimumSize (int rows, int columns)
{
+ if (isMinimumSizeSet())
+ return new Dimension(minSize);
+
TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
- // Sun returns Dimension (0,0) in this case.
if (peer == null)
- return new Dimension (0, 0);
+ return new Dimension (getWidth(), getHeight());
return peer.getMinimumSize (rows, columns);
}
/**
- * Retrieve the preferred size for this text area, considering the
- * text area's current row and column values. A text area's preferred
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the preferred size for this text area.
*
* @return The preferred size for this text field.
*/
@@ -370,11 +359,8 @@
}
/**
- * Retrieve the preferred size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's preferred size depends on the number of rows and columns
- * of text it would prefer to display, and on the size of the font
- * in which the text would be displayed.
+ * Retrieve the preferred size for this text area. If the preferred
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the preferred size
* calculation.
@@ -389,11 +375,7 @@
}
/**
- * Retrieve the preferred size for this text area, considering the
- * text area's current row and column values. A text area's preferred
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the preferred size for this text area.
*
* @return The preferred size for this text field.
*
@@ -406,11 +388,8 @@
}
/**
- * Retrieve the preferred size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's preferred size depends on the number of rows and columns
- * of text it would prefer to display, and on the size of the font
- * in which the text would be displayed.
+ * Retrieve the preferred size for this text area. If the preferred
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the preferred size
* calculation.
@@ -424,11 +403,12 @@
*/
public Dimension preferredSize (int rows, int columns)
{
+ if (isPreferredSizeSet())
+ return new Dimension(prefSize);
+
TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
- // Sun returns Dimension (0,0) in this case.
if (peer == null)
- return new Dimension (0, 0);
+ return new Dimension (getWidth(), getHeight());
return peer.getPreferredSize (rows, columns);
}
@@ -478,6 +458,8 @@
if (peer != null)
peer.insert (str, peer.getText().length ());
+ else
+ setText(getText() + str);
}
/**
@@ -504,11 +486,20 @@
*/
public void insertText (String str, int pos)
{
+ String tmp1 = null;
+ String tmp2 = null;
+
TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer != null)
peer.insert (str, pos);
+ else
+ {
+ tmp1 = getText().substring(0, pos);
+ tmp2 = getText().substring(pos, getText().length());
+ setText(tmp1 + str + tmp2);
}
+ }
/**
* Replace a range of characters with the specified text. The
@@ -544,11 +535,20 @@
*/
public void replaceText (String str, int start, int end)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
+ String tmp1 = null;
+ String tmp2 = null;
+ TextAreaPeer peer = (TextAreaPeer) getPeer();
+
if (peer != null)
- peer.replaceRange (str, start, end);
+ peer.replaceRange(str, start, end);
+ else
+ {
+ tmp1 = getText().substring(0, start);
+ tmp2 = getText().substring(end, getText().length());
+ setText(tmp1 + str + tmp2);
}
+ }
/**
* Retrieve a debugging string for this text area.
Modified: trunk/core/src/classpath/java/java/awt/TextComponent.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/TextComponent.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/TextComponent.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -1,5 +1,5 @@
/* TextComponent.java -- Widgets for entering text
- Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2003, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,45 +63,36 @@
implements Serializable, Accessible
{
-/*
- * Static Variables
- */
+ private static final long serialVersionUID = -2214773872412987419L;
-// Constant for serialization
-private static final long serialVersionUID = -2214773872412987419L;
-
-/*
- * Instance Variables
- */
-
-/**
+ /**
* @serial Indicates whether or not this component is editable.
* This is package-private to avoid an accessor method.
*/
-boolean editable;
+ boolean editable;
-/**
+ /**
* @serial The starting position of the selected text region.
* This is package-private to avoid an accessor method.
*/
-int selectionStart;
+ int selectionStart;
-/**
+ /**
* @serial The ending position of the selected text region.
* This is package-private to avoid an accessor method.
*/
-int selectionEnd;
+ int selectionEnd;
-/**
+ /**
* @serial The text in the component
* This is package-private to avoid an accessor method.
*/
-String text;
+ String text;
-/**
+ /**
* A list of listeners that will receive events from this object.
*/
-protected transient TextListener textListener;
+ protected transient TextListener textListener;
protected class AccessibleAWTTextComponent
extends AccessibleAWTComponent
@@ -318,146 +309,121 @@
}
-/*************************************************************************/
-/*
- * Constructors
- */
-
-TextComponent(String text)
-{
+ TextComponent(String text)
+ {
+ if (text == null)
+ this.text = "";
+ else
this.text = text;
+
this.editable = true;
-}
+ }
-/*************************************************************************/
-/*
- * Instance Methods
- */
-
-/**
+ /**
* Returns the text in this component
*
* @return The text in this component.
*/
-public synchronized String
-getText()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized String getText()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
text = tcp.getText();
return(text);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the text in this component to the specified string.
*
* @param text The new text for this component.
*/
-public synchronized void
-setText(String text)
-{
+ public synchronized void setText(String text)
+ {
if (text == null)
text = "";
this.text = text;
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.setText(text);
setCaretPosition(0);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns a string that contains the text that is currently selected.
*
* @return The currently selected text region.
*/
-public synchronized String
-getSelectedText()
-{
+ public synchronized String getSelectedText()
+ {
String alltext = getText();
int start = getSelectionStart();
int end = getSelectionEnd();
return(alltext.substring(start, end));
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the starting position of the selected text region.
* If the text is not selected then caret position is returned.
*
* @return The starting position of the selected text region.
*/
-public synchronized int
-getSelectionStart()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized int getSelectionStart()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
selectionStart = tcp.getSelectionStart();
return(selectionStart);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the starting position of the selected region to the
* specified value. If the specified value is out of range, then it
* will be silently changed to the nearest legal value.
*
* @param selectionStart The new start position for selected text.
*/
-public synchronized void
-setSelectionStart(int selectionStart)
-{
- select(selectionStart, getSelectionEnd());
-}
+ public synchronized void setSelectionStart(int selectionStart)
+ {
+ select(selectionStart,
+ (getSelectionEnd() < selectionStart)
+ ? selectionStart : getSelectionEnd());
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the ending position of the selected text region.
* If the text is not selected, then caret position is returned
*
* @return The ending position of the selected text region.
*/
-public synchronized int
-getSelectionEnd()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized int getSelectionEnd()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
selectionEnd = tcp.getSelectionEnd();
return(selectionEnd);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the ending position of the selected region to the
* specified value. If the specified value is out of range, then it
* will be silently changed to the nearest legal value.
*
* @param selectionEnd The new start position for selected text.
*/
-public synchronized void
-setSelectionEnd(int selectionEnd)
-{
+ public synchronized void setSelectionEnd(int selectionEnd)
+ {
select(getSelectionStart(), selectionEnd);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* This method sets the selected text range to the text between the
* specified start and end positions. Illegal values for these
* positions are silently fixed.
@@ -465,9 +431,8 @@
* @param selectionStart The new start position for the selected text.
* @param selectionEnd The new end position for the selected text.
*/
-public synchronized void
-select(int selectionStart, int selectionEnd)
-{
+ public synchronized void select(int selectionStart, int selectionEnd)
+ {
if (selectionStart < 0)
selectionStart = 0;
@@ -483,42 +448,34 @@
this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd;
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.select(selectionStart, selectionEnd);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Selects all of the text in the component.
*/
-public synchronized void
-selectAll()
-{
+ public synchronized void selectAll()
+ {
select(0, getText().length());
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the current caret position in the text.
*
* @return The caret position in the text.
*/
-public synchronized int
-getCaretPosition()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized int getCaretPosition()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
return(tcp.getCaretPosition());
else
return(0);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the caret position to the specified value.
*
* @param caretPosition The new caret position.
@@ -528,111 +485,90 @@
*
* @since 1.1
*/
-public synchronized void
-setCaretPosition(int caretPosition)
-{
+ public synchronized void setCaretPosition(int caretPosition)
+ {
if (caretPosition < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException();
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.setCaretPosition(caretPosition);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Tests whether or not this component's text can be edited.
*
* @return <code>true</code> if the text can be edited, <code>false</code>
* otherwise.
*/
-public boolean
-isEditable()
-{
+ public boolean isEditable()
+ {
return(editable);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets whether or not this component's text can be edited.
*
* @param editable <code>true</code> to enable editing of the text,
* <code>false</code> to disable it.
*/
-public synchronized void
-setEditable(boolean editable)
-{
+ public synchronized void setEditable(boolean editable)
+ {
this.editable = editable;
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.setEditable(editable);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Notifies the component that it should destroy its native peer.
*/
-public void
-removeNotify()
-{
+ public void removeNotify()
+ {
super.removeNotify();
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Adds a new listener to the list of text listeners for this
* component.
*
* @param listener The listener to be added.
*/
-public synchronized void
-addTextListener(TextListener listener)
-{
+ public synchronized void addTextListener(TextListener listener)
+ {
textListener = AWTEventMulticaster.add(textListener, listener);
enableEvents(AWTEvent.TEXT_EVENT_MASK);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Removes the specified listener from the list of listeners
* for this component.
*
* @param listener The listener to remove.
*/
-public synchronized void
-removeTextListener(TextListener listener)
-{
+ public synchronized void removeTextListener(TextListener listener)
+ {
textListener = AWTEventMulticaster.remove(textListener, listener);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Processes the specified event for this component. Text events are
* processed by calling the <code>processTextEvent()</code> method.
* All other events are passed to the superclass method.
*
* @param event The event to process.
*/
-protected void
-processEvent(AWTEvent event)
-{
+ protected void processEvent(AWTEvent event)
+ {
if (event instanceof TextEvent)
processTextEvent((TextEvent)event);
else
super.processEvent(event);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Processes the specified text event by dispatching it to any listeners
* that are registered. Note that this method will only be called
* if text event's are enabled. This will be true if there are any
@@ -641,16 +577,14 @@
*
* @param event The text event to process.
*/
-protected void
-processTextEvent(TextEvent event)
-{
+ protected void processTextEvent(TextEvent event)
+ {
if (textListener != null)
textListener.textValueChanged(event);
-}
+ }
-void
-dispatchEventImpl(AWTEvent e)
-{
+ void dispatchEventImpl(AWTEvent e)
+ {
if (e.id <= TextEvent.TEXT_LAST
&& e.id >= TextEvent.TEXT_FIRST
&& (textListener != null
@@ -658,20 +592,17 @@
processEvent(e);
else
super.dispatchEventImpl(e);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns a debugging string.
*
* @return A debugging string.
*/
-protected String
-paramString()
-{
+ protected String paramString()
+ {
return(getClass().getName() + "(text=" + getText() + ")");
-}
+ }
/**
* Returns an array of all the objects currently registered as FooListeners
@@ -681,20 +612,20 @@
* @exception ClassCastException If listenerType doesn't specify a class or
* interface that implements java.util.EventListener.
*/
- public EventListener[] getListeners (Class listenerType)
+ public <T extends EventListener> T[] getListeners(Class<T> listenerType)
{
if (listenerType == TextListener.class)
- return AWTEventMulticaster.getListeners (textListener, listenerType);
+ return AWTEventMulticaster.getListeners(textListener, listenerType);
- return super.getListeners (listenerType);
+ return super.getListeners(listenerType);
}
/**
* Returns all text listeners registered to this object.
*/
- public TextListener[] getTextListeners ()
+ public TextListener[] getTextListeners()
{
- return (TextListener[]) getListeners (TextListener.class);
+ return (TextListener[]) getListeners(TextListener.class);
}
/**
@@ -712,30 +643,35 @@
}
- /*******************************/
// Provide AccessibleAWTTextComponent access to several peer functions that
// aren't publicly exposed. This is package-private to avoid an accessor
// method.
- synchronized int
- getIndexAtPoint(Point p)
+ synchronized int getIndexAtPoint(Point p)
{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
return tcp.getIndexAtPoint(p.x, p.y);
return -1;
}
- synchronized Rectangle
- getCharacterBounds(int i)
+ synchronized Rectangle getCharacterBounds(int i)
{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
return tcp.getCharacterBounds(i);
return null;
}
-
+ /**
+ * All old mouse events for this component should
+ * be ignored.
+ *
+ * @return true to ignore all old mouse events.
+ */
+ static boolean ignoreOldMouseEvents()
+ {
+ return true;
+ }
-
} // class TextComponent
Modified: trunk/core/src/classpath/java/java/awt/TextField.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/TextField.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/TextField.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -1,5 +1,5 @@
/* TextField.java -- A one line text entry field
- Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,53 +55,40 @@
public class TextField extends TextComponent
{
-/*
- * Static Variables
+ /**
+ * The number used to generate the name returned by getName.
*/
+ private static transient long next_textfield_number;
-// Serialization constant
-private static final long serialVersionUID = -2966288784432217853L;
-/*************************************************************************/
+ private static final long serialVersionUID = -2966288784432217853L;
-/*
- * Instance Variables
- */
-/**
+ /**
* @serial The number of columns in the text entry field.
*/
-private int columns;
+ private int columns;
-/**
+ /**
* @serial The character that is echoed when doing protected input
*/
-private char echoChar;
+ private char echoChar;
-// List of registered ActionListener's for this object.
-private ActionListener action_listeners;
+ // List of registered ActionListener's for this object.
+ private ActionListener action_listeners;
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
+ /**
* Initializes a new instance of <code>TextField</code> that is empty
* and has one column.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
*/
-public
-TextField()
-{
- this("", 1);
-}
+ public TextField()
+ {
+ this("", 0);
+ }
-/*************************************************************************/
-
-/**
+ /**
* Initializes a new instance of <code>TextField</code> containing
* the specified text. The number of columns will be equal to the
* length of the text string.
@@ -110,15 +97,12 @@
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
*/
-public
-TextField(String text)
-{
- this(text, text.length());
-}
+ public TextField(String text)
+ {
+ this(text, (text == null) ? 0 : text.length());
+ }
-/*************************************************************************/
-
-/**
+ /**
* Initializes a new instance of <code>TextField</code> that is empty
* and has the specified number of columns.
*
@@ -126,15 +110,12 @@
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
*/
-public
-TextField(int columns)
-{
+ public TextField(int columns)
+ {
this("", columns);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Initializes a new instance of <code>TextField</code> with the
* specified text and number of columns.
*
@@ -143,84 +124,69 @@
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
*/
-public
-TextField(String text, int columns)
-{
+ public TextField(String text, int columns)
+ {
super(text);
+
+ if (columns < 0)
+ this.columns = 0;
+ else
this.columns = columns;
if (GraphicsEnvironment.isHeadless())
throw new HeadlessException ();
-}
+ }
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
+ /**
* Returns the number of columns in the field.
*
* @return The number of columns in the field.
*/
-public int
-getColumns()
-{
+ public int getColumns()
+ {
return(columns);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the number of columns in this field to the specified value.
*
* @param columns The new number of columns in the field.
*
* @exception IllegalArgumentException If columns is less than zero.
*/
-public synchronized void
-setColumns(int columns)
-{
+ public synchronized void setColumns(int columns)
+ {
if (columns < 0)
throw new IllegalArgumentException("Value is less than zero: " +
columns);
this.columns = columns;
// FIXME: How to we communicate this to our peer?
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the character that is echoed to the screen when a text
* field is protected (such as when a password is being entered).
*
* @return The echo character for this text field.
*/
-public char
-getEchoChar()
-{
+ public char getEchoChar()
+ {
return(echoChar);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the character that is echoed when protected input such as
* a password is displayed.
*
* @param echoChar The new echo character.
*/
-public void
-setEchoChar(char echoChar)
-{
- setEchoCharacter (echoChar);
-}
+ public void setEchoChar(char echoChar)
+ {
+ setEchoCharacter(echoChar);
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the character that is echoed when protected input such as
* a password is displayed.
*
@@ -229,64 +195,52 @@
* @deprecated This method is deprecated in favor of
* <code>setEchoChar()</code>
*/
-public void
-setEchoCharacter(char echoChar)
-{
+ public void setEchoCharacter(char echoChar)
+ {
this.echoChar = echoChar;
TextFieldPeer peer = (TextFieldPeer) getPeer ();
if (peer != null)
peer.setEchoChar (echoChar);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Tests whether or not this text field has an echo character set
* so that characters the user type are not echoed to the screen.
*
* @return <code>true</code> if an echo character is set,
* <code>false</code> otherwise.
*/
-public boolean
-echoCharIsSet()
-{
+ public boolean echoCharIsSet()
+ {
if (echoChar == '\u0000')
return(false);
else
return(true);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the minimum size for this text field.
*
* @return The minimum size for this text field.
*/
-public Dimension
-getMinimumSize()
-{
+ public Dimension getMinimumSize()
+ {
return getMinimumSize (getColumns ());
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the minimum size of a text field with the specified number
* of columns.
*
* @param columns The number of columns to get the minimum size for.
*/
-public Dimension
-getMinimumSize(int columns)
-{
- return minimumSize (columns);
-}
+ public Dimension getMinimumSize(int columns)
+ {
+ return minimumSize(columns);
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the minimum size for this text field.
*
* @return The minimum size for this text field.
@@ -294,15 +248,12 @@
* @deprecated This method is deprecated in favor of
* <code>getMinimumSize()</code>.
*/
-public Dimension
-minimumSize()
-{
- return minimumSize (getColumns ());
-}
+ public Dimension minimumSize()
+ {
+ return minimumSize(getColumns ());
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the minimum size of a text field with the specified number
* of columns.
*
@@ -311,46 +262,40 @@
* @deprecated This method is deprecated in favor of
* <code>getMinimumSize(int)</code>.
*/
-public Dimension
-minimumSize(int columns)
-{
+ public Dimension minimumSize(int columns)
+ {
+ if (isMinimumSizeSet())
+ return new Dimension(minSize);
+
TextFieldPeer peer = (TextFieldPeer) getPeer ();
if (peer == null)
- return null; // FIXME: What do we do if there is no peer?
+ return new Dimension(getWidth(), getHeight());
return peer.getMinimumSize (columns);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the preferred size for this text field.
*
* @return The preferred size for this text field.
*/
-public Dimension
-getPreferredSize()
-{
- return getPreferredSize (getColumns ());
-}
+ public Dimension getPreferredSize()
+ {
+ return getPreferredSize(getColumns ());
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the preferred size of a text field with the specified number
* of columns.
*
* @param columns The number of columns to get the preferred size for.
*/
-public Dimension
-getPreferredSize(int columns)
-{
- return preferredSize (columns);
-}
+ public Dimension getPreferredSize(int columns)
+ {
+ return preferredSize(columns);
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the preferred size for this text field.
*
* @return The preferred size for this text field.
@@ -358,15 +303,12 @@
* @deprecated This method is deprecated in favor of
* <code>getPreferredSize()</code>.
*/
-public Dimension
-preferredSize()
-{
- return preferredSize (getColumns ());
-}
+ public Dimension preferredSize()
+ {
+ return preferredSize(getColumns ());
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the preferred size of a text field with the specified number
* of columns.
*
@@ -375,63 +317,55 @@
* @deprecated This method is deprecated in favor of
* <code>getPreferredSize(int)</code>.
*/
-public Dimension
-preferredSize(int columns)
-{
+ public Dimension preferredSize(int columns)
+ {
+ if (isPreferredSizeSet())
+ return new Dimension(prefSize);
+
TextFieldPeer peer = (TextFieldPeer) getPeer ();
if (peer == null)
- return new Dimension (0, 0);
+ return new Dimension (getWidth(), getHeight());
return peer.getPreferredSize (columns);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Notifies this object that it should create its native peer.
*/
-public void
-addNotify()
-{
+ public void addNotify()
+ {
if (getPeer() != null)
return;
setPeer((ComponentPeer)getToolkit().createTextField(this));
-}
+ super.addNotify();
+ }
-/*************************************************************************/
-
-/**
+ /**
* Addes a new listener to the list of action listeners for this
* object.
*
* @param listener The listener to add to the list.
*/
-public synchronized void
-addActionListener(ActionListener listener)
-{
+ public synchronized void addActionListener(ActionListener listener)
+ {
action_listeners = AWTEventMulticaster.add(action_listeners, listener);
enableEvents(AWTEvent.ACTION_EVENT_MASK);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Removes the specified listener from the list of action listeners
* for this object.
*
* @param listener The listener to remove from the list.
*/
-public synchronized void
-removeActionListener(ActionListener listener)
-{
+ public synchronized void removeActionListener(ActionListener listener)
+ {
action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Processes the specified event. If the event is an instance of
* <code>ActionEvent</code> then <code>processActionEvent()</code> is
* called to process it, otherwise the event is sent to the
@@ -439,18 +373,15 @@
*
* @param event The event to process.
*/
-protected void
-processEvent(AWTEvent event)
-{
+ protected void processEvent(AWTEvent event)
+ {
if (event instanceof ActionEvent)
processActionEvent((ActionEvent)event);
else
super.processEvent(event);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Processes an action event by calling any registered listeners.
* Note to subclasses: This method is not called unless action events
* are enabled on this object. This will be true if any listeners
@@ -459,16 +390,14 @@
*
* @param event The event to process.
*/
-protected void
-processActionEvent(ActionEvent event)
-{
+ protected void processActionEvent(ActionEvent event)
+ {
if (action_listeners != null)
action_listeners.actionPerformed(event);
-}
+ }
-void
-dispatchEventImpl(AWTEvent e)
-{
+ void dispatchEventImpl(AWTEvent e)
+ {
if (e.id <= ActionEvent.ACTION_LAST
&& e.id >= ActionEvent.ACTION_FIRST
&& (action_listeners != null
@@ -476,21 +405,18 @@
processEvent(e);
else
super.dispatchEventImpl(e);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns a debug string for this object.
*
* @return A debug string for this object.
*/
-protected String
-paramString()
-{
+ protected String paramString()
+ {
return(getClass().getName() + "(columns=" + getColumns() + ",echoChar=" +
getEchoChar());
-}
+ }
/**
* Returns an array of all the objects currently registered as FooListeners
@@ -502,7 +428,7 @@
*
* @since 1.3
*/
- public EventListener[] getListeners (Class listenerType)
+ public <T extends EventListener> T[] getListeners (Class<T> listenerType)
{
if (listenerType == ActionListener.class)
return AWTEventMulticaster.getListeners (action_listeners, listenerType);
@@ -521,6 +447,21 @@
return (ActionListener[]) getListeners (ActionListener.class);
}
+ /**
+ * Generate a unique name for this <code>TextField</code>.
+ *
+ * @return A unique name for this <code>TextField</code>.
+ */
+ String generateName()
+ {
+ return "textfield" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_textfield_number++;
+ }
+
protected class AccessibleAWTTextField extends AccessibleAWTTextComponent
{
private static final long serialVersionUID = 6219164359235943158L;
@@ -540,4 +481,4 @@
return new AccessibleAWTTextField();
}
-} // class TextField
+}
Modified: trunk/core/src/classpath/java/java/awt/Toolkit.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Toolkit.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/Toolkit.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -1,5 +1,5 @@
/* Toolkit.java -- AWT Toolkit superclass
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,10 @@
package java.awt;
+import gnu.classpath.SystemProperties;
+import gnu.java.awt.AWTUtilities;
import gnu.java.awt.peer.GLightweightPeer;
+import gnu.java.awt.peer.headless.HeadlessToolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.DragGestureEvent;
@@ -50,6 +53,7 @@
import java.awt.event.AWTEventListener;
import java.awt.event.AWTEventListenerProxy;
import java.awt.event.KeyEvent;
+import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
@@ -69,6 +73,7 @@
import java.awt.peer.MenuBarPeer;
import java.awt.peer.MenuItemPeer;
import java.awt.peer.MenuPeer;
+import java.awt.peer.MouseInfoPeer;
import java.awt.peer.PanelPeer;
import java.awt.peer.PopupMenuPeer;
import java.awt.peer.ScrollPanePeer;
@@ -76,13 +81,18 @@
import java.awt.peer.TextAreaPeer;
import java.awt.peer.TextFieldPeer;
import java.awt.peer.WindowPeer;
-import java.awt.peer.MouseInfoPeer;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.File;
+import java.io.FileInputStream;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
+import java.util.StringTokenizer;
/**
* The AWT system uses a set of native peer objects to implement its
@@ -113,7 +123,8 @@
/** The toolkit properties. */
private static Properties props = new Properties();
- protected final Map desktopProperties = new Properties();
+ protected final Map<String,Object> desktopProperties =
+ new Hashtable<String,Object>();
protected final PropertyChangeSupport desktopPropsSupport
= new PropertyChangeSupport(this);
@@ -541,11 +552,12 @@
*
* @throws AWTError If the toolkit cannot be loaded.
*/
- public static Toolkit getDefaultToolkit()
+ public static synchronized Toolkit getDefaultToolkit()
{
if (toolkit != null)
return toolkit;
- String toolkit_name = System.getProperty("awt.toolkit",
+
+ String toolkit_name = SystemProperties.getProperty("awt.toolkit",
default_toolkit_name);
try
{
@@ -559,6 +571,8 @@
throw new AWTError(toolkit_name + " is not a subclass of " +
"java.awt.Toolkit");
toolkit = (Toolkit) obj;
+
+ initAccessibility();
return toolkit;
}
catch (ThreadDeath death)
@@ -567,9 +581,19 @@
}
catch (Throwable t)
{
- AWTError e = new AWTError("Cannot load AWT toolkit: " + toolkit_name);
+ // Check for the headless property.
+ if (GraphicsEnvironment.isHeadless())
+ {
+ toolkit = new HeadlessToolkit();
+ return toolkit;
+ }
+ else
+ {
+ AWTError e = new AWTError("Cannot load AWT toolkit: "
+ + toolkit_name);
throw (AWTError) e.initCause(t);
- }
+ }
+ }
}
// @classpath-bugfix
@@ -711,6 +735,14 @@
public PrintJob getPrintJob(Frame frame, String title,
JobAttributes jobAttr, PageAttributes pageAttr)
{
+ // FIXME: it is possible this check may be removed
+ // if this method, when written, always delegates to
+ // getPrintJob(Frame, String, Properties).
+ SecurityManager sm;
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
return null;
}
@@ -775,12 +807,11 @@
*/
public boolean getLockingKeyState(int keyCode)
{
- if (keyCode != KeyEvent.VK_CAPS_LOCK
- && keyCode != KeyEvent.VK_NUM_LOCK
- && keyCode != KeyEvent.VK_SCROLL_LOCK)
- throw new IllegalArgumentException();
+ if (AWTUtilities.isValidKey(keyCode))
+ throw new UnsupportedOperationException
+ ("cannot get locking state of key code " + keyCode);
- throw new UnsupportedOperationException();
+ throw new IllegalArgumentException("invalid key code " + keyCode);
}
/**
@@ -959,8 +990,8 @@
/**
* @since 1.3
*/
- public DragGestureRecognizer
- createDragGestureRecognizer(Class recognizer, DragSource ds,
+ public <T extends DragGestureRecognizer> T
+ createDragGestureRecognizer(Class<T> recognizer, DragSource ds,
Component comp, int actions,
DragGestureListener l)
{
@@ -1247,5 +1278,140 @@
/**
* @since 1.3
*/
- public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight);
+ public abstract Map<TextAttribute,?>
+ mapInputMethodHighlight(InputMethodHighlight highlight);
+
+ /**
+ * Initializes the accessibility framework. In particular, this loads the
+ * properties javax.accessibility.screen_magnifier_present and
+ * javax.accessibility.screen_reader_present and loads
+ * the classes specified in javax.accessibility.assistive_technologies.
+ */
+ private static void initAccessibility()
+ {
+ AccessController.doPrivileged
+ (new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Properties props = new Properties();
+ String sep = File.separator;
+
+ // Try the user configuration.
+ try
+ {
+ File propsFile = new File(System.getProperty("user.home") + sep
+ + ".accessibility.properties");
+ FileInputStream in = new FileInputStream(propsFile);
+ props.load(in);
+ in.close();
+ }
+ catch (Exception ex)
+ {
+ // User configuration not present, ignore.
+ }
+
+ // Try the system configuration if there was no user configuration.
+ if (props.size() == 0)
+ {
+ try
+ {
+ File propsFile =
+ new File(System.getProperty("gnu.classpath.home.url")
+ + sep + "accessibility.properties");
+ FileInputStream in = new FileInputStream(propsFile);
+ props.load(in);
+ in.close();
+ }
+ catch (Exception ex)
+ {
+ // System configuration not present, ignore.
+ }
+ }
+
+ // Fetch the screen_magnifier_present property. Check systen properties
+ // first, then fallback to the configuration file.
+ String magPresent = SystemProperties.getProperty
+ ("javax.accessibility.screen_magnifier_present");
+ if (magPresent == null)
+ {
+ magPresent = props.getProperty("screen_magnifier_present");
+ if (magPresent != null)
+ {
+ SystemProperties.setProperty
+ ("javax.accessibility.screen_magnifier_present", magPresent);
+ }
+ }
+
+ // Fetch the screen_reader_present property. Check systen properties
+ // first, then fallback to the configuration file.
+ String readerPresent = SystemProperties.getProperty
+ ("javax.accessibility.screen_reader_present");
+ if (readerPresent == null)
+ {
+ readerPresent = props.getProperty("screen_reader_present");
+ if (readerPresent != null)
+ {
+ SystemProperties.setProperty
+ ("javax.accessibility.screen_reader_present", readerPresent);
+ }
+ }
+
+ // Fetch the list of classes to be loaded.
+ String classes = SystemProperties.getProperty
+ ("javax.accessibility.assistive_technologies");
+ if (classes == null)
+ {
+ classes = props.getProperty("assistive_technologies");
+ if (classes != null)
+ {
+ SystemProperties.setProperty
+ ("javax.accessibility.assistive_technologies", classes);
+ }
+ }
+
+ // Try to load the assisitive_technologies classes.
+ if (classes != null)
+ {
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ StringTokenizer tokenizer = new StringTokenizer(classes, ",");
+ while (tokenizer.hasMoreTokens())
+ {
+ String className = tokenizer.nextToken();
+ try
+ {
+ Class atClass = cl.loadClass(className);
+ atClass.newInstance();
+ }
+ catch (ClassNotFoundException ex)
+ {
+ AWTError err = new AWTError("Assistive Technology class not"
+ + " found: " + className);
+ err.initCause(ex);
+ throw err;
+ }
+ catch (InstantiationException ex)
+ {
+ AWTError err =
+ new AWTError("Assistive Technology class cannot be "
+ + "instantiated: " + className);
+ err.initCause(ex);
+ throw err;
+ }
+ catch (IllegalAccessException ex)
+ {
+ AWTError err =
+ new AWTError("Assistive Technology class cannot be "
+ + "accessed: " + className);
+ err.initCause(err);
+ throw err;
+ }
+ }
+ }
+ return null;
+ }
+ });
+
+ }
+
} // class Toolkit
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|