Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942
This commit is contained in:
parent
27079765d0
commit
8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
|
@ -39,6 +39,19 @@ exception statement from your version. */
|
|||
|
||||
package java.awt;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.InputMethodEvent;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.event.TextEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
|
@ -275,4 +288,94 @@ public abstract class AWTEvent extends EventObject
|
|||
{
|
||||
return consumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an event id to the appropriate event mask.
|
||||
*
|
||||
* @param id the event id
|
||||
*
|
||||
* @return the event mask for the specified id
|
||||
*/
|
||||
static long eventIdToMask(int id)
|
||||
{
|
||||
long mask = 0;
|
||||
switch (id)
|
||||
{
|
||||
case ActionEvent.ACTION_PERFORMED:
|
||||
mask = ACTION_EVENT_MASK;
|
||||
break;
|
||||
case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
|
||||
mask = ADJUSTMENT_EVENT_MASK;
|
||||
break;
|
||||
case ComponentEvent.COMPONENT_MOVED:
|
||||
case ComponentEvent.COMPONENT_RESIZED:
|
||||
case ComponentEvent.COMPONENT_SHOWN:
|
||||
case ComponentEvent.COMPONENT_HIDDEN:
|
||||
mask = COMPONENT_EVENT_MASK;
|
||||
break;
|
||||
case ContainerEvent.COMPONENT_ADDED:
|
||||
case ContainerEvent.COMPONENT_REMOVED:
|
||||
mask = CONTAINER_EVENT_MASK;
|
||||
break;
|
||||
case FocusEvent.FOCUS_GAINED:
|
||||
case FocusEvent.FOCUS_LOST:
|
||||
mask = FOCUS_EVENT_MASK;
|
||||
break;
|
||||
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
|
||||
case InputMethodEvent.CARET_POSITION_CHANGED:
|
||||
mask = INPUT_METHOD_EVENT_MASK;
|
||||
break;
|
||||
case InvocationEvent.INVOCATION_DEFAULT:
|
||||
mask = INVOCATION_EVENT_MASK;
|
||||
break;
|
||||
case ItemEvent.ITEM_STATE_CHANGED:
|
||||
mask = ITEM_EVENT_MASK;
|
||||
break;
|
||||
case KeyEvent.KEY_TYPED:
|
||||
case KeyEvent.KEY_PRESSED:
|
||||
case KeyEvent.KEY_RELEASED:
|
||||
mask = KEY_EVENT_MASK;
|
||||
break;
|
||||
case MouseEvent.MOUSE_CLICKED:
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
mask = MOUSE_EVENT_MASK;
|
||||
break;
|
||||
case MouseEvent.MOUSE_MOVED:
|
||||
case MouseEvent.MOUSE_ENTERED:
|
||||
case MouseEvent.MOUSE_EXITED:
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
mask = MOUSE_MOTION_EVENT_MASK;
|
||||
break;
|
||||
case MouseEvent.MOUSE_WHEEL:
|
||||
mask = MOUSE_WHEEL_EVENT_MASK;
|
||||
break;
|
||||
case PaintEvent.PAINT:
|
||||
case PaintEvent.UPDATE:
|
||||
mask = PAINT_EVENT_MASK;
|
||||
break;
|
||||
case TextEvent.TEXT_VALUE_CHANGED:
|
||||
mask = TEXT_EVENT_MASK;
|
||||
break;
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
mask = WINDOW_EVENT_MASK;
|
||||
break;
|
||||
case WindowEvent.WINDOW_GAINED_FOCUS:
|
||||
case WindowEvent.WINDOW_LOST_FOCUS:
|
||||
mask = WINDOW_FOCUS_EVENT_MASK;
|
||||
break;
|
||||
case WindowEvent.WINDOW_STATE_CHANGED:
|
||||
mask = WINDOW_STATE_EVENT_MASK;
|
||||
break;
|
||||
default:
|
||||
mask = 0;
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
} // class AWTEvent
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* BasicStroke.java --
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -41,38 +41,89 @@ package java.awt;
|
|||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* STUB CLASS ONLY
|
||||
* A general purpose {@link Stroke} implementation that can represent a wide
|
||||
* variety of line styles for use with subclasses of {@link Graphics2D}.
|
||||
* <p>
|
||||
* The line cap and join styles can be set using the options illustrated
|
||||
* here:
|
||||
* <p>
|
||||
* <img src="doc-files/capjoin.png" width="350" height="180"
|
||||
* alt="Illustration of line cap and join styles" />
|
||||
* <p>
|
||||
* A dash array can be used to specify lines with alternating opaque and
|
||||
* transparent sections.
|
||||
*/
|
||||
public class BasicStroke implements Stroke
|
||||
{
|
||||
/**
|
||||
* Indicates a mitered line join style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int JOIN_MITER = 0;
|
||||
|
||||
/**
|
||||
* Indicates a rounded line join style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int JOIN_ROUND = 1;
|
||||
|
||||
/**
|
||||
* Indicates a bevelled line join style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int JOIN_BEVEL = 2;
|
||||
|
||||
/**
|
||||
* Indicates a flat line cap style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int CAP_BUTT = 0;
|
||||
|
||||
/**
|
||||
* Indicates a rounded line cap style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int CAP_ROUND = 1;
|
||||
|
||||
/**
|
||||
* Indicates a square line cap style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int CAP_SQUARE = 2;
|
||||
|
||||
/** The stroke width. */
|
||||
private final float width;
|
||||
|
||||
/** The line cap style. */
|
||||
private final int cap;
|
||||
|
||||
/** The line join style. */
|
||||
private final int join;
|
||||
|
||||
/** The miter limit. */
|
||||
private final float limit;
|
||||
|
||||
/** The dash array. */
|
||||
private final float[] dash;
|
||||
|
||||
/** The dash phase. */
|
||||
private final float phase;
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given attributes.
|
||||
*
|
||||
* @param width May not be negative .
|
||||
* @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
||||
* @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
||||
* @param miterlimit the limit to trim the miter join. The miterlimit must be
|
||||
* @param width the line width (>= 0.0f).
|
||||
* @param cap the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
|
||||
* @param join the line join style (one of {@link #JOIN_ROUND},
|
||||
* {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
|
||||
* @param miterlimit the limit to trim the miter join. The miterlimit must be
|
||||
* greater than or equal to 1.0f.
|
||||
* @param dash The array representing the dashing pattern. There must be at
|
||||
* least one non-zero entry.
|
||||
* @param dashPhase is negative and dash is not null.
|
||||
*
|
||||
* @exception IllegalArgumentException If one input parameter doesn't meet
|
||||
* @throws IllegalArgumentException If one input parameter doesn't meet
|
||||
* its needs.
|
||||
*/
|
||||
public BasicStroke(float width, int cap, int join, float miterlimit,
|
||||
|
@ -122,15 +173,17 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given attributes.
|
||||
*
|
||||
* @param width The width of the BasicStroke. May not be negative .
|
||||
* @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
||||
* @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
||||
* @param width the line width (>= 0.0f).
|
||||
* @param cap the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
|
||||
* @param join the line join style (one of {@link #JOIN_ROUND},
|
||||
* {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
|
||||
* @param miterlimit the limit to trim the miter join. The miterlimit must be
|
||||
* greater than or equal to 1.0f.
|
||||
*
|
||||
* @exception IllegalArgumentException If one input parameter doesn't meet
|
||||
* @throws IllegalArgumentException If one input parameter doesn't meet
|
||||
* its needs.
|
||||
*/
|
||||
public BasicStroke(float width, int cap, int join, float miterlimit)
|
||||
|
@ -139,15 +192,17 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given attributes.
|
||||
* The miter limit defaults to <code>10.0</code>.
|
||||
*
|
||||
* @param width The width of the BasicStroke. May not be nehative.
|
||||
* @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
||||
* @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
||||
* @param width the line width (>= 0.0f).
|
||||
* @param cap the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
|
||||
* @param join the line join style (one of {@link #JOIN_ROUND},
|
||||
* {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
|
||||
*
|
||||
* @exception IllegalArgumentException If one input parameter doesn't meet
|
||||
* @throws IllegalArgumentException If one input parameter doesn't meet
|
||||
* its needs.
|
||||
* @exception IllegalArgumentException FIXME
|
||||
*/
|
||||
public BasicStroke(float width, int cap, int join)
|
||||
{
|
||||
|
@ -155,11 +210,17 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
*
|
||||
* @param width The width of the BasicStroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given line
|
||||
* width. The default values are:
|
||||
* <ul>
|
||||
* <li>line cap style: {@link #CAP_SQUARE};</li>
|
||||
* <li>line join style: {@link #JOIN_MITER};</li>
|
||||
* <li>miter limit: <code>10.0f</code>.
|
||||
* </ul>
|
||||
*
|
||||
* @exception IllegalArgumentException If width is negative.
|
||||
* @param width the line width (>= 0.0f).
|
||||
*
|
||||
* @throws IllegalArgumentException If <code>width</code> is negative.
|
||||
*/
|
||||
public BasicStroke(float width)
|
||||
{
|
||||
|
@ -167,43 +228,92 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance. The default values are:
|
||||
* <ul>
|
||||
* <li>line width: <code>1.0f</code>;</li>
|
||||
* <li>line cap style: {@link #CAP_SQUARE};</li>
|
||||
* <li>line join style: {@link #JOIN_MITER};</li>
|
||||
* <li>miter limit: <code>10.0f</code>.
|
||||
* </ul>
|
||||
*/
|
||||
public BasicStroke()
|
||||
{
|
||||
this(1, CAP_SQUARE, JOIN_MITER, 10, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a shape representing the stroked outline of the given shape.
|
||||
* THIS METHOD IS NOT YET IMPLEMENTED.
|
||||
*
|
||||
* @param s the shape.
|
||||
*/
|
||||
public Shape createStrokedShape(Shape s)
|
||||
{
|
||||
// FIXME: Implement this
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the line width.
|
||||
*
|
||||
* @return The line width.
|
||||
*/
|
||||
public float getLineWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a code indicating the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND}, {@link #CAP_SQUARE}).
|
||||
*
|
||||
* @return A code indicating the line cap style.
|
||||
*/
|
||||
public int getEndCap()
|
||||
{
|
||||
return cap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a code indicating the line join style (one of {@link #JOIN_BEVEL},
|
||||
* {@link #JOIN_MITER} or {@link #JOIN_ROUND}).
|
||||
*
|
||||
* @return A code indicating the line join style.
|
||||
*/
|
||||
public int getLineJoin()
|
||||
{
|
||||
return join;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the miter limit.
|
||||
*
|
||||
* @return The miter limit.
|
||||
*/
|
||||
public float getMiterLimit()
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dash array, which defines the length of alternate opaque and
|
||||
* transparent sections in lines drawn with this stroke. If
|
||||
* <code>null</code>, a continuous line will be drawn.
|
||||
*
|
||||
* @return The dash array (possibly <code>null</code>).
|
||||
*/
|
||||
public float[] getDashArray()
|
||||
{
|
||||
return dash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dash phase for the stroke. This is the offset from the start
|
||||
* of a path at which the pattern defined by {@link #getDashArray()} is
|
||||
* rendered.
|
||||
*
|
||||
* @return The dash phase.
|
||||
*/
|
||||
public float getDashPhase()
|
||||
{
|
||||
return phase;
|
||||
|
@ -215,6 +325,8 @@ public class BasicStroke implements Stroke
|
|||
* (converted to <code>int</code> first with
|
||||
* <code>Float.floatToIntBits()</code> if the value is a
|
||||
* <code>float</code>).
|
||||
*
|
||||
* @return The hash code.
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
|
@ -233,9 +345,18 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given Object is an instance of BasicStroke
|
||||
* and the width, cap, join, limit, dash array and phase are all
|
||||
* equal.
|
||||
* Compares this <code>BasicStroke</code> for equality with an arbitrary
|
||||
* object. This method returns <code>true</code> if and only if:
|
||||
* <ul>
|
||||
* <li><code>o</code> is an instanceof <code>BasicStroke</code>;<li>
|
||||
* <li>this object has the same width, line cap style, line join style,
|
||||
* miter limit, dash array and dash phase as <code>o</code>.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param o the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> if this stroke is equal to <code>o</code> and
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
@ -245,4 +366,4 @@ public class BasicStroke implements Stroke
|
|||
return width == s.width && cap == s.cap && join == s.join
|
||||
&& limit == s.limit && Arrays.equals(dash, s.dash) && phase == s.phase;
|
||||
}
|
||||
} // class BasicStroke
|
||||
}
|
||||
|
|
|
@ -460,27 +460,30 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Lays out the specified container according to the constraints
|
||||
* in this object.
|
||||
*
|
||||
* Lays out the specified container according to the constraints in this
|
||||
* object.
|
||||
*
|
||||
* @param target The container to lay out.
|
||||
*/
|
||||
public void layoutContainer(Container target)
|
||||
{
|
||||
synchronized (target.getTreeLock ())
|
||||
synchronized (target.getTreeLock())
|
||||
{
|
||||
Insets i = target.getInsets();
|
||||
int top = i.top;
|
||||
int bottom = target.height - i.bottom;
|
||||
int left = i.left;
|
||||
int right = target.width - i.right;
|
||||
|
||||
ComponentOrientation orient = target.getComponentOrientation ();
|
||||
boolean left_to_right = orient.isLeftToRight ();
|
||||
boolean left_to_right = target.getComponentOrientation().isLeftToRight();
|
||||
|
||||
Component my_north = north;
|
||||
Component my_east = east;
|
||||
Component my_south = south;
|
||||
Component my_west = west;
|
||||
|
||||
// Note that we currently don't handle vertical layouts. Neither
|
||||
// does JDK 1.3.
|
||||
// Note that we currently don't handle vertical layouts.
|
||||
// Neither does JDK 1.3.
|
||||
if (firstLine != null)
|
||||
my_north = firstLine;
|
||||
if (lastLine != null)
|
||||
|
@ -500,65 +503,42 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
my_west = lastItem;
|
||||
}
|
||||
|
||||
Dimension c = calcCompSize(center, PREF);
|
||||
Dimension n = calcCompSize(my_north, PREF);
|
||||
Dimension s = calcCompSize(my_south, PREF);
|
||||
Dimension e = calcCompSize(my_east, PREF);
|
||||
Dimension w = calcCompSize(my_west, PREF);
|
||||
int targetWidth = target.getWidth();
|
||||
int targetHeight = target.getHeight();
|
||||
if (my_north != null)
|
||||
{
|
||||
Dimension n = calcCompSize(my_north, PREF);
|
||||
my_north.setBounds(left, top, right - left, n.height);
|
||||
top += n.height + vgap;
|
||||
}
|
||||
|
||||
/*
|
||||
<-> hgap <-> hgap
|
||||
+----------------------------+ }
|
||||
|t | } i.top
|
||||
| +----------------------+ | --- y1 }
|
||||
| |n | |
|
||||
| +----------------------+ | } vgap
|
||||
| +---+ +----------+ +---+ | --- y2 } }
|
||||
| |w | |c | |e | | } hh
|
||||
| +---+ +----------+ +---+ | } vgap }
|
||||
| +----------------------+ | --- y3 }
|
||||
| |s | |
|
||||
| +----------------------+ | }
|
||||
| | } i.bottom
|
||||
+----------------------------+ }
|
||||
|x1 |x2 |x3
|
||||
<---------------------->
|
||||
<--> ww <-->
|
||||
i.left i.right
|
||||
*/
|
||||
if (my_south != null)
|
||||
{
|
||||
Dimension s = calcCompSize(my_south, PREF);
|
||||
my_south.setBounds(left, bottom - s.height, right - left, s.height);
|
||||
bottom -= s.height + vgap;
|
||||
}
|
||||
|
||||
int x1 = i.left;
|
||||
int x2 = x1 + w.width + (w.width == 0 ? 0 : hgap);
|
||||
int x3;
|
||||
if (targetWidth <= i.right + e.width)
|
||||
x3 = x2 + w.width + (w.width == 0 ? 0 : hgap);
|
||||
else
|
||||
x3 = targetWidth - i.right - e.width;
|
||||
int ww = targetWidth - i.right - i.left;
|
||||
if (my_east != null)
|
||||
{
|
||||
Dimension e = calcCompSize(my_east, PREF);
|
||||
my_east.setBounds(right - e.width, top, e.width, bottom - top);
|
||||
right -= e.width + hgap;
|
||||
}
|
||||
|
||||
int y1 = i.top;
|
||||
int y2 = y1 + n.height + (n.height == 0 ? 0 : vgap);
|
||||
int midh = Math.max(e.height, Math.max(w.height, c.height));
|
||||
int y3;
|
||||
if (targetHeight <= i.bottom + s.height)
|
||||
y3 = y2 + midh + vgap;
|
||||
else
|
||||
y3 = targetHeight - i.bottom - s.height;
|
||||
int hh = y3-y2-(s.height == 0 ? 0 : vgap);
|
||||
if (my_west != null)
|
||||
{
|
||||
Dimension w = calcCompSize(my_west, PREF);
|
||||
my_west.setBounds(left, top, w.width, bottom - top);
|
||||
left += w.width + hgap;
|
||||
}
|
||||
|
||||
setBounds(center, x2, y2, x3-x2-(w.width == 0 ? 0 : hgap), hh);
|
||||
setBounds(my_north, x1, y1, ww, n.height);
|
||||
setBounds(my_south, x1, y3, ww, s.height);
|
||||
setBounds(my_west, x1, y2, w.width, hh);
|
||||
setBounds(my_east, x3, y2, e.width, hh);
|
||||
if (center != null)
|
||||
center.setBounds(left, top, right - left, bottom - top);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this layout manager.
|
||||
*
|
||||
*
|
||||
* @return A string representation of this object.
|
||||
*/
|
||||
public String toString()
|
||||
|
@ -566,20 +546,9 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a convenience method to set the bounds on a component.
|
||||
* If the indicated component is null, nothing is done.
|
||||
*/
|
||||
private void setBounds(Component comp, int x, int y, int w, int h)
|
||||
{
|
||||
if (comp == null)
|
||||
return;
|
||||
comp.setBounds(x, y, w, h);
|
||||
}
|
||||
|
||||
private Dimension calcCompSize(Component comp, int what)
|
||||
{
|
||||
if (comp == null || !comp.isVisible())
|
||||
if (comp == null || ! comp.isVisible())
|
||||
return new Dimension(0, 0);
|
||||
if (what == MIN)
|
||||
return comp.getMinimumSize();
|
||||
|
@ -589,12 +558,12 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
}
|
||||
|
||||
/**
|
||||
* This is a helper function used to compute the various sizes for
|
||||
* this layout.
|
||||
* This is a helper function used to compute the various sizes for this
|
||||
* layout.
|
||||
*/
|
||||
private Dimension calcSize(Container target, int what)
|
||||
{
|
||||
synchronized (target.getTreeLock ())
|
||||
synchronized (target.getTreeLock())
|
||||
{
|
||||
Insets ins = target.getInsets();
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
/**
|
||||
* Cause the first component in the container to be displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void first (Container parent)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
/**
|
||||
* Cause the last component in the container to be displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void last (Container parent)
|
||||
{
|
||||
|
@ -247,7 +247,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
* this current card is the last one in the deck, the first
|
||||
* component is displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void next (Container parent)
|
||||
{
|
||||
|
@ -271,7 +271,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
* If this current card is the first one in the deck, the last
|
||||
* component is displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void previous (Container parent)
|
||||
{
|
||||
|
@ -321,13 +321,19 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
|
||||
/**
|
||||
* Cause the named component to be shown. If the component name is
|
||||
* unknown, this method does nothing.
|
||||
* unknown or <code>null</code>, this method does nothing.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param name The name of the component to show
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
* @param name The name of the component to show
|
||||
*/
|
||||
public void show (Container parent, String name)
|
||||
{
|
||||
if (name == null)
|
||||
return;
|
||||
|
||||
if (parent.getLayout() != this)
|
||||
throw new IllegalArgumentException("parent's layout is not this CardLayout");
|
||||
|
||||
Object target = tab.get (name);
|
||||
if (target != null)
|
||||
{
|
||||
|
@ -362,9 +368,15 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
*
|
||||
* @param parent The parent container
|
||||
* @param what The type of goto: FIRST, LAST, NEXT or PREV
|
||||
*
|
||||
* @throws IllegalArgumentException if parent has not this
|
||||
* CardLayout set as its layout.
|
||||
*/
|
||||
private void gotoComponent (Container parent, int what)
|
||||
{
|
||||
if (parent.getLayout() != this)
|
||||
throw new IllegalArgumentException("parent's layout is not this CardLayout");
|
||||
|
||||
synchronized (parent.getTreeLock ())
|
||||
{
|
||||
int num = parent.ncomponents;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Checkbox.java -- An AWT checkbox widget
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -459,11 +460,14 @@ getState()
|
|||
public synchronized void
|
||||
setState(boolean state)
|
||||
{
|
||||
this.state = state;
|
||||
if (peer != null)
|
||||
if (this.state != state)
|
||||
{
|
||||
CheckboxPeer cp = (CheckboxPeer) peer;
|
||||
cp.setState (state);
|
||||
this.state = state;
|
||||
if (peer != null)
|
||||
{
|
||||
CheckboxPeer cp = (CheckboxPeer) peer;
|
||||
cp.setState (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,10 +603,15 @@ void
|
|||
dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
if (e.id <= ItemEvent.ITEM_LAST
|
||||
&& e.id >= ItemEvent.ITEM_FIRST
|
||||
&& (item_listeners != null
|
||||
|| (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
&& e.id >= ItemEvent.ITEM_FIRST)
|
||||
{
|
||||
ItemEvent ie = (ItemEvent) e;
|
||||
int itemState = ie.getStateChange();
|
||||
setState(itemState == ItemEvent.SELECTED ? true : false);
|
||||
if (item_listeners != null
|
||||
|| (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0)
|
||||
processEvent(e);
|
||||
}
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
|
|
|
@ -468,15 +468,16 @@ getSelectedIndex()
|
|||
public synchronized void
|
||||
select(int index)
|
||||
{
|
||||
if ((index < 0) || (index > getItemCount()))
|
||||
if ((index < 0) || (index >= getItemCount()))
|
||||
throw new IllegalArgumentException("Bad index: " + index);
|
||||
|
||||
this.selectedIndex = index;
|
||||
if (peer != null)
|
||||
{
|
||||
if (pItems.size() > 0) {
|
||||
selectedIndex = index;
|
||||
ChoicePeer cp = (ChoicePeer) peer;
|
||||
cp.select (index);
|
||||
}
|
||||
if (cp != null) {
|
||||
cp.select(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -573,18 +574,6 @@ processItemEvent(ItemEvent event)
|
|||
item_listeners.itemStateChanged(event);
|
||||
}
|
||||
|
||||
void
|
||||
dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
if (e.id <= ItemEvent.ITEM_LAST
|
||||
&& e.id >= ItemEvent.ITEM_FIRST
|
||||
&& (item_listeners != null
|
||||
|| (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Component.java -- a graphics component
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006
|
||||
Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -40,6 +41,7 @@ package java.awt;
|
|||
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
|
@ -900,7 +902,7 @@ public abstract class Component
|
|||
// Avoid NullPointerExceptions by creating a local reference.
|
||||
ComponentPeer currentPeer=peer;
|
||||
if (currentPeer != null)
|
||||
currentPeer.setVisible(true);
|
||||
currentPeer.show();
|
||||
|
||||
// The JDK repaints the component before invalidating the parent.
|
||||
// So do we.
|
||||
|
@ -1388,18 +1390,20 @@ public abstract class Component
|
|||
int oldy = this.y;
|
||||
int oldwidth = this.width;
|
||||
int oldheight = this.height;
|
||||
|
||||
if (this.x == x && this.y == y
|
||||
&& this.width == width && this.height == height)
|
||||
|
||||
if (this.x == x && this.y == y && this.width == width
|
||||
&& this.height == height)
|
||||
return;
|
||||
invalidate ();
|
||||
|
||||
invalidate();
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
if (peer != null)
|
||||
peer.setBounds (x, y, width, height);
|
||||
|
||||
|
||||
// Erase old bounds and repaint new bounds for lightweights.
|
||||
if (isLightweight() && isShowing())
|
||||
{
|
||||
|
@ -1598,16 +1602,18 @@ public abstract class Component
|
|||
public Dimension preferredSize()
|
||||
{
|
||||
if (prefSize == null)
|
||||
if (peer == null)
|
||||
return new Dimension(width, height);
|
||||
else
|
||||
prefSize = peer.getPreferredSize();
|
||||
{
|
||||
if (peer == null)
|
||||
prefSize = minimumSize();
|
||||
else
|
||||
prefSize = peer.getPreferredSize();
|
||||
}
|
||||
return prefSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component's minimum size.
|
||||
*
|
||||
*
|
||||
* @return the component's minimum size
|
||||
* @see #getPreferredSize()
|
||||
* @see LayoutManager
|
||||
|
@ -1882,8 +1888,7 @@ public abstract class Component
|
|||
*/
|
||||
public void repaint()
|
||||
{
|
||||
if (isShowing())
|
||||
repaint(0, 0, 0, width, height);
|
||||
repaint(0, 0, 0, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1897,8 +1902,7 @@ public abstract class Component
|
|||
*/
|
||||
public void repaint(long tm)
|
||||
{
|
||||
if (isShowing())
|
||||
repaint(tm, 0, 0, width, height);
|
||||
repaint(tm, 0, 0, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1915,8 +1919,7 @@ public abstract class Component
|
|||
*/
|
||||
public void repaint(int x, int y, int w, int h)
|
||||
{
|
||||
if (isShowing())
|
||||
repaint(0, x, y, w, h);
|
||||
repaint(0, x, y, w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2308,6 +2311,10 @@ public abstract class Component
|
|||
*/
|
||||
public final void dispatchEvent(AWTEvent e)
|
||||
{
|
||||
Event oldEvent = translateEvent(e);
|
||||
if (oldEvent != null)
|
||||
postEvent (oldEvent);
|
||||
|
||||
// Some subclasses in the AWT package need to override this behavior,
|
||||
// hence the use of dispatchEventImpl().
|
||||
dispatchEventImpl(e);
|
||||
|
@ -3419,10 +3426,11 @@ public abstract class Component
|
|||
}
|
||||
|
||||
/**
|
||||
* Called to inform this component it has been added to a container.
|
||||
* A native peer - if any - is created at this time. This method is
|
||||
* called automatically by the AWT system and should not be called by
|
||||
* user level code.
|
||||
* Called when the parent of this Component is made visible or when
|
||||
* the Component is added to an already visible Container and needs
|
||||
* to be shown. A native peer - if any - is created at this
|
||||
* time. This method is called automatically by the AWT system and
|
||||
* should not be called by user level code.
|
||||
*
|
||||
* @see #isDisplayable()
|
||||
* @see #removeNotify()
|
||||
|
@ -3431,6 +3439,8 @@ public abstract class Component
|
|||
{
|
||||
if (peer == null)
|
||||
peer = getToolkit().createComponent(this);
|
||||
else if (parent != null && parent.isLightweight())
|
||||
new HeavyweightInLightweightListener(parent);
|
||||
/* Now that all the children has gotten their peers, we should
|
||||
have the event mask needed for this component and its
|
||||
lightweight subcomponents. */
|
||||
|
@ -4480,6 +4490,109 @@ p * <li>the set of backward traversal keys
|
|||
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, byte oldValue,
|
||||
byte newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Byte(oldValue),
|
||||
new Byte(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, char oldValue,
|
||||
char newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Character(oldValue),
|
||||
new Character(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, short oldValue,
|
||||
short newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Short(oldValue),
|
||||
new Short(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, long oldValue,
|
||||
long newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Long(oldValue),
|
||||
new Long(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, float oldValue,
|
||||
float newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Float(oldValue),
|
||||
new Float(newValue));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, double oldValue,
|
||||
double newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Double(oldValue),
|
||||
new Double(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text layout orientation of this component. New components default
|
||||
* to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects only
|
||||
|
@ -4597,7 +4710,7 @@ p * <li>the set of backward traversal keys
|
|||
*/
|
||||
static Event translateEvent (AWTEvent e)
|
||||
{
|
||||
Component target = (Component) e.getSource ();
|
||||
Object target = e.getSource ();
|
||||
Event translated = null;
|
||||
|
||||
if (e instanceof InputEvent)
|
||||
|
@ -4770,6 +4883,25 @@ p * <li>the set of backward traversal keys
|
|||
0, 0, oldKey, oldMods);
|
||||
}
|
||||
}
|
||||
else if (e instanceof AdjustmentEvent)
|
||||
{
|
||||
AdjustmentEvent ae = (AdjustmentEvent) e;
|
||||
int type = ae.getAdjustmentType();
|
||||
int oldType;
|
||||
if (type == AdjustmentEvent.BLOCK_DECREMENT)
|
||||
oldType = Event.SCROLL_PAGE_UP;
|
||||
else if (type == AdjustmentEvent.BLOCK_INCREMENT)
|
||||
oldType = Event.SCROLL_PAGE_DOWN;
|
||||
else if (type == AdjustmentEvent.TRACK)
|
||||
oldType = Event.SCROLL_ABSOLUTE;
|
||||
else if (type == AdjustmentEvent.UNIT_DECREMENT)
|
||||
oldType = Event.SCROLL_LINE_UP;
|
||||
else if (type == AdjustmentEvent.UNIT_INCREMENT)
|
||||
oldType = Event.SCROLL_LINE_DOWN;
|
||||
else
|
||||
oldType = type;
|
||||
translated = new Event(target, oldType, new Integer(ae.getValue()));
|
||||
}
|
||||
else if (e instanceof ActionEvent)
|
||||
translated = new Event (target, Event.ACTION_EVENT,
|
||||
((ActionEvent) e).getActionCommand ());
|
||||
|
@ -4790,16 +4922,16 @@ p * <li>the set of backward traversal keys
|
|||
|
||||
void dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
Event oldEvent = translateEvent (e);
|
||||
// Give toolkit a chance to dispatch the event
|
||||
// to globally registered listeners.
|
||||
Toolkit.getDefaultToolkit().globalDispatchEvent(e);
|
||||
|
||||
// This boolean tells us not to process focus events when the focus
|
||||
// opposite component is the same as the focus component.
|
||||
boolean ignoreFocus =
|
||||
(e instanceof FocusEvent &&
|
||||
((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent());
|
||||
|
||||
if (oldEvent != null)
|
||||
postEvent (oldEvent);
|
||||
|
||||
if (eventTypeEnabled (e.id))
|
||||
{
|
||||
// the trick we use to communicate between dispatch and redispatch
|
||||
|
@ -4925,16 +5057,6 @@ p * <li>the set of backward traversal keys
|
|||
Rectangle r1 = queuedEvent.getUpdateRect();
|
||||
Rectangle r2 = newEvent.getUpdateRect();
|
||||
Rectangle union = r1.union(r2);
|
||||
|
||||
int r1a = r1.width * r1.height;
|
||||
int r2a = r2.width * r2.height;
|
||||
int ua = union.width * union.height;
|
||||
|
||||
if (ua > (r1a+r2a)*2)
|
||||
return null;
|
||||
/* The 2 factor should maybe be reconsidered. Perhaps 3/2
|
||||
would be better? */
|
||||
|
||||
newEvent.setUpdateRect(union);
|
||||
return newEvent;
|
||||
}
|
||||
|
@ -5014,9 +5136,76 @@ p * <li>the set of backward traversal keys
|
|||
s.writeObject(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Nested classes.
|
||||
|
||||
/**
|
||||
* This class fixes the bounds for a Heavyweight component that
|
||||
* is placed inside a Lightweight container. When the lightweight is
|
||||
* moved or resized, setBounds for the lightweight peer does nothing.
|
||||
* Therefore, it was never moved on the screen. This class is
|
||||
* attached to the lightweight, and it adjusts the position and size
|
||||
* of the peer when notified.
|
||||
* This is the same for show and hide.
|
||||
*/
|
||||
class HeavyweightInLightweightListener
|
||||
implements ComponentListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor. Adds component listener to lightweight parent.
|
||||
*
|
||||
* @param parent - the lightweight container.
|
||||
*/
|
||||
public HeavyweightInLightweightListener(Container parent)
|
||||
{
|
||||
parent.addComponentListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is resized.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the resize
|
||||
*/
|
||||
public void componentResized(ComponentEvent event)
|
||||
{
|
||||
// Nothing to do here, componentMoved will be called.
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is moved.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the move
|
||||
*/
|
||||
public void componentMoved(ComponentEvent event)
|
||||
{
|
||||
if (peer != null)
|
||||
peer.setBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is made visible.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the visibility
|
||||
*/
|
||||
public void componentShown(ComponentEvent event)
|
||||
{
|
||||
if (isShowing())
|
||||
peer.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is hidden.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the visibility
|
||||
*/
|
||||
public void componentHidden(ComponentEvent event)
|
||||
{
|
||||
if (!isShowing())
|
||||
peer.hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides accessibility support for subclasses of container.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Container.java -- parent container class in AWT
|
||||
Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation
|
||||
Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -42,12 +43,10 @@ import java.awt.event.ComponentListener;
|
|||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.ContainerListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
@ -62,8 +61,6 @@ import java.util.Set;
|
|||
|
||||
import javax.accessibility.Accessible;
|
||||
|
||||
import gnu.java.awt.AWTUtilities;
|
||||
|
||||
/**
|
||||
* A generic window toolkit object that acts as a container for other objects.
|
||||
* Components are tracked in a list, and new elements are at the end of the
|
||||
|
@ -88,10 +85,13 @@ public class Container extends Component
|
|||
Component[] component;
|
||||
LayoutManager layoutMgr;
|
||||
|
||||
LightweightDispatcher dispatcher;
|
||||
|
||||
Dimension maxSize;
|
||||
|
||||
/**
|
||||
* Keeps track if the Container was cleared during a paint/update.
|
||||
*/
|
||||
private boolean backCleared;
|
||||
|
||||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
|
@ -101,7 +101,6 @@ public class Container extends Component
|
|||
|
||||
/* Anything else is non-serializable, and should be declared "transient". */
|
||||
transient ContainerListener containerListener;
|
||||
transient PropertyChangeSupport changeSupport;
|
||||
|
||||
/** The focus traversal policy that determines how focus is
|
||||
transferred between this Container and its children. */
|
||||
|
@ -186,25 +185,6 @@ public class Container extends Component
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the components at position i and j, in the container.
|
||||
*/
|
||||
|
||||
protected void swapComponents (int i, int j)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (i < 0
|
||||
|| i >= component.length
|
||||
|| j < 0
|
||||
|| j >= component.length)
|
||||
throw new ArrayIndexOutOfBoundsException ();
|
||||
Component tmp = component[i];
|
||||
component[i] = component[j];
|
||||
component[j] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the insets for this container, which is the space used for
|
||||
* borders, the margin, etc.
|
||||
|
@ -385,6 +365,8 @@ public class Container extends Component
|
|||
// Notify the layout manager.
|
||||
if (layoutMgr != null)
|
||||
{
|
||||
// If we have a LayoutManager2 the constraints are "real",
|
||||
// otherwise they are the "name" of the Component to add.
|
||||
if (layoutMgr instanceof LayoutManager2)
|
||||
{
|
||||
LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
|
||||
|
@ -393,7 +375,7 @@ public class Container extends Component
|
|||
else if (constraints instanceof String)
|
||||
layoutMgr.addLayoutComponent((String) constraints, comp);
|
||||
else
|
||||
layoutMgr.addLayoutComponent(null, comp);
|
||||
layoutMgr.addLayoutComponent("", comp);
|
||||
}
|
||||
|
||||
// We previously only sent an event when this container is showing.
|
||||
|
@ -428,8 +410,7 @@ public class Container extends Component
|
|||
for (int j = 0; j < list.length; j++)
|
||||
r.removeComponentListener(list[j]);
|
||||
|
||||
if (r.isShowing())
|
||||
r.removeNotify();
|
||||
r.removeNotify();
|
||||
|
||||
System.arraycopy(component, index + 1, component, index,
|
||||
ncomponents - index - 1);
|
||||
|
@ -777,16 +758,17 @@ public class Container extends Component
|
|||
* a superclass method so that lightweight components are properly
|
||||
* drawn.
|
||||
*
|
||||
* @param g The graphics context for this paint job.
|
||||
* @param g - The graphics context for this paint job.
|
||||
*/
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
if (!isShowing())
|
||||
return;
|
||||
|
||||
// Visit heavyweights as well, in case they were
|
||||
// erased when we cleared the background for this container.
|
||||
visitChildren(g, GfxPaintVisitor.INSTANCE, false);
|
||||
// Visit heavyweights if the background was cleared
|
||||
// for this container.
|
||||
visitChildren(g, GfxPaintVisitor.INSTANCE, !backCleared);
|
||||
backCleared = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -817,8 +799,11 @@ public class Container extends Component
|
|||
// also not cleared. So we do a check on !(peer instanceof LightweightPeer)
|
||||
// instead.
|
||||
ComponentPeer p = peer;
|
||||
if (p != null && !(p instanceof LightweightPeer))
|
||||
g.clearRect(0, 0, getWidth(), getHeight());
|
||||
if (p != null && ! (p instanceof LightweightPeer))
|
||||
{
|
||||
g.clearRect(0, 0, getWidth(), getHeight());
|
||||
backCleared = true;
|
||||
}
|
||||
|
||||
paint(g);
|
||||
}
|
||||
|
@ -1557,28 +1542,105 @@ public class Container extends Component
|
|||
if (orientation == null)
|
||||
throw new NullPointerException ();
|
||||
}
|
||||
|
||||
|
||||
public void addPropertyChangeListener (PropertyChangeListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
|
||||
if (changeSupport == null)
|
||||
changeSupport = new PropertyChangeSupport (this);
|
||||
|
||||
changeSupport.addPropertyChangeListener (listener);
|
||||
// TODO: Why is this overridden?
|
||||
super.addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener (String name,
|
||||
|
||||
public void addPropertyChangeListener (String propertyName,
|
||||
PropertyChangeListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
|
||||
if (changeSupport == null)
|
||||
changeSupport = new PropertyChangeSupport (this);
|
||||
// TODO: Why is this overridden?
|
||||
super.addPropertyChangeListener(propertyName, listener);
|
||||
}
|
||||
|
||||
changeSupport.addPropertyChangeListener (name, listener);
|
||||
|
||||
/**
|
||||
* Sets the Z ordering for the component <code>comp</code> to
|
||||
* <code>index</code>. Components with lower Z order paint above components
|
||||
* with higher Z order.
|
||||
*
|
||||
* @param comp the component for which to change the Z ordering
|
||||
* @param index the index to set
|
||||
*
|
||||
* @throws NullPointerException if <code>comp == null</code>
|
||||
* @throws IllegalArgumentException if comp is an ancestor of this container
|
||||
* @throws IllegalArgumentException if <code>index</code> is not in
|
||||
* <code>[0, getComponentCount()]</code> for moving between
|
||||
* containers or <code>[0, getComponentCount() - 1]</code> for moving
|
||||
* inside this container
|
||||
* @throws IllegalArgumentException if <code>comp == this</code>
|
||||
* @throws IllegalArgumentException if <code>comp</code> is a
|
||||
* <code>Window</code>
|
||||
*
|
||||
* @see #getComponentZOrder(Component)
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public final void setComponentZOrder(Component comp, int index)
|
||||
{
|
||||
if (comp == null)
|
||||
throw new NullPointerException("comp must not be null");
|
||||
if (comp instanceof Container && ((Container) comp).isAncestorOf(this))
|
||||
throw new IllegalArgumentException("comp must not be an ancestor of "
|
||||
+ "this");
|
||||
if (comp instanceof Window)
|
||||
throw new IllegalArgumentException("comp must not be a Window");
|
||||
|
||||
if (comp == this)
|
||||
throw new IllegalArgumentException("cannot add component to itself");
|
||||
|
||||
// FIXME: Implement reparenting.
|
||||
if ( comp.getParent() != this)
|
||||
throw new AssertionError("Reparenting is not implemented yet");
|
||||
else
|
||||
{
|
||||
// Find current component index.
|
||||
int currentIndex = getComponentZOrder(comp);
|
||||
if (currentIndex < index)
|
||||
{
|
||||
System.arraycopy(component, currentIndex + 1, component,
|
||||
currentIndex, index - currentIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.arraycopy(component, index, component, index + 1,
|
||||
currentIndex - index);
|
||||
}
|
||||
component[index] = comp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Z ordering index of <code>comp</code>. If <code>comp</code>
|
||||
* is not a child component of this Container, this returns <code>-1</code>.
|
||||
*
|
||||
* @param comp the component for which to query the Z ordering
|
||||
*
|
||||
* @return the Z ordering index of <code>comp</code> or <code>-1</code> if
|
||||
* <code>comp</code> is not a child of this Container
|
||||
*
|
||||
* @see #setComponentZOrder(Component, int)
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public final int getComponentZOrder(Component comp)
|
||||
{
|
||||
int index = -1;
|
||||
if (component != null)
|
||||
{
|
||||
for (int i = 0; i < component.length; i++)
|
||||
{
|
||||
if (component[i] == comp)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
// Hidden helper methods.
|
||||
|
@ -1600,17 +1662,17 @@ public class Container extends Component
|
|||
private void visitChildren(Graphics gfx, GfxVisitor visitor,
|
||||
boolean lightweightOnly)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
for (int i = ncomponents - 1; i >= 0; --i)
|
||||
{
|
||||
Component comp = component[i];
|
||||
boolean applicable = comp.isVisible()
|
||||
&& (comp.isLightweight() || !lightweightOnly);
|
||||
|
||||
&& (comp.isLightweight() || ! lightweightOnly);
|
||||
|
||||
if (applicable)
|
||||
visitChild(gfx, visitor, comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1631,10 +1693,9 @@ public class Container extends Component
|
|||
Component comp)
|
||||
{
|
||||
Rectangle bounds = comp.getBounds();
|
||||
|
||||
|
||||
if(!gfx.hitClip(bounds.x,bounds.y, bounds.width, bounds.height))
|
||||
return;
|
||||
|
||||
Graphics g2 = gfx.create(bounds.x, bounds.y, bounds.width,
|
||||
bounds.height);
|
||||
try
|
||||
|
@ -1649,17 +1710,18 @@ public class Container extends Component
|
|||
|
||||
void dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
// Give lightweight dispatcher a chance to handle it.
|
||||
if (dispatcher != null && dispatcher.handleEvent (e))
|
||||
return;
|
||||
|
||||
if ((e.id <= ContainerEvent.CONTAINER_LAST
|
||||
&& e.id >= ContainerEvent.CONTAINER_FIRST)
|
||||
&& (containerListener != null
|
||||
|| (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
boolean dispatched =
|
||||
LightweightDispatcher.getInstance().dispatchEvent(e);
|
||||
if (! dispatched)
|
||||
{
|
||||
if ((e.id <= ContainerEvent.CONTAINER_LAST
|
||||
&& e.id >= ContainerEvent.CONTAINER_FIRST)
|
||||
&& (containerListener != null
|
||||
|| (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1743,15 +1805,6 @@ public class Container extends Component
|
|||
component[i].addNotify();
|
||||
if (component[i].isLightweight ())
|
||||
{
|
||||
|
||||
// If we're not lightweight, and we just got a lightweight
|
||||
// child, we need a lightweight dispatcher to feed it events.
|
||||
if (!this.isLightweight() && dispatcher == null)
|
||||
dispatcher = new LightweightDispatcher (this);
|
||||
|
||||
if (dispatcher != null)
|
||||
dispatcher.enableEvents(component[i].eventMask);
|
||||
|
||||
enableEvents(component[i].eventMask);
|
||||
if (peer != null && !isLightweight ())
|
||||
enableEvents (AWTEvent.PAINT_EVENT_MASK);
|
||||
|
@ -1998,229 +2051,3 @@ public class Container extends Component
|
|||
} // class AccessibleContainerHandler
|
||||
} // class AccessibleAWTContainer
|
||||
} // class Container
|
||||
|
||||
/**
|
||||
* There is a helper class implied from stack traces called
|
||||
* LightweightDispatcher, but since it is not part of the public API,
|
||||
* rather than mimic it exactly we write something which does "roughly
|
||||
* the same thing".
|
||||
*/
|
||||
class LightweightDispatcher implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 5184291520170872969L;
|
||||
private Container nativeContainer;
|
||||
private Cursor nativeCursor;
|
||||
private long eventMask;
|
||||
|
||||
private transient Component pressedComponent;
|
||||
private transient Component lastComponentEntered;
|
||||
private transient int pressCount;
|
||||
|
||||
LightweightDispatcher(Container c)
|
||||
{
|
||||
nativeContainer = c;
|
||||
}
|
||||
|
||||
void enableEvents(long l)
|
||||
{
|
||||
eventMask |= l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deepest visible descendent of parent that contains the
|
||||
* specified location and that is not transparent and MouseListener-less.
|
||||
* @param parent the root component to begin the search
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @return null if <code>parent</code> doesn't contain the location,
|
||||
* parent if parent is not a container or has no child that contains the
|
||||
* location, otherwise the appropriate component from the conditions
|
||||
* above.
|
||||
*/
|
||||
Component getDeepestComponentForMouseEventAt(Component parent, int x, int y)
|
||||
{
|
||||
if (parent == null || (! parent.contains(x, y)))
|
||||
return null;
|
||||
|
||||
if (! (parent instanceof Container))
|
||||
return parent;
|
||||
|
||||
Container c = (Container) parent;
|
||||
return c.findComponentForMouseEventAt(x, y);
|
||||
}
|
||||
|
||||
Component acquireComponentForMouseEvent(MouseEvent me)
|
||||
{
|
||||
int x = me.getX ();
|
||||
int y = me.getY ();
|
||||
|
||||
Component mouseEventTarget = null;
|
||||
// Find the candidate which should receive this event.
|
||||
Component parent = nativeContainer;
|
||||
Component candidate = null;
|
||||
Point p = me.getPoint();
|
||||
while (candidate == null && parent != null)
|
||||
{
|
||||
candidate = getDeepestComponentForMouseEventAt(parent, p.x, p.y);
|
||||
if (candidate == null || (candidate.eventMask & me.getID()) == 0)
|
||||
{
|
||||
candidate = null;
|
||||
p = AWTUtilities.convertPoint(parent, p.x, p.y, parent.parent);
|
||||
parent = parent.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// If the only candidate we found was the native container itself,
|
||||
// don't dispatch any event at all. We only care about the lightweight
|
||||
// children here.
|
||||
if (candidate == nativeContainer)
|
||||
candidate = null;
|
||||
|
||||
// If our candidate is new, inform the old target we're leaving.
|
||||
if (lastComponentEntered != null
|
||||
&& lastComponentEntered.isShowing()
|
||||
&& lastComponentEntered != candidate)
|
||||
{
|
||||
// Old candidate could have been removed from
|
||||
// the nativeContainer so we check first.
|
||||
if (AWTUtilities.isDescendingFrom(lastComponentEntered,
|
||||
nativeContainer))
|
||||
{
|
||||
Point tp = AWTUtilities.convertPoint(nativeContainer,
|
||||
x, y, lastComponentEntered);
|
||||
MouseEvent exited = new MouseEvent (lastComponentEntered,
|
||||
MouseEvent.MOUSE_EXITED,
|
||||
me.getWhen (),
|
||||
me.getModifiersEx (),
|
||||
tp.x, tp.y,
|
||||
me.getClickCount (),
|
||||
me.isPopupTrigger (),
|
||||
me.getButton ());
|
||||
lastComponentEntered.dispatchEvent (exited);
|
||||
}
|
||||
lastComponentEntered = null;
|
||||
}
|
||||
|
||||
// If we have a candidate, maybe enter it.
|
||||
if (candidate != null)
|
||||
{
|
||||
mouseEventTarget = candidate;
|
||||
if (candidate.isLightweight()
|
||||
&& candidate.isShowing()
|
||||
&& candidate != nativeContainer
|
||||
&& candidate != lastComponentEntered)
|
||||
{
|
||||
lastComponentEntered = mouseEventTarget;
|
||||
Point cp = AWTUtilities.convertPoint(nativeContainer,
|
||||
x, y, lastComponentEntered);
|
||||
MouseEvent entered = new MouseEvent (lastComponentEntered,
|
||||
MouseEvent.MOUSE_ENTERED,
|
||||
me.getWhen (),
|
||||
me.getModifiersEx (),
|
||||
cp.x, cp.y,
|
||||
me.getClickCount (),
|
||||
me.isPopupTrigger (),
|
||||
me.getButton ());
|
||||
lastComponentEntered.dispatchEvent (entered);
|
||||
}
|
||||
}
|
||||
|
||||
// Check which buttons where pressed except the last button that
|
||||
// changed state.
|
||||
int modifiers = me.getModifiersEx() & (MouseEvent.BUTTON1_DOWN_MASK
|
||||
| MouseEvent.BUTTON2_DOWN_MASK
|
||||
| MouseEvent.BUTTON3_DOWN_MASK);
|
||||
switch(me.getButton())
|
||||
{
|
||||
case MouseEvent.BUTTON1:
|
||||
modifiers &= ~MouseEvent.BUTTON1_DOWN_MASK;
|
||||
break;
|
||||
case MouseEvent.BUTTON2:
|
||||
modifiers &= ~MouseEvent.BUTTON2_DOWN_MASK;
|
||||
break;
|
||||
case MouseEvent.BUTTON3:
|
||||
modifiers &= ~MouseEvent.BUTTON3_DOWN_MASK;
|
||||
break;
|
||||
}
|
||||
|
||||
if (me.getID() == MouseEvent.MOUSE_RELEASED
|
||||
|| me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0
|
||||
|| me.getID() == MouseEvent.MOUSE_DRAGGED)
|
||||
{
|
||||
// If any of the following events occur while a button is held down,
|
||||
// they should be dispatched to the same component to which the
|
||||
// original MOUSE_PRESSED event was dispatched:
|
||||
// - MOUSE_RELEASED: This is important for correct dragging
|
||||
// behaviour, otherwise the release goes to an arbitrary component
|
||||
// outside of the dragged component. OTOH, if there is no mouse
|
||||
// drag while the mouse is pressed, the component under the mouse
|
||||
// is the same as the previously pressed component anyway.
|
||||
// - MOUSE_PRESSED: another button pressed while the first is held
|
||||
// down
|
||||
// - MOUSE_DRAGGED
|
||||
if (AWTUtilities.isDescendingFrom(pressedComponent, nativeContainer))
|
||||
mouseEventTarget = pressedComponent;
|
||||
}
|
||||
else if (me.getID() == MouseEvent.MOUSE_CLICKED)
|
||||
{
|
||||
// Don't dispatch CLICKED events whose target is not the same as the
|
||||
// target for the original PRESSED event.
|
||||
if (candidate != pressedComponent)
|
||||
{
|
||||
mouseEventTarget = null;
|
||||
pressCount = 0;
|
||||
}
|
||||
else if (pressCount == 0)
|
||||
pressedComponent = null;
|
||||
}
|
||||
return mouseEventTarget;
|
||||
}
|
||||
|
||||
boolean handleEvent(AWTEvent e)
|
||||
{
|
||||
if (e instanceof MouseEvent)
|
||||
{
|
||||
MouseEvent me = (MouseEvent) e;
|
||||
|
||||
// Make the LightWeightDispatcher reentrant. This is necessary when
|
||||
// a lightweight component does its own modal event queue.
|
||||
Component mouseEventTarget = acquireComponentForMouseEvent(me);
|
||||
|
||||
// Avoid dispatching ENTERED and EXITED events twice.
|
||||
if (mouseEventTarget != null
|
||||
&& mouseEventTarget.isShowing()
|
||||
&& e.getID() != MouseEvent.MOUSE_ENTERED
|
||||
&& e.getID() != MouseEvent.MOUSE_EXITED)
|
||||
{
|
||||
switch (e.getID())
|
||||
{
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
if (pressCount++ == 0)
|
||||
pressedComponent = mouseEventTarget;
|
||||
break;
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
// Clear our memory of the original PRESSED event, only if
|
||||
// we're not expecting a CLICKED event after this. If
|
||||
// there is a CLICKED event after this, it will do clean up.
|
||||
if (--pressCount == 0
|
||||
&& mouseEventTarget != pressedComponent)
|
||||
{
|
||||
pressedComponent = null;
|
||||
pressCount = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
MouseEvent newEvt =
|
||||
AWTUtilities.convertMouseEvent(nativeContainer, me,
|
||||
mouseEventTarget);
|
||||
mouseEventTarget.dispatchEvent(newEvt);
|
||||
|
||||
if (newEvt.isConsumed())
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
|
||||
return e.isConsumed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,6 +219,8 @@ public class Cursor implements java.io.Serializable
|
|||
|
||||
public String toString()
|
||||
{
|
||||
return (this.getClass() + "[" + getName() + "]");
|
||||
return (this.getClass()
|
||||
+ "[type=" + getType()
|
||||
+ ",name=" + getName() + "]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Frame.java -- AWT toplevel window
|
||||
Copyright (C) 1999, 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -57,143 +58,156 @@ import javax.accessibility.AccessibleStateSet;
|
|||
*/
|
||||
public class Frame extends Window implements MenuContainer
|
||||
{
|
||||
/**
|
||||
* Constant for the default cursor.
|
||||
* @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cross-hair cursor.
|
||||
* @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
|
||||
/**
|
||||
* Constant for the default cursor.
|
||||
*
|
||||
* @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cursor over a text field.
|
||||
* @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
|
||||
/**
|
||||
* Constant for a cross-hair cursor.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cursor to display while waiting for an action to complete.
|
||||
* @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
|
||||
*/
|
||||
public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
|
||||
/**
|
||||
* Constant for a cursor over a text field.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over SW corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
|
||||
/**
|
||||
* Constant for a cursor to display while waiting for an action to complete.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
|
||||
*/
|
||||
public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over SE corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over SW corner of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over NW corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over SE corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over NE corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over NW corner of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over N edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over NE corner of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over S edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over N edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over E edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over S edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over W edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over E edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a hand cursor.
|
||||
* @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
|
||||
/**
|
||||
* Cursor used over W edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cursor used during window move operations.
|
||||
* @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
|
||||
/**
|
||||
* Constant for a hand cursor.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
|
||||
|
||||
public static final int ICONIFIED = 1;
|
||||
public static final int MAXIMIZED_BOTH = 6;
|
||||
public static final int MAXIMIZED_HORIZ = 2;
|
||||
public static final int MAXIMIZED_VERT = 4;
|
||||
public static final int NORMAL = 0;
|
||||
/**
|
||||
* Constant for a cursor used during window move operations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
|
||||
|
||||
// Serialization version constant
|
||||
private static final long serialVersionUID = 2673458971256075116L;
|
||||
public static final int ICONIFIED = 1;
|
||||
public static final int MAXIMIZED_BOTH = 6;
|
||||
public static final int MAXIMIZED_HORIZ = 2;
|
||||
public static final int MAXIMIZED_VERT = 4;
|
||||
public static final int NORMAL = 0;
|
||||
|
||||
/**
|
||||
* @serial The version of the class data being serialized
|
||||
* // FIXME: what is this value?
|
||||
*/
|
||||
private int frameSerializedDataVersion;
|
||||
//Serialization version constant
|
||||
private static final long serialVersionUID = 2673458971256075116L;
|
||||
|
||||
/**
|
||||
* @serial Image used as the icon when this frame is minimized.
|
||||
*/
|
||||
private Image icon;
|
||||
/**
|
||||
* @serial The version of the class data being serialized
|
||||
* FIXME: what is this value?
|
||||
*/
|
||||
private int frameSerializedDataVersion;
|
||||
|
||||
/**
|
||||
* @serial Constant used by the JDK Motif peer set. Not used in
|
||||
* this implementation.
|
||||
*/
|
||||
private boolean mbManagement;
|
||||
/**
|
||||
* @serial Image used as the icon when this frame is minimized.
|
||||
*/
|
||||
private Image icon;
|
||||
|
||||
/**
|
||||
* @serial The menu bar for this frame.
|
||||
*/
|
||||
//private MenuBar menuBar = new MenuBar();
|
||||
private MenuBar menuBar;
|
||||
/**
|
||||
* @serial Constant used by the JDK Motif peer set. Not used in
|
||||
* this implementation.
|
||||
*/
|
||||
private boolean mbManagement;
|
||||
|
||||
/**
|
||||
* @serial A list of other top-level windows owned by this window.
|
||||
*/
|
||||
Vector ownedWindows = new Vector();
|
||||
/**
|
||||
* @serial The menu bar for this frame.
|
||||
*/
|
||||
private MenuBar menuBar;
|
||||
|
||||
/**
|
||||
* @serial Indicates whether or not this frame is resizable.
|
||||
*/
|
||||
private boolean resizable = true;
|
||||
/**
|
||||
* @serial A list of other top-level windows owned by this window.
|
||||
*/
|
||||
Vector ownedWindows = new Vector();
|
||||
|
||||
/**
|
||||
* @serial The state of this frame.
|
||||
* // FIXME: What are the values here?
|
||||
* This is package-private to avoid an accessor method.
|
||||
*/
|
||||
int state;
|
||||
/**
|
||||
* @serial Indicates whether or not this frame is resizable.
|
||||
*/
|
||||
private boolean resizable = true;
|
||||
|
||||
/**
|
||||
* @serial The title of the frame.
|
||||
*/
|
||||
private String title = "";
|
||||
/**
|
||||
* @serial The state of this frame.
|
||||
* // FIXME: What are the values here?
|
||||
* This is package-private to avoid an accessor method.
|
||||
*/
|
||||
int state;
|
||||
|
||||
/**
|
||||
* @serial The title of the frame.
|
||||
*/
|
||||
private String title = "";
|
||||
|
||||
/**
|
||||
* Maximized bounds for this frame.
|
||||
|
@ -210,223 +224,235 @@ private String title = "";
|
|||
*/
|
||||
private static transient long next_frame_number;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has no title.
|
||||
*/
|
||||
public
|
||||
Frame()
|
||||
{
|
||||
this("");
|
||||
noteFrame(this);
|
||||
}
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has no title.
|
||||
*/
|
||||
public Frame()
|
||||
{
|
||||
this("");
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has the specified title.
|
||||
*
|
||||
* @param title The title of this frame.
|
||||
*/
|
||||
public
|
||||
Frame(String title)
|
||||
{
|
||||
super();
|
||||
this.title = title;
|
||||
// Top-level frames are initially invisible.
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has the specified title.
|
||||
*
|
||||
* @param title the title of this frame
|
||||
*/
|
||||
public Frame(String title)
|
||||
{
|
||||
super();
|
||||
this.title = title;
|
||||
// Top-level frames are initially invisible.
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
public
|
||||
Frame(GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
public Frame(GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
public
|
||||
Frame(String title, GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
setTitle(title);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
public Frame(String title, GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
setTitle(title);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this frame's title string.
|
||||
*
|
||||
* @return This frame's title string.
|
||||
*/
|
||||
public String
|
||||
getTitle()
|
||||
{
|
||||
return(title);
|
||||
}
|
||||
/**
|
||||
* Returns this frame's title string.
|
||||
*
|
||||
* @return this frame's title string
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets this frame's title to the specified value.
|
||||
*
|
||||
* @param title The new frame title.
|
||||
*/
|
||||
public synchronized void
|
||||
setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setTitle(title);
|
||||
}
|
||||
/**
|
||||
* Sets this frame's title to the specified value.
|
||||
*
|
||||
* @param title the new frame title
|
||||
*/
|
||||
public synchronized void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setTitle(title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this frame's icon.
|
||||
*
|
||||
* @return This frame's icon, or <code>null</code> if this frame does not
|
||||
* have an icon.
|
||||
*/
|
||||
public Image
|
||||
getIconImage()
|
||||
{
|
||||
return(icon);
|
||||
}
|
||||
/**
|
||||
* Returns this frame's icon.
|
||||
*
|
||||
* @return this frame's icon, or <code>null</code> if this frame does not
|
||||
* have an icon
|
||||
*/
|
||||
public Image getIconImage()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this frame's icon to the specified value.
|
||||
*
|
||||
* @icon The new icon for this frame.
|
||||
*/
|
||||
public synchronized void
|
||||
setIconImage(Image icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setIconImage(icon);
|
||||
}
|
||||
/**
|
||||
* Sets this frame's icon to the specified value.
|
||||
*
|
||||
* @icon the new icon for this frame
|
||||
*/
|
||||
public synchronized void setIconImage(Image icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setIconImage(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this frame's menu bar.
|
||||
*
|
||||
* @return This frame's menu bar, or <code>null</code> if this frame
|
||||
* does not have a menu bar.
|
||||
*/
|
||||
public MenuBar
|
||||
getMenuBar()
|
||||
{
|
||||
return(menuBar);
|
||||
}
|
||||
/**
|
||||
* Returns this frame's menu bar.
|
||||
*
|
||||
* @return this frame's menu bar, or <code>null</code> if this frame
|
||||
* does not have a menu bar
|
||||
*/
|
||||
public MenuBar getMenuBar()
|
||||
{
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this frame's menu bar.
|
||||
*
|
||||
* @param menuBar The new menu bar for this frame.
|
||||
*/
|
||||
public synchronized void
|
||||
setMenuBar(MenuBar menuBar)
|
||||
{
|
||||
if (peer != null)
|
||||
/**
|
||||
* Sets this frame's menu bar. Removes any existing menu bar. If the
|
||||
* given menu bar is part of another frame it will be removed from
|
||||
* that frame.
|
||||
*
|
||||
* @param menuBar the new menu bar for this frame
|
||||
*/
|
||||
public synchronized void setMenuBar(MenuBar menuBar)
|
||||
{
|
||||
if (this.menuBar != null)
|
||||
this.menuBar.removeNotify();
|
||||
remove(this.menuBar);
|
||||
|
||||
this.menuBar = menuBar;
|
||||
if (menuBar != null)
|
||||
{
|
||||
MenuContainer parent = menuBar.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(menuBar);
|
||||
menuBar.setParent(this);
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.addNotify();
|
||||
invalidateTree();
|
||||
((FramePeer) peer).setMenuBar(menuBar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not this frame is resizable. This will be
|
||||
* <code>true</code> by default.
|
||||
*
|
||||
* @return <code>true</code> if this frame is resizable, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
public boolean isResizable()
|
||||
{
|
||||
return resizable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resizability of this frame to the specified value.
|
||||
*
|
||||
* @param resizable <code>true</code> to make the frame resizable,
|
||||
* <code>false</code> to make it non-resizable
|
||||
*/
|
||||
public synchronized void setResizable(boolean resizable)
|
||||
{
|
||||
this.resizable = resizable;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setResizable(resizable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cursor type of the cursor for this window. This will
|
||||
* be one of the constants in this class.
|
||||
*
|
||||
* @return the cursor type for this frame
|
||||
*
|
||||
* @deprecated Use <code>Component.getCursor()</code> instead.
|
||||
*/
|
||||
public int getCursorType()
|
||||
{
|
||||
return getCursor().getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cursor for this window to the specified type. The specified
|
||||
* type should be one of the constants in this class.
|
||||
*
|
||||
* @param type the cursor type
|
||||
*
|
||||
* @deprecated Use <code>Component.setCursor(Cursor)</code> instead.
|
||||
*/
|
||||
public void setCursor(int type)
|
||||
{
|
||||
setCursor(new Cursor(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified menu component from this frame. If it is
|
||||
* the current MenuBar it is removed from the frame. If it is a
|
||||
* Popup it is removed from this component. If it is any other menu
|
||||
* component it is ignored.
|
||||
*
|
||||
* @param menu the menu component to remove
|
||||
*/
|
||||
public void remove(MenuComponent menu)
|
||||
{
|
||||
if (menu == menuBar)
|
||||
{
|
||||
if (menuBar != null)
|
||||
{
|
||||
if (peer != null)
|
||||
{
|
||||
((FramePeer) peer).setMenuBar(null);
|
||||
menuBar.removeNotify();
|
||||
}
|
||||
menuBar.setParent(null);
|
||||
}
|
||||
menuBar = null;
|
||||
}
|
||||
else
|
||||
super.remove(menu);
|
||||
}
|
||||
|
||||
public void addNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.addNotify();
|
||||
invalidateTree ();
|
||||
((FramePeer) peer).setMenuBar(menuBar);
|
||||
if (peer == null)
|
||||
peer = getToolkit ().createFrame (this);
|
||||
|
||||
super.addNotify();
|
||||
}
|
||||
this.menuBar = menuBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not this frame is resizable. This will be
|
||||
* <code>true</code> by default.
|
||||
*
|
||||
* @return <code>true</code> if this frame is resizable, <code>false</code>
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean
|
||||
isResizable()
|
||||
{
|
||||
return(resizable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resizability of this frame to the specified value.
|
||||
*
|
||||
* @param resizable <code>true</code> to make the frame resizable,
|
||||
* <code>false</code> to make it non-resizable.
|
||||
*/
|
||||
public synchronized void
|
||||
setResizable(boolean resizable)
|
||||
{
|
||||
this.resizable = resizable;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setResizable(resizable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cursor type of the cursor for this window. This will
|
||||
* be one of the constants in this class.
|
||||
*
|
||||
* @return The cursor type for this frame.
|
||||
*
|
||||
* @deprecated Use <code>Component.getCursor()</code> instead.
|
||||
*/
|
||||
public int
|
||||
getCursorType()
|
||||
{
|
||||
return(getCursor().getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cursor for this window to the specified type. The specified
|
||||
* type should be one of the constants in this class.
|
||||
*
|
||||
* @param type The cursor type.
|
||||
*
|
||||
* @deprecated Use <code>Component.setCursor(Cursor)</code> instead.
|
||||
*/
|
||||
public void
|
||||
setCursor(int type)
|
||||
{
|
||||
setCursor(new Cursor(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified component from this frame's menu.
|
||||
*
|
||||
* @param menu The menu component to remove.
|
||||
*/
|
||||
public void
|
||||
remove(MenuComponent menu)
|
||||
{
|
||||
menuBar.remove(menu);
|
||||
}
|
||||
|
||||
public void
|
||||
addNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.addNotify();
|
||||
if (peer == null)
|
||||
peer = getToolkit ().createFrame (this);
|
||||
|
||||
super.addNotify();
|
||||
}
|
||||
|
||||
public void removeNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.removeNotify();
|
||||
super.removeNotify();
|
||||
}
|
||||
public void removeNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.removeNotify();
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a debugging string describing this window.
|
||||
*
|
||||
* @return A debugging string describing this window.
|
||||
* @return a debugging string describing this window
|
||||
*/
|
||||
protected String paramString ()
|
||||
protected String paramString()
|
||||
{
|
||||
String title = getTitle ();
|
||||
String title = getTitle();
|
||||
|
||||
String resizable = "";
|
||||
if (isResizable ())
|
||||
|
@ -455,17 +481,17 @@ public void removeNotify()
|
|||
return super.paramString () + ",title=" + title + resizable + state;
|
||||
}
|
||||
|
||||
private static ArrayList weakFrames = new ArrayList();
|
||||
private static ArrayList weakFrames = new ArrayList();
|
||||
|
||||
private static void noteFrame(Frame f)
|
||||
{
|
||||
weakFrames.add(new WeakReference(f));
|
||||
}
|
||||
private static void noteFrame(Frame f)
|
||||
{
|
||||
weakFrames.add(new WeakReference(f));
|
||||
}
|
||||
|
||||
public static Frame[] getFrames()
|
||||
{
|
||||
int n = 0;
|
||||
synchronized (weakFrames)
|
||||
public static Frame[] getFrames()
|
||||
{
|
||||
int n = 0;
|
||||
synchronized (weakFrames)
|
||||
{
|
||||
Iterator i = weakFrames.iterator();
|
||||
while (i.hasNext())
|
||||
|
@ -490,32 +516,31 @@ public static Frame[] getFrames()
|
|||
return frames;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setState (int state)
|
||||
public void setState(int state)
|
||||
{
|
||||
int current_state = getExtendedState ();
|
||||
|
||||
if (state == NORMAL
|
||||
&& (current_state & ICONIFIED) != 0)
|
||||
setExtendedState (current_state | ICONIFIED);
|
||||
setExtendedState(current_state | ICONIFIED);
|
||||
|
||||
if (state == ICONIFIED
|
||||
&& (current_state & ~ICONIFIED) == 0)
|
||||
setExtendedState (current_state & ~ICONIFIED);
|
||||
setExtendedState(current_state & ~ICONIFIED);
|
||||
}
|
||||
|
||||
public int getState ()
|
||||
public int getState()
|
||||
{
|
||||
/* FIXME: State might have changed in the peer... Must check. */
|
||||
|
||||
// FIXME: State might have changed in the peer... Must check.
|
||||
return (state & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public void setExtendedState (int state)
|
||||
public void setExtendedState(int state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
@ -523,7 +548,7 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public int getExtendedState ()
|
||||
public int getExtendedState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
@ -531,7 +556,7 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public void setMaximizedBounds (Rectangle maximizedBounds)
|
||||
public void setMaximizedBounds(Rectangle maximizedBounds)
|
||||
{
|
||||
this.maximizedBounds = maximizedBounds;
|
||||
}
|
||||
|
@ -539,11 +564,11 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* Returns the maximized bounds of this frame.
|
||||
*
|
||||
* @return the maximized rectangle, may be null.
|
||||
* @return the maximized rectangle, may be null
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public Rectangle getMaximizedBounds ()
|
||||
public Rectangle getMaximizedBounds()
|
||||
{
|
||||
return maximizedBounds;
|
||||
}
|
||||
|
@ -553,7 +578,7 @@ public static Frame[] getFrames()
|
|||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public boolean isUndecorated ()
|
||||
public boolean isUndecorated()
|
||||
{
|
||||
return undecorated;
|
||||
}
|
||||
|
@ -562,14 +587,14 @@ public static Frame[] getFrames()
|
|||
* Disables or enables decorations for this frame. This method can only be
|
||||
* called while the frame is not displayable.
|
||||
*
|
||||
* @exception IllegalComponentStateException If this frame is displayable.
|
||||
* @throws IllegalComponentStateException if this frame is displayable
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public void setUndecorated (boolean undecorated)
|
||||
public void setUndecorated(boolean undecorated)
|
||||
{
|
||||
if (isDisplayable ())
|
||||
throw new IllegalComponentStateException ();
|
||||
if (isDisplayable())
|
||||
throw new IllegalComponentStateException();
|
||||
|
||||
this.undecorated = undecorated;
|
||||
}
|
||||
|
@ -577,14 +602,14 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* Generate a unique name for this frame.
|
||||
*
|
||||
* @return A unique name for this frame.
|
||||
* @return a unique name for this frame
|
||||
*/
|
||||
String generateName ()
|
||||
String generateName()
|
||||
{
|
||||
return "frame" + getUniqueLong ();
|
||||
return "frame" + getUniqueLong();
|
||||
}
|
||||
|
||||
private static synchronized long getUniqueLong ()
|
||||
private static synchronized long getUniqueLong()
|
||||
{
|
||||
return next_frame_number++;
|
||||
}
|
||||
|
@ -617,10 +642,9 @@ public static Frame[] getFrames()
|
|||
*/
|
||||
public AccessibleContext getAccessibleContext()
|
||||
{
|
||||
/* Create the context if this is the first request */
|
||||
// Create the context if this is the first request.
|
||||
if (accessibleContext == null)
|
||||
accessibleContext = new AccessibleAWTFrame();
|
||||
return accessibleContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -99,12 +99,32 @@ public class Insets implements Cloneable, Serializable
|
|||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the contents of this Insets object to the specified values.
|
||||
*
|
||||
* @param top the top inset
|
||||
* @param left the left inset
|
||||
* @param bottom the bottom inset
|
||||
* @param right the right inset
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void set(int top, int left, int bottom, int right)
|
||||
{
|
||||
this.top = top;
|
||||
this.left = left;
|
||||
this.bottom = bottom;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether this object is equal to the specified object. The other
|
||||
* object must be an instance of Insets with identical field values.
|
||||
*
|
||||
* @param obj the object to test against
|
||||
* @return true if the specified object is equal to this one
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
|
|
200
libjava/classpath/java/awt/LightweightDispatcher.java
Normal file
200
libjava/classpath/java/awt/LightweightDispatcher.java
Normal file
|
@ -0,0 +1,200 @@
|
|||
/* LightweightDispatcher.java -- Dispatches mouse events to lightweights
|
||||
Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 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;
|
||||
|
||||
import gnu.java.awt.AWTUtilities;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* Redispatches mouse events to lightweight components. The native peers know
|
||||
* nothing about the lightweight components and thus mouse events are always
|
||||
* targetted at Windows or heavyweight components. This class listenes directly
|
||||
* on the eventqueue and dispatches mouse events to lightweight components.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
class LightweightDispatcher
|
||||
{
|
||||
|
||||
/**
|
||||
* Maps thread groups to lightweight dispatcher instances. We need to
|
||||
* have one instance per thread group so that 2 or more applets or otherwise
|
||||
* separated applications (like in OSGI) do not interfer with each other.
|
||||
*/
|
||||
private static WeakHashMap instances = new WeakHashMap();
|
||||
|
||||
/**
|
||||
* The component that is the start of a mouse dragging. All MOUSE_DRAGGED
|
||||
* events that follow the initial press must have the source set to this,
|
||||
* as well as the MOUSE_RELEASED event following the dragging.
|
||||
*/
|
||||
private Component dragTarget;
|
||||
|
||||
/**
|
||||
* The last mouse event target. If the target changes, additional
|
||||
* MOUSE_ENTERED and MOUSE_EXITED events must be dispatched.
|
||||
*/
|
||||
private Component lastTarget;
|
||||
|
||||
/**
|
||||
* Returns an instance of LightweightDispatcher for the current thread's
|
||||
* thread group.
|
||||
*
|
||||
* @return an instance of LightweightDispatcher for the current thread's
|
||||
* thread group
|
||||
*/
|
||||
static LightweightDispatcher getInstance()
|
||||
{
|
||||
Thread t = Thread.currentThread();
|
||||
ThreadGroup tg = t.getThreadGroup();
|
||||
LightweightDispatcher instance = (LightweightDispatcher) instances.get(tg);
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new LightweightDispatcher();
|
||||
instances.put(tg, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new LightweightDispatcher. This is private to prevent access
|
||||
* from outside. Use {@link #getInstance()} instead.
|
||||
*/
|
||||
private LightweightDispatcher()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives notification if a mouse event passes along the eventqueue.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
public boolean dispatchEvent(AWTEvent event)
|
||||
{
|
||||
boolean dispatched = false;
|
||||
if (event instanceof MouseEvent && event.getSource() instanceof Window)
|
||||
{
|
||||
MouseEvent mouseEvent = (MouseEvent) event;
|
||||
handleMouseEvent(mouseEvent);
|
||||
dispatched = true;
|
||||
}
|
||||
return dispatched;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all mouse events that are targetted at toplevel containers
|
||||
* (Window instances) and dispatches them to the correct lightweight child.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
private void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
Window window = (Window) ev.getSource();
|
||||
Component target = window.findComponentAt(ev.getX(), ev.getY());
|
||||
if (target != null && target.isLightweight())
|
||||
{
|
||||
// Dispatch additional MOUSE_EXITED and MOUSE_ENTERED if event target
|
||||
// is different from the last event target.
|
||||
if (target != lastTarget)
|
||||
{
|
||||
if (lastTarget != null)
|
||||
{
|
||||
Point p1 = AWTUtilities.convertPoint(window, ev.getX(),
|
||||
ev.getY(), lastTarget);
|
||||
MouseEvent mouseExited =
|
||||
new MouseEvent(lastTarget, MouseEvent.MOUSE_EXITED,
|
||||
ev.getWhen(), ev.getModifiers(), p1.x, p1.y,
|
||||
ev.getClickCount(), ev.isPopupTrigger());
|
||||
lastTarget.dispatchEvent(mouseExited);
|
||||
}
|
||||
Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
|
||||
target);
|
||||
MouseEvent mouseEntered =
|
||||
new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
|
||||
ev.getModifiers(), p.x, p.y, ev.getClickCount(),
|
||||
ev.isPopupTrigger());
|
||||
target.dispatchEvent(mouseEntered);
|
||||
}
|
||||
|
||||
switch (ev.getID())
|
||||
{
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
dragTarget = target;
|
||||
break;
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
if (dragTarget != null)
|
||||
target = dragTarget;
|
||||
dragTarget = null;
|
||||
break;
|
||||
case MouseEvent.MOUSE_CLICKED:
|
||||
// When we receive a MOUSE_CLICKED, we set the target to the
|
||||
// previous target, which must have been a MOUSE_RELEASED event.
|
||||
// This is necessary for the case when the MOUSE_RELEASED has
|
||||
// caused the original target (like an internal component) go
|
||||
// away.
|
||||
target = lastTarget;
|
||||
break;
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
target = dragTarget;
|
||||
break;
|
||||
default:
|
||||
// Do nothing in other cases.
|
||||
break;
|
||||
}
|
||||
|
||||
lastTarget = target;
|
||||
|
||||
Point targetCoordinates =
|
||||
AWTUtilities.convertPoint(window, ev.getX(), ev.getY(), target);
|
||||
int dx = targetCoordinates.x - ev.getX();
|
||||
int dy = targetCoordinates.y - ev.getY();
|
||||
ev.translatePoint(dx, dy);
|
||||
ev.setSource(target);
|
||||
target.dispatchEvent(ev);
|
||||
|
||||
// We reset the event, so that the normal event dispatching is not
|
||||
// influenced by this modified event.
|
||||
ev.setSource(window);
|
||||
ev.translatePoint(-dx, -dy);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* Menu.java -- A Java AWT Menu
|
||||
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.
|
||||
|
||||
|
@ -220,15 +220,16 @@ getItem(int index)
|
|||
public MenuItem
|
||||
add(MenuItem item)
|
||||
{
|
||||
MenuContainer parent = item.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(item);
|
||||
|
||||
items.addElement(item);
|
||||
if (item.parent != null)
|
||||
{
|
||||
item.parent.remove(item);
|
||||
}
|
||||
item.parent = this;
|
||||
item.setParent(this);
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
item.addNotify();
|
||||
MenuPeer mp = (MenuPeer) peer;
|
||||
mp.addItem(item);
|
||||
}
|
||||
|
@ -266,26 +267,33 @@ insert(MenuItem item, int index)
|
|||
if (index < 0)
|
||||
throw new IllegalArgumentException("Index is less than zero");
|
||||
|
||||
MenuPeer peer = (MenuPeer) getPeer();
|
||||
if (peer == null)
|
||||
return;
|
||||
|
||||
int count = getItemCount ();
|
||||
|
||||
if (index >= count)
|
||||
peer.addItem (item);
|
||||
add(item);
|
||||
else
|
||||
{
|
||||
for (int i = count - 1; i >= index; i--)
|
||||
peer.delItem (i);
|
||||
MenuContainer parent = item.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(item);
|
||||
|
||||
items.insertElementAt(item, index);
|
||||
item.setParent(this);
|
||||
|
||||
peer.addItem (item);
|
||||
MenuPeer peer = (MenuPeer) getPeer();
|
||||
if (peer == null)
|
||||
return;
|
||||
|
||||
for (int i = count - 1; i >= index; i--)
|
||||
peer.delItem(i);
|
||||
|
||||
item.addNotify();
|
||||
peer.addItem(item);
|
||||
|
||||
for (int i = index; i < count; i++)
|
||||
peer.addItem ((MenuItem) items.elementAt (i));
|
||||
peer.addItem((MenuItem) items.elementAt (i));
|
||||
}
|
||||
|
||||
items.insertElementAt(item, index);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -344,11 +352,15 @@ insertSeparator(int index)
|
|||
public synchronized void
|
||||
remove(int index)
|
||||
{
|
||||
items.removeElementAt(index);
|
||||
MenuItem item = (MenuItem) items.remove(index);
|
||||
|
||||
MenuPeer mp = (MenuPeer)getPeer();
|
||||
MenuPeer mp = (MenuPeer) getPeer();
|
||||
if (mp != null)
|
||||
mp.delItem(index);
|
||||
{
|
||||
mp.delItem(index);
|
||||
item.removeNotify();
|
||||
}
|
||||
item.setParent(null);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -393,14 +405,21 @@ removeAll()
|
|||
public void
|
||||
addNotify()
|
||||
{
|
||||
MenuPeer peer = (MenuPeer) getPeer();
|
||||
if (peer == null)
|
||||
peer = getToolkit().createMenu(this);
|
||||
{
|
||||
peer = getToolkit().createMenu(this);
|
||||
setPeer(peer);
|
||||
}
|
||||
|
||||
Enumeration e = items.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
MenuItem mi = (MenuItem)e.nextElement();
|
||||
mi.addNotify();
|
||||
}
|
||||
peer.addItem(mi);
|
||||
}
|
||||
|
||||
super.addNotify ();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* MenuBar.java -- An AWT menu bar class
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,7 +40,6 @@ exception statement from your version. */
|
|||
package java.awt;
|
||||
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
import java.awt.peer.MenuComponentPeer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Enumeration;
|
||||
|
@ -60,364 +60,311 @@ public class MenuBar extends MenuComponent
|
|||
implements MenuContainer, Serializable, Accessible
|
||||
{
|
||||
|
||||
/*
|
||||
* Static Variables
|
||||
*/
|
||||
|
||||
// Serialization Constant
|
||||
private static final long serialVersionUID = -4930327919388951260L;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* @serial The menu used for providing help information
|
||||
*/
|
||||
private Menu helpMenu;
|
||||
|
||||
/**
|
||||
* @serial The menus contained in this menu bar.
|
||||
*/
|
||||
private Vector menus = new Vector();
|
||||
//Serialization Constant
|
||||
private static final long serialVersionUID = -4930327919388951260L;
|
||||
|
||||
/**
|
||||
* The accessible context for this component.
|
||||
*
|
||||
* @see #getAccessibleContext()
|
||||
* @serial ignored.
|
||||
* @serial The menu used for providing help information
|
||||
*/
|
||||
private transient AccessibleContext accessibleContext;
|
||||
private Menu helpMenu;
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* @serial The menus contained in this menu bar.
|
||||
*/
|
||||
private Vector menus = new Vector();
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>MenuBar</code>.
|
||||
*
|
||||
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
||||
*/
|
||||
public
|
||||
MenuBar()
|
||||
{
|
||||
if (GraphicsEnvironment.isHeadless())
|
||||
throw new HeadlessException ();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the help menu for this menu bar. This may be <code>null</code>.
|
||||
*
|
||||
* @return The help menu for this menu bar.
|
||||
*/
|
||||
public Menu
|
||||
getHelpMenu()
|
||||
{
|
||||
return(helpMenu);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Sets the help menu for this menu bar.
|
||||
*
|
||||
* @param menu The new help menu for this menu bar.
|
||||
*/
|
||||
public synchronized void
|
||||
setHelpMenu(Menu menu)
|
||||
{
|
||||
if (helpMenu != null)
|
||||
{
|
||||
helpMenu.removeNotify ();
|
||||
helpMenu.parent = null;
|
||||
}
|
||||
helpMenu = menu;
|
||||
|
||||
if (menu.parent != null)
|
||||
menu.parent.remove (menu);
|
||||
menu.parent = this;
|
||||
|
||||
MenuBarPeer peer = (MenuBarPeer) getPeer ();
|
||||
if (peer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
peer.addHelpMenu (menu);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/** Add a menu to this MenuBar. If the menu has already has a
|
||||
* parent, it is first removed from its old parent before being
|
||||
* added.
|
||||
*
|
||||
* @param menu The menu to add.
|
||||
*
|
||||
* @return The menu that was added.
|
||||
*/
|
||||
public synchronized Menu
|
||||
add(Menu menu)
|
||||
{
|
||||
if (menu.parent != null)
|
||||
menu.parent.remove (menu);
|
||||
|
||||
menu.parent = this;
|
||||
menus.addElement(menu);
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
}
|
||||
|
||||
return(menu);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Removes the menu at the specified index.
|
||||
*
|
||||
* @param index The index of the menu to remove from the menu bar.
|
||||
*/
|
||||
public synchronized void
|
||||
remove(int index)
|
||||
{
|
||||
Menu m = (Menu) menus.get (index);
|
||||
menus.remove (index);
|
||||
m.removeNotify ();
|
||||
m.parent = null;
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
MenuBarPeer mp = (MenuBarPeer) peer;
|
||||
mp.delMenu (index);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Removes the specified menu from the menu bar.
|
||||
*
|
||||
* @param menu The menu to remove from the menu bar.
|
||||
*/
|
||||
public void
|
||||
remove(MenuComponent menu)
|
||||
{
|
||||
int index = menus.indexOf(menu);
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
remove(index);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return The number of elements in the menu bar.
|
||||
*/
|
||||
public int
|
||||
getMenuCount()
|
||||
{
|
||||
return countMenus ();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return The number of elements in the menu bar.
|
||||
*
|
||||
* @deprecated This method is deprecated in favor of <code>getMenuCount()</code>.
|
||||
*/
|
||||
public int
|
||||
countMenus()
|
||||
{
|
||||
return menus.size () + (getHelpMenu () == null ? 0 : 1);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the menu at the specified index.
|
||||
*
|
||||
* @param index the index of the menu
|
||||
*
|
||||
* @return The requested menu.
|
||||
*
|
||||
* @exception ArrayIndexOutOfBoundsException If the index is not valid.
|
||||
*/
|
||||
public Menu
|
||||
getMenu(int index)
|
||||
{
|
||||
return((Menu)menus.elementAt(index));
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Creates this object's native peer.
|
||||
*/
|
||||
public void
|
||||
addNotify()
|
||||
{
|
||||
if (getPeer() == null)
|
||||
setPeer((MenuComponentPeer)getToolkit().createMenuBar(this));
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
/**
|
||||
* Initializes a new instance of <code>MenuBar</code>.
|
||||
*
|
||||
* @throws HeadlessException if GraphicsEnvironment.isHeadless() is true
|
||||
*/
|
||||
public MenuBar()
|
||||
{
|
||||
Menu mi = (Menu)e.nextElement();
|
||||
mi.addNotify();
|
||||
if (GraphicsEnvironment.isHeadless())
|
||||
throw new HeadlessException();
|
||||
}
|
||||
if (helpMenu != null)
|
||||
|
||||
/**
|
||||
* Returns the help menu for this menu bar. This may be <code>null</code>.
|
||||
*
|
||||
* @return the help menu for this menu bar
|
||||
*/
|
||||
public Menu getHelpMenu()
|
||||
{
|
||||
helpMenu.addNotify();
|
||||
((MenuBarPeer) peer).addHelpMenu(helpMenu);
|
||||
return helpMenu;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Destroys this object's native peer.
|
||||
*/
|
||||
public void
|
||||
removeNotify()
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
/**
|
||||
* Sets the help menu for this menu bar.
|
||||
*
|
||||
* @param menu the new help menu for this menu bar
|
||||
*/
|
||||
public synchronized void setHelpMenu(Menu menu)
|
||||
{
|
||||
Menu mi = (Menu) e.nextElement();
|
||||
mi.removeNotify();
|
||||
MenuBarPeer myPeer = (MenuBarPeer) getPeer ();
|
||||
|
||||
if (helpMenu != null)
|
||||
{
|
||||
if (myPeer != null)
|
||||
helpMenu.removeNotify();
|
||||
helpMenu.setParent(null);
|
||||
}
|
||||
helpMenu = menu;
|
||||
|
||||
MenuContainer parent = menu.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(menu);
|
||||
menu.setParent(this);
|
||||
|
||||
if (myPeer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
myPeer.addHelpMenu(menu);
|
||||
}
|
||||
}
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Add a menu to this MenuBar. If the menu has already has a
|
||||
* parent, it is first removed from its old parent before being
|
||||
* added.
|
||||
*
|
||||
* @param menu the menu to add
|
||||
*
|
||||
* @return the menu that was added
|
||||
*/
|
||||
public synchronized Menu add(Menu menu)
|
||||
{
|
||||
MenuBarPeer myPeer = (MenuBarPeer) getPeer ();
|
||||
|
||||
/**
|
||||
* Returns a list of all shortcuts for the menus in this menu bar.
|
||||
*
|
||||
* @return A list of all shortcuts for the menus in this menu bar.
|
||||
*/
|
||||
public synchronized Enumeration
|
||||
shortcuts()
|
||||
{
|
||||
Vector shortcuts = new Vector();
|
||||
Enumeration e = menus.elements();
|
||||
MenuContainer parent = menu.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(menu);
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu)e.nextElement();
|
||||
if (menu.getShortcut() != null)
|
||||
shortcuts.addElement(menu.getShortcut());
|
||||
}
|
||||
menus.addElement(menu);
|
||||
menu.setParent(this);
|
||||
|
||||
return(shortcuts.elements());
|
||||
}
|
||||
if (myPeer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
myPeer.addMenu(menu);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Removes the menu at the specified index.
|
||||
*
|
||||
* @param index the index of the menu to remove from the menu bar
|
||||
*/
|
||||
public synchronized void remove(int index)
|
||||
{
|
||||
Menu m = (Menu) menus.remove(index);
|
||||
MenuBarPeer mp = (MenuBarPeer) getPeer();
|
||||
|
||||
/**
|
||||
* Returns the menu item for the specified shortcut, or <code>null</code>
|
||||
* if no such item exists.
|
||||
*
|
||||
* @param shortcut The shortcut to return the menu item for.
|
||||
*
|
||||
* @return The menu item for the specified shortcut.
|
||||
*/
|
||||
public MenuItem
|
||||
getShortcutMenuItem(MenuShortcut shortcut)
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
if (mp != null)
|
||||
m.removeNotify();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu)e.nextElement();
|
||||
MenuShortcut s = menu.getShortcut();
|
||||
if ((s != null) && (s.equals(shortcut)))
|
||||
return(menu);
|
||||
}
|
||||
m.setParent(null);
|
||||
|
||||
return(null);
|
||||
}
|
||||
if (mp != null)
|
||||
mp.delMenu(index);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Removes the specified menu from the menu bar.
|
||||
*
|
||||
* @param menu the menu to remove from the menu bar
|
||||
*/
|
||||
public void remove(MenuComponent menu)
|
||||
{
|
||||
int index = menus.indexOf(menu);
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
/**
|
||||
* Deletes the specified menu shortcut.
|
||||
*
|
||||
* @param shortcut The shortcut to delete.
|
||||
*/
|
||||
public void
|
||||
deleteShortcut(MenuShortcut shortcut)
|
||||
{
|
||||
MenuItem it;
|
||||
// This is a slow implementation, but it probably doesn't matter.
|
||||
while ((it = getShortcutMenuItem (shortcut)) != null)
|
||||
it.deleteShortcut ();
|
||||
}
|
||||
remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AccessibleContext associated with this <code>MenuBar</code>.
|
||||
* The context is created, if necessary.
|
||||
*
|
||||
* @return the associated context
|
||||
*/
|
||||
public AccessibleContext getAccessibleContext()
|
||||
{
|
||||
/* Create the context if this is the first request */
|
||||
if (accessibleContext == null)
|
||||
accessibleContext = new AccessibleAWTMenuBar();
|
||||
return accessibleContext;
|
||||
}
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return the number of elements in the menu bar
|
||||
*/
|
||||
public int getMenuCount()
|
||||
{
|
||||
return countMenus();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides accessibility support for AWT menu bars.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
*/
|
||||
protected class AccessibleAWTMenuBar
|
||||
extends AccessibleAWTMenuComponent
|
||||
{
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return the number of elements in the menu bar
|
||||
*
|
||||
* @deprecated This method is deprecated in favor of
|
||||
* <code>getMenuCount()</code>.
|
||||
*/
|
||||
public int countMenus()
|
||||
{
|
||||
return menus.size() + (getHelpMenu() == null ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the menu at the specified index.
|
||||
*
|
||||
* @param index the index of the menu
|
||||
*
|
||||
* @return the requested menu
|
||||
*
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is not valid
|
||||
*/
|
||||
public Menu getMenu(int index)
|
||||
{
|
||||
return (Menu) menus.elementAt(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates this object's native peer.
|
||||
*/
|
||||
public void addNotify()
|
||||
{
|
||||
MenuBarPeer peer = (MenuBarPeer) getPeer();
|
||||
if (peer == null)
|
||||
{
|
||||
peer = getToolkit().createMenuBar(this);
|
||||
setPeer(peer);
|
||||
}
|
||||
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu mi = (Menu)e.nextElement();
|
||||
mi.addNotify();
|
||||
peer.addMenu(mi);
|
||||
}
|
||||
|
||||
if (helpMenu != null)
|
||||
{
|
||||
helpMenu.addNotify();
|
||||
peer.addHelpMenu(helpMenu);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys this object's native peer.
|
||||
*/
|
||||
public void removeNotify()
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu mi = (Menu) e.nextElement();
|
||||
mi.removeNotify();
|
||||
}
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all shortcuts for the menus in this menu bar.
|
||||
*
|
||||
* @return a list of all shortcuts for the menus in this menu bar
|
||||
*/
|
||||
public synchronized Enumeration shortcuts()
|
||||
{
|
||||
Vector shortcuts = new Vector();
|
||||
Enumeration e = menus.elements();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu)e.nextElement();
|
||||
if (menu.getShortcut() != null)
|
||||
shortcuts.addElement(menu.getShortcut());
|
||||
}
|
||||
|
||||
return shortcuts.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the menu item for the specified shortcut, or <code>null</code>
|
||||
* if no such item exists.
|
||||
*
|
||||
* @param shortcut the shortcut to return the menu item for
|
||||
*
|
||||
* @return the menu item for the specified shortcut
|
||||
*/
|
||||
public MenuItem getShortcutMenuItem(MenuShortcut shortcut)
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu) e.nextElement();
|
||||
MenuShortcut s = menu.getShortcut();
|
||||
if ((s != null) && s.equals(shortcut))
|
||||
return menu;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified menu shortcut.
|
||||
*
|
||||
* @param shortcut the shortcut to delete
|
||||
*/
|
||||
public void deleteShortcut(MenuShortcut shortcut)
|
||||
{
|
||||
MenuItem it;
|
||||
// This is a slow implementation, but it probably doesn't matter.
|
||||
while ((it = getShortcutMenuItem (shortcut)) != null)
|
||||
it.deleteShortcut();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AccessibleContext associated with this <code>MenuBar</code>.
|
||||
* The context is created, if necessary.
|
||||
*
|
||||
* @return the associated context
|
||||
*/
|
||||
public AccessibleContext getAccessibleContext()
|
||||
{
|
||||
// Create the context if this is the first request.
|
||||
if (accessibleContext == null)
|
||||
accessibleContext = new AccessibleAWTMenuBar();
|
||||
return accessibleContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides accessibility support for AWT menu bars.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
*/
|
||||
protected class AccessibleAWTMenuBar
|
||||
extends AccessibleAWTMenuComponent
|
||||
{
|
||||
|
||||
/**
|
||||
* Compatible with JDK 1.4.2 revision 5
|
||||
*/
|
||||
private static final long serialVersionUID = -8577604491830083815L;
|
||||
/**
|
||||
* Compatible with JDK 1.4.2 revision 5
|
||||
*/
|
||||
private static final long serialVersionUID = -8577604491830083815L;
|
||||
|
||||
/**
|
||||
* This is the default constructor, which simply calls the default
|
||||
* constructor of the superclass.
|
||||
*/
|
||||
protected AccessibleAWTMenuBar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accessible role relating to the menu bar.
|
||||
*
|
||||
* @return <code>AccessibleRole.MENU_BAR</code>
|
||||
*/
|
||||
public AccessibleRole getAccessibleRole()
|
||||
{
|
||||
return AccessibleRole.MENU_BAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the default constructor, which simply calls the default
|
||||
* constructor of the superclass.
|
||||
*/
|
||||
protected AccessibleAWTMenuBar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accessible role relating to the menu bar.
|
||||
*
|
||||
* @return <code>AccessibleRole.MENU_BAR</code>.
|
||||
*/
|
||||
public AccessibleRole getAccessibleRole()
|
||||
{
|
||||
return AccessibleRole.MENU_BAR;
|
||||
}
|
||||
|
||||
} // class AccessibleAWTMenuBar
|
||||
|
||||
} // class MenuBar
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/* Scrollbar.java -- AWT Scrollbar widget
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
@ -593,13 +593,33 @@ public class Scrollbar extends Component implements Accessible, Adjustable
|
|||
adjustment_listeners.adjustmentValueChanged(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Package private method to determine whether to call
|
||||
* processEvent() or not. Will handle events from peer and update
|
||||
* the current value.
|
||||
*/
|
||||
void dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
if (e.id <= AdjustmentEvent.ADJUSTMENT_LAST
|
||||
&& e.id >= AdjustmentEvent.ADJUSTMENT_FIRST
|
||||
&& (adjustment_listeners != null
|
||||
|| (eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
&& e.id >= AdjustmentEvent.ADJUSTMENT_FIRST)
|
||||
{
|
||||
AdjustmentEvent ae = (AdjustmentEvent) e;
|
||||
boolean adjusting = ae.getValueIsAdjusting();
|
||||
if (adjusting)
|
||||
setValueIsAdjusting(true);
|
||||
try
|
||||
{
|
||||
setValue(((AdjustmentEvent) e).getValue());
|
||||
if (adjustment_listeners != null
|
||||
|| (eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0)
|
||||
processEvent(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (adjusting)
|
||||
setValueIsAdjusting(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
|
|
|
@ -397,6 +397,7 @@ addNotify()
|
|||
return;
|
||||
|
||||
setPeer((ComponentPeer)getToolkit().createTextField(this));
|
||||
super.addNotify();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
|
|
@ -39,6 +39,8 @@ exception statement from your version. */
|
|||
|
||||
package java.awt;
|
||||
|
||||
import gnu.java.awt.peer.GLightweightPeer;
|
||||
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
|
@ -46,6 +48,7 @@ import java.awt.dnd.DragGestureRecognizer;
|
|||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.AWTEventListenerProxy;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.im.InputMethodHighlight;
|
||||
import java.awt.image.ColorModel;
|
||||
|
@ -76,6 +79,7 @@ import java.awt.peer.WindowPeer;
|
|||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -113,11 +117,18 @@ public abstract class Toolkit
|
|||
protected final PropertyChangeSupport desktopPropsSupport
|
||||
= new PropertyChangeSupport(this);
|
||||
|
||||
/**
|
||||
* All registered AWTEventListener objects. This is package private, so the
|
||||
* event queue can efficiently access this list.
|
||||
*/
|
||||
AWTEventListenerProxy[] awtEventListeners;
|
||||
|
||||
/**
|
||||
* Default constructor for subclasses.
|
||||
*/
|
||||
public Toolkit()
|
||||
{
|
||||
awtEventListeners = new AWTEventListenerProxy[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,7 +360,7 @@ public abstract class Toolkit
|
|||
*/
|
||||
protected LightweightPeer createComponent(Component target)
|
||||
{
|
||||
return new gnu.java.awt.peer.GLightweightPeer (target);
|
||||
return new GLightweightPeer(target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,7 +473,7 @@ public abstract class Toolkit
|
|||
*/
|
||||
public Insets getScreenInsets(GraphicsConfiguration gc)
|
||||
{
|
||||
return null;
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -965,33 +976,230 @@ public abstract class Toolkit
|
|||
return desktopPropsSupport.getPropertyChangeListeners(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an AWTEventListener to this toolkit. This listener is informed about
|
||||
* all events that pass the eventqueue that match the specified
|
||||
* <code>evenMask</code>. The <code>eventMask</code> is an ORed combination
|
||||
* of event masks as defined in {@link AWTEvent}.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @param listener the listener to add
|
||||
* @param eventMask the event mask of event types which the listener is
|
||||
* interested in
|
||||
*
|
||||
* @since 1.2
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
* @see #getAWTEventListeners()
|
||||
* @see #getAWTEventListeners(long)
|
||||
* @see #removeAWTEventListener(AWTEventListener)
|
||||
*/
|
||||
public void addAWTEventListener(AWTEventListener listener, long eventMask)
|
||||
{
|
||||
// SecurityManager s = System.getSecurityManager();
|
||||
// if (s != null)
|
||||
// s.checkPermission(AWTPermission("listenToAllAWTEvents"));
|
||||
// FIXME
|
||||
}
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
public void removeAWTEventListener(AWTEventListener listener)
|
||||
{
|
||||
// FIXME
|
||||
// Go through the list and check if the requested listener is already
|
||||
// registered.
|
||||
boolean found = false;
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
AWTEventListenerProxy proxy = awtEventListeners[i];
|
||||
if (proxy.getListener() == listener)
|
||||
{
|
||||
found = true;
|
||||
// Modify the proxies event mask to include the new event mask.
|
||||
AWTEventListenerProxy newProxy =
|
||||
new AWTEventListenerProxy(proxy.getEventMask() | eventMask,
|
||||
listener);
|
||||
awtEventListeners[i] = newProxy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If that listener was not found, then add it.
|
||||
if (! found)
|
||||
{
|
||||
AWTEventListenerProxy proxy =
|
||||
new AWTEventListenerProxy(eventMask, listener);
|
||||
AWTEventListenerProxy[] newArray =
|
||||
new AWTEventListenerProxy[awtEventListeners.length + 1];
|
||||
System.arraycopy(awtEventListeners, 0, newArray, 0,
|
||||
awtEventListeners.length);
|
||||
newArray[newArray.length - 1] = proxy;
|
||||
awtEventListeners = newArray;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an AWT event listener from this toolkit. This listener is no
|
||||
* longer informed of any event types it was registered in.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @param listener the listener to remove
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
* @since 1.2
|
||||
*
|
||||
* @see #addAWTEventListener(AWTEventListener, long)
|
||||
* @see #getAWTEventListeners()
|
||||
* @see #getAWTEventListeners(long)
|
||||
*/
|
||||
public void removeAWTEventListener(AWTEventListener listener)
|
||||
{
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
|
||||
// Find the index of the listener.
|
||||
int index = -1;
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
AWTEventListenerProxy proxy = awtEventListeners[i];
|
||||
if (proxy.getListener() == listener)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy over the arrays and leave out the removed element.
|
||||
if (index != -1)
|
||||
{
|
||||
AWTEventListenerProxy[] newArray =
|
||||
new AWTEventListenerProxy[awtEventListeners.length - 1];
|
||||
if (index > 0)
|
||||
System.arraycopy(awtEventListeners, 0, newArray, 0, index);
|
||||
if (index < awtEventListeners.length - 1)
|
||||
System.arraycopy(awtEventListeners, index + 1, newArray, index,
|
||||
awtEventListeners.length - index - 1);
|
||||
awtEventListeners = newArray;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered AWT event listeners. This method returns a copy of
|
||||
* the listener array, so that application cannot trash the listener list.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @return all registered AWT event listeners
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
* @since 1.4
|
||||
*
|
||||
* @see #addAWTEventListener(AWTEventListener, long)
|
||||
* @see #removeAWTEventListener(AWTEventListener)
|
||||
* @see #getAWTEventListeners(long)
|
||||
*/
|
||||
public AWTEventListener[] getAWTEventListeners()
|
||||
{
|
||||
return null;
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
// Create a copy of the array.
|
||||
AWTEventListener[] copy = new AWTEventListener[awtEventListeners.length];
|
||||
System.arraycopy(awtEventListeners, 0, copy, 0, awtEventListeners.length);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered AWT event listeners that listen for events with
|
||||
* the specified <code>eventMask</code>. This method returns a copy of
|
||||
* the listener array, so that application cannot trash the listener list.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @param mask the event mask
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
*
|
||||
* @since 1.4
|
||||
*
|
||||
* @see #addAWTEventListener(AWTEventListener, long)
|
||||
* @see #removeAWTEventListener(AWTEventListener)
|
||||
* @see #getAWTEventListeners()
|
||||
*/
|
||||
public AWTEventListener[] getAWTEventListeners(long mask)
|
||||
{
|
||||
return null;
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
// Create a copy of the array with only the requested listeners in it.
|
||||
ArrayList l = new ArrayList(awtEventListeners.length);
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
if ((awtEventListeners[i].getEventMask() & mask) != 0)
|
||||
l.add(awtEventListeners[i]);
|
||||
}
|
||||
|
||||
return (AWTEventListener[] ) l.toArray(new AWTEventListener[l.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dispatches events to listeners registered to this Toolkit. This is called
|
||||
* by {@link Component#dispatchEventImpl(AWTEvent)} in order to dispatch
|
||||
* events globally.
|
||||
*
|
||||
* @param ev the event to dispatch
|
||||
*/
|
||||
void globalDispatchEvent(AWTEvent ev)
|
||||
{
|
||||
// We do not use the accessor methods here because they create new
|
||||
// arrays each time. We must be very efficient, so we access this directly.
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
AWTEventListenerProxy proxy = awtEventListeners[i];
|
||||
if ((proxy.getEventMask() & AWTEvent.eventIdToMask(ev.getID())) != 0)
|
||||
proxy.eventDispatched(ev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -281,50 +281,53 @@ public class Window extends Container implements Accessible
|
|||
public void show()
|
||||
{
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
if (parent != null && !parent.isDisplayable())
|
||||
parent.addNotify();
|
||||
if (peer == null)
|
||||
addNotify();
|
||||
|
||||
// Show visible owned windows.
|
||||
Iterator e = ownedWindows.iterator();
|
||||
while(e.hasNext())
|
||||
{
|
||||
Window w = (Window)(((Reference) e.next()).get());
|
||||
if (w != null)
|
||||
{
|
||||
if (w.isVisible())
|
||||
w.getPeer().setVisible(true);
|
||||
}
|
||||
else
|
||||
// Remove null weak reference from ownedWindows.
|
||||
// Unfortunately this can't be done in the Window's
|
||||
// finalize method because there is no way to guarantee
|
||||
// synchronous access to ownedWindows there.
|
||||
e.remove();
|
||||
}
|
||||
validate();
|
||||
super.show();
|
||||
toFront();
|
||||
|
||||
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
|
||||
manager.setGlobalFocusedWindow (this);
|
||||
|
||||
if (!shown)
|
||||
{
|
||||
FocusTraversalPolicy policy = getFocusTraversalPolicy ();
|
||||
Component initialFocusOwner = null;
|
||||
if (parent != null && ! parent.isDisplayable())
|
||||
parent.addNotify();
|
||||
if (peer == null)
|
||||
addNotify();
|
||||
|
||||
if (policy != null)
|
||||
initialFocusOwner = policy.getInitialComponent (this);
|
||||
validate();
|
||||
if (visible)
|
||||
toFront();
|
||||
else
|
||||
{
|
||||
super.show();
|
||||
// Show visible owned windows.
|
||||
Iterator e = ownedWindows.iterator();
|
||||
while (e.hasNext())
|
||||
{
|
||||
Window w = (Window) (((Reference) e.next()).get());
|
||||
if (w != null)
|
||||
{
|
||||
if (w.isVisible())
|
||||
w.getPeer().setVisible(true);
|
||||
}
|
||||
else
|
||||
// Remove null weak reference from ownedWindows.
|
||||
// Unfortunately this can't be done in the Window's
|
||||
// finalize method because there is no way to guarantee
|
||||
// synchronous access to ownedWindows there.
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
manager.setGlobalFocusedWindow(this);
|
||||
|
||||
if (initialFocusOwner != null)
|
||||
initialFocusOwner.requestFocusInWindow ();
|
||||
if (! shown)
|
||||
{
|
||||
FocusTraversalPolicy policy = getFocusTraversalPolicy();
|
||||
Component initialFocusOwner = null;
|
||||
|
||||
shown = true;
|
||||
if (policy != null)
|
||||
initialFocusOwner = policy.getInitialComponent(this);
|
||||
|
||||
if (initialFocusOwner != null)
|
||||
initialFocusOwner.requestFocusInWindow();
|
||||
|
||||
shown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hide()
|
||||
|
|
|
@ -157,38 +157,42 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
|
|||
ClassLoader classLoader)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
// Bootstrap
|
||||
try
|
||||
{
|
||||
return(Class.forName(className));
|
||||
return Class.forName(className);
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
// Commented out for Java 1.1
|
||||
/*
|
||||
try
|
||||
catch(ClassNotFoundException cnfe)
|
||||
{
|
||||
return(className.getClass().getClassLoader().findClass(className));
|
||||
// Ignored.
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
|
||||
// System
|
||||
try
|
||||
{
|
||||
return(ClassLoader.getSystemClassLoader().findClass(className));
|
||||
ClassLoader loader = ClassLoader.getSystemClassLoader();
|
||||
return Class.forName(className, true, loader);
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
*/
|
||||
|
||||
// FIXME: What is the context class loader?
|
||||
/*
|
||||
catch(ClassNotFoundException cnfe)
|
||||
{
|
||||
// Ignored.
|
||||
}
|
||||
|
||||
// Context
|
||||
try
|
||||
{
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
return Class.forName(className, true, loader);
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
*/
|
||||
|
||||
catch(ClassNotFoundException cnfe)
|
||||
{
|
||||
// Ignored.
|
||||
}
|
||||
|
||||
if (classLoader != null)
|
||||
return(classLoader.loadClass(className));
|
||||
else
|
||||
throw new ClassNotFoundException(className);
|
||||
return Class.forName(className, true, classLoader);
|
||||
|
||||
throw new ClassNotFoundException(className);
|
||||
}
|
||||
|
||||
private static Class getRepresentationClassFromMime(String mimeString,
|
||||
|
@ -203,7 +207,13 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("classname: " + e.getMessage());
|
||||
IllegalArgumentException iae;
|
||||
iae = new IllegalArgumentException("mimeString: "
|
||||
+ mimeString
|
||||
+ " classLoader: "
|
||||
+ classLoader);
|
||||
iae.initCause(e);
|
||||
throw iae;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -90,7 +90,7 @@ public class DragSource implements Serializable
|
|||
*/
|
||||
public static DragSource getDefaultDragSource()
|
||||
{
|
||||
return null;
|
||||
return new DragSource();
|
||||
}
|
||||
|
||||
public static boolean isDragImageSupported()
|
||||
|
@ -172,13 +172,34 @@ public class DragSource implements Serializable
|
|||
return flavorMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy DragGestureRecognizer when Toolkit doesn't support drag and drop.
|
||||
*/
|
||||
static class NoDragGestureRecognizer extends DragGestureRecognizer
|
||||
{
|
||||
NoDragGestureRecognizer(DragSource ds, Component c, int actions,
|
||||
DragGestureListener dgl)
|
||||
{
|
||||
super(ds, c, actions, dgl);
|
||||
}
|
||||
|
||||
protected void registerListeners() { }
|
||||
protected void unregisterListeners() { }
|
||||
}
|
||||
|
||||
public DragGestureRecognizer
|
||||
createDragGestureRecognizer(Class recognizer, Component c, int actions,
|
||||
DragGestureListener dgl)
|
||||
{
|
||||
return Toolkit.getDefaultToolkit ()
|
||||
DragGestureRecognizer dgr;
|
||||
dgr = Toolkit.getDefaultToolkit ()
|
||||
.createDragGestureRecognizer (recognizer, this, c, actions,
|
||||
dgl);
|
||||
|
||||
if (dgr == null)
|
||||
dgr = new NoDragGestureRecognizer(this, c, actions, dgl);
|
||||
|
||||
return dgr;
|
||||
}
|
||||
|
||||
public DragGestureRecognizer
|
||||
|
|
BIN
libjava/classpath/java/awt/doc-files/capjoin.png
Normal file
BIN
libjava/classpath/java/awt/doc-files/capjoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -72,75 +72,15 @@ public class AWTEventListenerProxy extends EventListenerProxy
|
|||
}
|
||||
|
||||
/**
|
||||
* Forwards events on to the delegate if they meet the event mask.
|
||||
* Forwards events on to the delegate.
|
||||
*
|
||||
* @param event the to forward to the delagate listener
|
||||
*
|
||||
* @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);
|
||||
((AWTEventListener) getListener()).eventDispatched(event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,76 +59,344 @@ import java.awt.image.ImageObserver;
|
|||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
/**
|
||||
* Defines the methods that a component peer is required to implement.
|
||||
*/
|
||||
public interface ComponentPeer
|
||||
{
|
||||
/**
|
||||
* Returns the construction status of the specified image. This is called
|
||||
* by {@link Component#checkImage(Image, int, int, ImageObserver)}.
|
||||
*
|
||||
* @param img the image
|
||||
* @param width the width of the image
|
||||
* @param height the height of the image
|
||||
* @param ob the image observer to be notified of updates of the status
|
||||
*
|
||||
* @return a bitwise ORed set of ImageObserver flags
|
||||
*/
|
||||
int checkImage(Image img, int width, int height,
|
||||
ImageObserver ob);
|
||||
ImageObserver ob);
|
||||
|
||||
/**
|
||||
* Creates an image by starting the specified image producer. This is called
|
||||
* by {@link Component#createImage(ImageProducer)}.
|
||||
*
|
||||
* @param prod the image producer to be used to create the image
|
||||
*
|
||||
* @return the created image
|
||||
*/
|
||||
Image createImage(ImageProducer prod);
|
||||
|
||||
/**
|
||||
* Creates an empty image with the specified <code>width</code> and
|
||||
* <code>height</code>.
|
||||
*
|
||||
* @param width the width of the image to be created
|
||||
* @param height the height of the image to be created
|
||||
*
|
||||
* @return the created image
|
||||
*/
|
||||
Image createImage(int width, int height);
|
||||
|
||||
/**
|
||||
* Disables the component. This is called by {@link Component#disable()}.
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* Disposes the component peer. This should release all resources held by the
|
||||
* peer. This is called when the component is no longer in use.
|
||||
*/
|
||||
void dispose();
|
||||
|
||||
/**
|
||||
* Enables the component. This is called by {@link Component#enable()}.
|
||||
*/
|
||||
void enable();
|
||||
|
||||
/**
|
||||
* Returns the color model of the component. This is currently not used.
|
||||
*
|
||||
* @return the color model of the component
|
||||
*/
|
||||
ColorModel getColorModel();
|
||||
|
||||
/**
|
||||
* Returns the font metrics for the specified font. This is called by
|
||||
* {@link Component#getFontMetrics(Font)}.
|
||||
*
|
||||
* @param f the font for which to query the font metrics
|
||||
*
|
||||
* @return the font metrics for the specified font
|
||||
*/
|
||||
FontMetrics getFontMetrics(Font f);
|
||||
|
||||
/**
|
||||
* Returns a {@link Graphics} object suitable for drawing on this component.
|
||||
* This is called by {@link Component#getGraphics()}.
|
||||
*
|
||||
* @return a graphics object suitable for drawing on this component
|
||||
*/
|
||||
Graphics getGraphics();
|
||||
|
||||
/**
|
||||
* Returns the location of this component in screen coordinates. This is
|
||||
* called by {@link Component#getLocationOnScreen()}.
|
||||
*
|
||||
* @return the location of this component in screen coordinates
|
||||
*/
|
||||
Point getLocationOnScreen();
|
||||
|
||||
/**
|
||||
* Returns the minimum size for the component. This is called by
|
||||
* {@link Component#getMinimumSize()}.
|
||||
*
|
||||
* @return the minimum size for the component
|
||||
*/
|
||||
Dimension getMinimumSize();
|
||||
|
||||
/**
|
||||
* Returns the preferred size for the component. This is called by
|
||||
* {@link Component#getPreferredSize()}.
|
||||
*
|
||||
* @return the preferred size for the component
|
||||
*/
|
||||
Dimension getPreferredSize();
|
||||
|
||||
/**
|
||||
* Returns the toolkit that created this peer.
|
||||
*
|
||||
* @return the toolkit that created this peer
|
||||
*/
|
||||
Toolkit getToolkit();
|
||||
|
||||
/**
|
||||
* Handles the given event. This is called from
|
||||
* {@link Component#dispatchEvent(AWTEvent)} to give the peer a chance to
|
||||
* react to events for the component.
|
||||
*
|
||||
* @param e the event
|
||||
*/
|
||||
void handleEvent(AWTEvent e);
|
||||
|
||||
/**
|
||||
* Makes the component invisible. This is called from
|
||||
* {@link Component#hide()}.
|
||||
*/
|
||||
void hide();
|
||||
|
||||
/**
|
||||
* Part of the earlier 1.1 API, replaced by isFocusable().
|
||||
* Returns <code>true</code> if the component can receive keyboard input
|
||||
* focus. This is called from {@link Component#isFocusTraversable()}.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, replaced by isFocusable().
|
||||
*/
|
||||
boolean isFocusTraversable();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the component can receive keyboard input
|
||||
* focus. This is called from {@link Component#isFocusable()}.
|
||||
*/
|
||||
boolean isFocusable();
|
||||
|
||||
/**
|
||||
* Returns the minimum size for the component. This is called by
|
||||
* {@link Component#minimumSize()}.
|
||||
*
|
||||
* @return the minimum size for the component
|
||||
*/
|
||||
Dimension minimumSize();
|
||||
|
||||
/**
|
||||
* Returns the preferred size for the component. This is called by
|
||||
* {@link Component#getPreferredSize()}.
|
||||
*
|
||||
* @return the preferred size for the component
|
||||
*/
|
||||
Dimension preferredSize();
|
||||
|
||||
void paint(Graphics graphics);
|
||||
|
||||
/**
|
||||
* Prepares an image for rendering on this component. This is called by
|
||||
* {@link Component#prepareImage(Image, int, int, ImageObserver)}.
|
||||
*
|
||||
* @param img the image to prepare
|
||||
* @param width the desired width of the rendered image
|
||||
* @param height the desired height of the rendered image
|
||||
* @param ob the image observer to be notified of updates in the preparation
|
||||
* process
|
||||
*
|
||||
* @return <code>true</code> if the image has been fully prepared,
|
||||
* <code>false</code> otherwise (in which case the image observer
|
||||
* receives updates)
|
||||
*/
|
||||
boolean prepareImage(Image img, int width, int height,
|
||||
ImageObserver ob);
|
||||
|
||||
void print(Graphics graphics);
|
||||
|
||||
/**
|
||||
* Repaints the specified rectangle of this component. This is called from
|
||||
* {@link Component#repaint(long, int, int, int, int)}.
|
||||
*
|
||||
* @param tm number of milliseconds to wait with repainting
|
||||
* @param x the X coordinate of the upper left corner of the damaged rectangle
|
||||
* @param y the Y coordinate of the upper left corner of the damaged rectangle
|
||||
* @param width the width of the damaged rectangle
|
||||
* @param height the height of the damaged rectangle
|
||||
*/
|
||||
void repaint(long tm, int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Part of the earlier 1.1 API, apparently replaced by argument
|
||||
* form of the same method.
|
||||
* Requests that this component receives the focus. This is called from
|
||||
* {@link Component#requestFocus()}.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, apparently replaced by argument
|
||||
* form of the same method.
|
||||
*/
|
||||
void requestFocus();
|
||||
boolean requestFocus (Component source, boolean bool1, boolean bool2, long x);
|
||||
|
||||
/**
|
||||
* Requests that this component receives the focus. This is called from
|
||||
* {@link Component#requestFocus()}.
|
||||
*
|
||||
* @param source TODO
|
||||
* @param bool1 TODO
|
||||
* @param bool2 TODO
|
||||
* @param x TODO
|
||||
*/
|
||||
boolean requestFocus(Component source, boolean bool1, boolean bool2, long x);
|
||||
|
||||
/**
|
||||
* Notifies the peer that the bounds of this component have changed. This
|
||||
* is called by {@link Component#reshape(int, int, int, int)}.
|
||||
*
|
||||
* @param x the X coordinate of the upper left corner of the component
|
||||
* @param y the Y coordinate of the upper left corner of the component
|
||||
* @param width the width of the component
|
||||
* @param height the height of the component
|
||||
*/
|
||||
void reshape(int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Sets the background color of the component. This is called by
|
||||
* {@link Component#setBackground(Color)}.
|
||||
*
|
||||
* @param color the background color to set
|
||||
*/
|
||||
void setBackground(Color color);
|
||||
|
||||
/**
|
||||
* Notifies the peer that the bounds of this component have changed. This
|
||||
* is called by {@link Component#setBounds(int, int, int, int)}.
|
||||
*
|
||||
* @param x the X coordinate of the upper left corner of the component
|
||||
* @param y the Y coordinate of the upper left corner of the component
|
||||
* @param width the width of the component
|
||||
* @param height the height of the component
|
||||
*/
|
||||
void setBounds(int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Part of the earlier 1.1 API, apparently no longer needed.
|
||||
* Sets the cursor of the component. This is called by
|
||||
* {@link Component#setCursor(Cursor)}.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, apparently no longer needed.
|
||||
*/
|
||||
void setCursor(Cursor cursor);
|
||||
|
||||
/**
|
||||
* Sets the enabled/disabled state of this component. This is called by
|
||||
* {@link Component#setEnabled(boolean)}.
|
||||
*
|
||||
* @param enabled <code>true</code> to enable the component,
|
||||
* <code>false</code> to disable it
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Sets the font of the component. This is called by
|
||||
* {@link Component#setFont(Font)}.
|
||||
*
|
||||
* @param font the font to set
|
||||
*/
|
||||
void setFont(Font font);
|
||||
|
||||
/**
|
||||
* Sets the foreground color of the component. This is called by
|
||||
* {@link Component#setForeground(Color)}.
|
||||
*
|
||||
* @param color the foreground color to set
|
||||
*/
|
||||
void setForeground(Color color);
|
||||
|
||||
/**
|
||||
* Sets the visibility state of the component. This is called by
|
||||
* {@link Component#setVisible(boolean)}.
|
||||
*
|
||||
* @param visible <code>true</code> to make the component visible,
|
||||
* <code>false</code> to make it invisible
|
||||
*/
|
||||
void setVisible(boolean visible);
|
||||
|
||||
/**
|
||||
* Makes the component visible. This is called by {@link Component#show()}.
|
||||
*/
|
||||
void show();
|
||||
|
||||
/**
|
||||
* Get the graphics configuration of the component. The color model
|
||||
* of the component can be derived from the configuration.
|
||||
*
|
||||
* @return the graphics configuration of the component
|
||||
*/
|
||||
GraphicsConfiguration getGraphicsConfiguration();
|
||||
|
||||
/**
|
||||
* Part of an older API, no longer needed.
|
||||
*/
|
||||
void setEventMask (long mask);
|
||||
void setEventMask(long mask);
|
||||
|
||||
// Methods below are introduced since 1.1
|
||||
/**
|
||||
* Returns <code>true</code> if this component has been obscured,
|
||||
* <code>false</code> otherwise. This will only work if
|
||||
* {@link #canDetermineObscurity()} also returns <code>true</code>.
|
||||
*
|
||||
* @return <code>true</code> if this component has been obscured,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
boolean isObscured();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this component peer can determine if the
|
||||
* component has been obscured, <code>false</code> otherwise.
|
||||
*
|
||||
* @return <code>true</code> if this component peer can determine if the
|
||||
* component has been obscured, <code>false</code> otherwise
|
||||
*/
|
||||
boolean canDetermineObscurity();
|
||||
|
||||
/**
|
||||
* Coalesces the specified paint event.
|
||||
*
|
||||
* @param e the paint event
|
||||
*/
|
||||
void coalescePaintEvent(PaintEvent e);
|
||||
|
||||
/**
|
||||
* Updates the cursor.
|
||||
*/
|
||||
void updateCursorImmediately();
|
||||
|
||||
/**
|
||||
* Returns true, if this component can handle wheel scrolling,
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
* @return true, if this component can handle wheel scrolling,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean handlesWheelScrolling();
|
||||
|
||||
/**
|
||||
|
|
124
libjava/classpath/java/awt/print/NoPrinterJob.java
Normal file
124
libjava/classpath/java/awt/print/NoPrinterJob.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
/* NoPrinterJob.java -- Fake PrinterJob that just signals no print service.
|
||||
Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 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.print;
|
||||
|
||||
/**
|
||||
* Fake PrinterJob that just signals no print service. This is only
|
||||
* here so applications can call
|
||||
* <code>PrintJob.getPrinterJob().getPrinterJob()</code> and check
|
||||
* that it returns <code>null</code> which indicates no actual
|
||||
* printing support is available.
|
||||
*/
|
||||
class NoPrinterJob extends PrinterJob
|
||||
{
|
||||
public int getCopies()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setCopies(int copies)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public String getJobName()
|
||||
{
|
||||
return "NoPrinterJob";
|
||||
}
|
||||
|
||||
public void setJobName(String job_name)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return "NoUser";
|
||||
}
|
||||
|
||||
public void cancel()
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public PageFormat defaultPage(PageFormat page_format)
|
||||
{
|
||||
return page_format;
|
||||
}
|
||||
|
||||
public PageFormat pageDialog(PageFormat page_format)
|
||||
{
|
||||
return page_format;
|
||||
}
|
||||
|
||||
public void print() throws PrinterException
|
||||
{
|
||||
throw new PrinterException("No printer");
|
||||
}
|
||||
|
||||
public boolean printDialog()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPageable(Pageable pageable)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public void setPrintable(Printable printable)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public void setPrintable(Printable printable, PageFormat page_format)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public PageFormat validatePage(PageFormat page_format)
|
||||
{
|
||||
return page_format;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* PageFormat.java -- Information about the page format
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,254 +39,195 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This class contains information about the desired page format to
|
||||
* use for printing a particular set of pages.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public class PageFormat implements Cloneable
|
||||
{
|
||||
|
||||
/*
|
||||
* Static Variables
|
||||
* This class contains information about the desired page format to use for
|
||||
* printing a particular set of pages.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
|
||||
/**
|
||||
* A constant for a landscaped page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int LANDSCAPE = 0;
|
||||
|
||||
/**
|
||||
* A constant for a portrait page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int PORTRAIT = 1;
|
||||
|
||||
/**
|
||||
* A constant for a reversed landscaped page orientation. This is
|
||||
* the orientation used by Macintosh's for landscape. The origin is
|
||||
* in the upper right hand corner instead of the upper left. The
|
||||
* X and Y axes are reversed. Used by <code>getOrientation</code> and
|
||||
* <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int REVERSE_LANDSCAPE = 2;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
*/
|
||||
|
||||
// The page orientation
|
||||
private int orientation;
|
||||
|
||||
// The paper type
|
||||
private Paper paper;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method creates a default page layout, which will be in portrait
|
||||
* format.
|
||||
*/
|
||||
public
|
||||
PageFormat()
|
||||
public class PageFormat
|
||||
implements Cloneable
|
||||
{
|
||||
this.paper = new Paper();
|
||||
this.orientation = PORTRAIT;
|
||||
/**
|
||||
* A constant for a landscaped page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int LANDSCAPE = 0;
|
||||
|
||||
/**
|
||||
* A constant for a portrait page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int PORTRAIT = 1;
|
||||
|
||||
/**
|
||||
* A constant for a reversed landscaped page orientation. This is the
|
||||
* orientation used by Macintosh's for landscape. The origin is in the
|
||||
* upper right hand corner instead of the upper left. The X and Y axes
|
||||
* are reversed. Used by <code>getOrientation</code> and
|
||||
* <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int REVERSE_LANDSCAPE = 2;
|
||||
|
||||
// The page orientation
|
||||
private int orientation;
|
||||
|
||||
// The paper type
|
||||
private Paper paper;
|
||||
|
||||
/**
|
||||
* This method creates a default page layout, which will be in portrait
|
||||
* format.
|
||||
*/
|
||||
public PageFormat()
|
||||
{
|
||||
this.paper = new Paper();
|
||||
this.orientation = PORTRAIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the width of the page, in 1/72nd's of an inch. The
|
||||
* "width" measured depends on orientation.
|
||||
*
|
||||
* @return The width of the page.
|
||||
*/
|
||||
public double getWidth()
|
||||
{
|
||||
return paper.getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the height of the page, in 1/72nd's of an inch. The
|
||||
* "height" measured depends on the orientation.
|
||||
*
|
||||
* @return The height of the page.
|
||||
*/
|
||||
public double getHeight()
|
||||
{
|
||||
return paper.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate value of the upper leftmost drawable
|
||||
* area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable X coordinate.
|
||||
*/
|
||||
public double getImageableX()
|
||||
{
|
||||
return paper.getImageableX();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate value of the upper leftmost drawable
|
||||
* area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable Y coordinate.
|
||||
*/
|
||||
public double getImageableY()
|
||||
{
|
||||
return paper.getImageableY();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the imageable width of the paper, in 1/72nd's of an
|
||||
* inch.
|
||||
*
|
||||
* @return The imageable width of the paper.
|
||||
*/
|
||||
public double getImageableWidth()
|
||||
{
|
||||
return paper.getImageableWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the imageable height of the paper, in 1/72nd's of an
|
||||
* inch.
|
||||
*
|
||||
* @return The imageable height of the paper.
|
||||
*/
|
||||
public double getImageableHeight()
|
||||
{
|
||||
return paper.getImageableHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the <code>paper</code> object being used for this page
|
||||
* format.
|
||||
*
|
||||
* @return A copy of the <code>Paper</code> object for this format.
|
||||
*/
|
||||
public Paper getPaper()
|
||||
{
|
||||
return (Paper) paper.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>Paper</code> object to be used by this page format.
|
||||
*
|
||||
* @param paper The new <code>Paper</code> object for this page format.
|
||||
*/
|
||||
public void setPaper(Paper paper)
|
||||
{
|
||||
this.paper = paper;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the current page orientation. The value returned will
|
||||
* be one of the page orientation constants from this class.
|
||||
*
|
||||
* @return The current page orientation.
|
||||
*/
|
||||
public int getOrientation()
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the page orientation for this format to the specified
|
||||
* value. It must be one of the page orientation constants from this class
|
||||
* or an exception will be thrown.
|
||||
*
|
||||
* @param orientation The new page orientation.
|
||||
* @exception IllegalArgumentException If the specified page orientation
|
||||
* value is not one of the constants from this class.
|
||||
*/
|
||||
public void setOrientation(int orientation) throws IllegalArgumentException
|
||||
{
|
||||
if ((orientation != PORTRAIT) && (orientation != LANDSCAPE)
|
||||
&& (orientation != REVERSE_LANDSCAPE))
|
||||
throw new IllegalArgumentException("Bad page orientation value: "
|
||||
+ orientation);
|
||||
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a matrix used for transforming user space coordinates
|
||||
* to page coordinates. The value returned will be six doubles as described
|
||||
* in <code>java.awt.geom.AffineTransform</code>.
|
||||
*
|
||||
* @return The transformation matrix for this page format.
|
||||
*/
|
||||
public double[] getMatrix()
|
||||
{
|
||||
throw new RuntimeException("Not implemented since I don't know what to do");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (super.clone());
|
||||
}
|
||||
catch (CloneNotSupportedException e)
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method returns the width of the page, in 1/72nd's of an inch. The
|
||||
* "width" measured depends on orientation.
|
||||
*
|
||||
* @return The width of the page.
|
||||
*/
|
||||
public double
|
||||
getWidth()
|
||||
{
|
||||
return(paper.getWidth());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the height of the page, in 1/72nd's of an inch.
|
||||
* The "height" measured depends on the orientation.
|
||||
*
|
||||
* @return The height of the page.
|
||||
*/
|
||||
public double
|
||||
getHeight()
|
||||
{
|
||||
return(paper.getHeight());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate value of the upper leftmost
|
||||
* drawable area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable X coordinate.
|
||||
*/
|
||||
public double
|
||||
getImageableX()
|
||||
{
|
||||
return(paper.getImageableX());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate value of the upper leftmost
|
||||
* drawable area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable Y coordinate.
|
||||
*/
|
||||
public double
|
||||
getImageableY()
|
||||
{
|
||||
return(paper.getImageableY());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the imageable width of the paper, in 1/72nd's of
|
||||
* an inch.
|
||||
*
|
||||
* @return The imageable width of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableWidth()
|
||||
{
|
||||
return(paper.getImageableWidth());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the imageable height of the paper, in 1/72nd's of
|
||||
* an inch.
|
||||
*
|
||||
* @return The imageable height of the paper.
|
||||
*/
|
||||
public double getImageableHeight()
|
||||
{
|
||||
return(paper.getImageableHeight());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns a copy of the <code>paper</code> object being used for this
|
||||
* page format.
|
||||
*
|
||||
* @return A copy of the <code>Paper</code> object for this format.
|
||||
*/
|
||||
public Paper
|
||||
getPaper()
|
||||
{
|
||||
return((Paper)paper.clone());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Sets the <code>Paper</code> object to be used by this page format.
|
||||
*
|
||||
* @param paper The new <code>Paper</code> object for this page format.
|
||||
*/
|
||||
public void
|
||||
setPaper(Paper paper)
|
||||
{
|
||||
this.paper = paper;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the current page orientation. The value returned
|
||||
* will be one of the page orientation constants from this class.
|
||||
*
|
||||
* @return The current page orientation.
|
||||
*/
|
||||
public int
|
||||
getOrientation()
|
||||
{
|
||||
return(orientation);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method sets the page orientation for this format to the
|
||||
* specified value. It must be one of the page orientation constants
|
||||
* from this class or an exception will be thrown.
|
||||
*
|
||||
* @param orientation The new page orientation.
|
||||
*
|
||||
* @exception IllegalArgumentException If the specified page orientation
|
||||
* value is not one of the constants from this class.
|
||||
*/
|
||||
public void
|
||||
setOrientation(int orientation) throws IllegalArgumentException
|
||||
{
|
||||
if ((orientation != PORTRAIT) &&
|
||||
(orientation != LANDSCAPE) &&
|
||||
(orientation != REVERSE_LANDSCAPE))
|
||||
throw new IllegalArgumentException("Bad page orientation value: " +
|
||||
orientation);
|
||||
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns a matrix used for transforming user space
|
||||
* coordinates to page coordinates. The value returned will be six
|
||||
* doubles as described in <code>java.awt.geom.AffineTransform</code>.
|
||||
*
|
||||
* @return The transformation matrix for this page format.
|
||||
*/
|
||||
public double[]
|
||||
getMatrix()
|
||||
{
|
||||
throw new RuntimeException("Not implemented since I don't know what to do");
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object
|
||||
clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return(super.clone());
|
||||
}
|
||||
catch(CloneNotSupportedException e)
|
||||
{
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
|
||||
} // class PageFormat
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Pageable.java -- Pages to be printed
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,75 +39,52 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This interface represents pages that are to be printed.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
* This interface represents pages that are to be printed.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public interface Pageable
|
||||
{
|
||||
/**
|
||||
* This constant is returned when <code>getNumberOfPages()</code> cannot
|
||||
* determine the number of pages available for printing.
|
||||
*/
|
||||
int UNKNOWN_NUMBER_OF_PAGES = - 1;
|
||||
|
||||
/*
|
||||
* Static Variables
|
||||
*/
|
||||
/**
|
||||
* This method returns the number of pages this object contains, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if it cannot determine the number
|
||||
* of pages to be printed.
|
||||
*
|
||||
* @return The number of pages to be printed, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if this is unknown.
|
||||
*/
|
||||
int getNumberOfPages();
|
||||
|
||||
/**
|
||||
* This constant is returned when <code>getNumberOfPages()</code>
|
||||
* cannot determine the number of pages available for printing.
|
||||
*/
|
||||
int UNKNOWN_NUMBER_OF_PAGES = -1;
|
||||
/**
|
||||
* This method returns the <code>PageFormat</code> instance for the
|
||||
* specified page. Page numbers start at zero. An exception is thrown if the
|
||||
* requested page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>PageFormat</code> for.
|
||||
* @return The <code>PageFormat</code> for the requested page.
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method returns the number of pages this object contains, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if it cannot determine the number
|
||||
* of pages to be printed.
|
||||
*
|
||||
* @return The number of pages to be printed, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if this is unknown.
|
||||
*/
|
||||
int
|
||||
getNumberOfPages();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the <code>PageFormat</code> instance for the
|
||||
* specified page. Page numbers start at zero. An exception is thrown if
|
||||
* the requested page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>PageFormat</code> for.
|
||||
*
|
||||
* @return The <code>PageFormat</code> for the requested page.
|
||||
*
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
PageFormat
|
||||
getPageFormat(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the <code>Printable</code> instance for the
|
||||
* specified page. Page numbers start at zero. An exception is thrown if
|
||||
* the requested page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>Printable</code> for.
|
||||
*
|
||||
* @return The <code>Printable</code> for the requested page.
|
||||
*
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
Printable
|
||||
getPrintable(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
} // interface Pageable
|
||||
/**
|
||||
* This method returns the <code>Printable</code> instance for the specified
|
||||
* page. Page numbers start at zero. An exception is thrown if the requested
|
||||
* page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>Printable</code> for.
|
||||
* @return The <code>Printable</code> for the requested page.
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Paper.java -- Information about a paper type.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,198 +39,159 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This class describes a particular type of paper.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public class Paper implements Cloneable
|
||||
{
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
* This class describes a particular type of paper.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
|
||||
// Height of the paper
|
||||
private double height;
|
||||
|
||||
// Width of the paper
|
||||
private double width;
|
||||
|
||||
// Upper left imageable X coordinate
|
||||
private double imageableX;
|
||||
|
||||
// Upper left imageable Y coordinate
|
||||
private double imageableY;
|
||||
|
||||
// Imageable width of the page
|
||||
private double imageableWidth;
|
||||
|
||||
// Imageable height of the page
|
||||
private double imageableHeight;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method creates a letter sized paper with one inch margins
|
||||
*/
|
||||
public
|
||||
Paper()
|
||||
public class Paper
|
||||
implements Cloneable
|
||||
{
|
||||
width = 8.5 * 72;
|
||||
height = 11 * 72;
|
||||
imageableX = 72;
|
||||
imageableY = 72;
|
||||
imageableWidth = width - (2 * 72);
|
||||
imageableHeight = height - (2 * 72);
|
||||
// Height of the paper
|
||||
private double height;
|
||||
|
||||
// Width of the paper
|
||||
private double width;
|
||||
|
||||
// Upper left imageable X coordinate
|
||||
private double imageableX;
|
||||
|
||||
// Upper left imageable Y coordinate
|
||||
private double imageableY;
|
||||
|
||||
// Imageable width of the page
|
||||
private double imageableWidth;
|
||||
|
||||
// Imageable height of the page
|
||||
private double imageableHeight;
|
||||
|
||||
/**
|
||||
* This method creates a letter sized paper with one inch margins
|
||||
*/
|
||||
public Paper()
|
||||
{
|
||||
width = 8.5 * 72;
|
||||
height = 11 * 72;
|
||||
imageableX = 72;
|
||||
imageableY = 72;
|
||||
imageableWidth = width - (2 * 72);
|
||||
imageableHeight = height - (2 * 72);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the height of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The width of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate of the upper left hand corner of the
|
||||
* imageable area of the paper.
|
||||
*
|
||||
* @return The X coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double getImageableX()
|
||||
{
|
||||
return imageableX;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate of the upper left hand corner of the
|
||||
* imageable area of the paper.
|
||||
*
|
||||
* @return The Y coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double getImageableY()
|
||||
{
|
||||
return imageableY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the imageable area of the paper.
|
||||
*
|
||||
* @return The width of the imageable area of the paper.
|
||||
*/
|
||||
public double getImageableWidth()
|
||||
{
|
||||
return imageableWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the imageable area of the paper.
|
||||
*
|
||||
* @return The height of the imageable area of the paper.
|
||||
*/
|
||||
public double getImageableHeight()
|
||||
{
|
||||
return imageableHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the size of the paper to the specified width and height,
|
||||
* which are specified in 1/72nds of an inch.
|
||||
*
|
||||
* @param width The width of the paper in 1/72nds of an inch.
|
||||
* @param height The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public void setSize(double width, double height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the imageable area of the paper by specifying the
|
||||
* coordinates of the upper left hand corner of that area, and its length
|
||||
* and height. All values are in 1/72nds of an inch.
|
||||
*
|
||||
* @param imageableX The X coordinate of the upper left hand corner of the
|
||||
* imageable area, in 1/72nds of an inch.
|
||||
* @param imageableY The Y coordinate of the upper left hand corner of the
|
||||
* imageable area, in 1/72nds of an inch.
|
||||
* @param imageableWidth The width of the imageable area of the paper, in
|
||||
* 1/72nds of an inch.
|
||||
* @param imageableHeight The heigth of the imageable area of the paper, in
|
||||
* 1/72nds of an inch.
|
||||
*/
|
||||
public void setImageableArea(double imageableX, double imageableY,
|
||||
double imageableWidth, double imageableHeight)
|
||||
{
|
||||
this.imageableX = imageableX;
|
||||
this.imageableY = imageableY;
|
||||
this.imageableWidth = imageableWidth;
|
||||
this.imageableHeight = imageableHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (super.clone());
|
||||
}
|
||||
catch (CloneNotSupportedException e)
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the height of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double
|
||||
getHeight()
|
||||
{
|
||||
return(height);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the width of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The width of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double
|
||||
getWidth()
|
||||
{
|
||||
return(width);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate of the upper left hand corner
|
||||
* of the imageable area of the paper.
|
||||
*
|
||||
* @return The X coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableX()
|
||||
{
|
||||
return(imageableX);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate of the upper left hand corner
|
||||
* of the imageable area of the paper.
|
||||
*
|
||||
* @return The Y coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableY()
|
||||
{
|
||||
return(imageableY);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the width of the imageable area of the paper.
|
||||
*
|
||||
* @return The width of the imageable area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableWidth()
|
||||
{
|
||||
return(imageableWidth);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the height of the imageable area of the paper.
|
||||
*
|
||||
* @return The height of the imageable area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableHeight()
|
||||
{
|
||||
return(imageableHeight);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method sets the size of the paper to the specified width and
|
||||
* height, which are specified in 1/72nds of an inch.
|
||||
*
|
||||
* @param width The width of the paper in 1/72nds of an inch.
|
||||
* @param height The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public void
|
||||
setSize(double width, double height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method sets the imageable area of the paper by specifying the
|
||||
* coordinates of the upper left hand corner of that area, and its
|
||||
* length and height. All values are in 1/72nds of an inch.
|
||||
*
|
||||
* @param imageableX The X coordinate of the upper left hand corner of
|
||||
* the imageable area, in 1/72nds of an inch.
|
||||
* @param imageableY The Y coordinate of the upper left hand corner of
|
||||
* the imageable area, in 1/72nds of an inch.
|
||||
* @param imageableWidth The width of the imageable area of the paper,
|
||||
* in 1/72nds of an inch.
|
||||
* @param imageableHeight The heigth of the imageable area of the paper,
|
||||
* in 1/72nds of an inch.
|
||||
*/
|
||||
public void
|
||||
setImageableArea(double imageableX, double imageableY,
|
||||
double imageableWidth, double imageableHeight)
|
||||
{
|
||||
this.imageableX = imageableX;
|
||||
this.imageableY = imageableY;
|
||||
this.imageableWidth = imageableWidth;
|
||||
this.imageableHeight = imageableHeight;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method creates a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object
|
||||
clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return(super.clone());
|
||||
}
|
||||
catch(CloneNotSupportedException e)
|
||||
{
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
|
||||
} // class Paper
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PrinterGraphics.java -- Hook to return print job controller.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,23 +39,20 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This interface is implemented by the <code>Graphics</code> instance
|
||||
* that is used for rendering pages. It provides a hook to return the
|
||||
* object that is controlling the print job.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
* This interface is implemented by the <code>Graphics</code> instance that is
|
||||
* used for rendering pages. It provides a hook to return the object that is
|
||||
* controlling the print job.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public interface PrinterGraphics
|
||||
{
|
||||
/**
|
||||
* This method returns the instance of <code>PrinterJob</code> that is
|
||||
* controlling this print job.
|
||||
*
|
||||
* @return The <code>PrinterJob</code> that is controlling this print job.
|
||||
*/
|
||||
PrinterJob getPrinterJob();
|
||||
|
||||
/**
|
||||
* This method returns the instance of <code>PrinterJob</code> that is
|
||||
* controlling this print job.
|
||||
*
|
||||
* @return The <code>PrinterJob</code> that is controlling this print job.
|
||||
*/
|
||||
PrinterJob
|
||||
getPrinterJob();
|
||||
|
||||
} // interface PrinterGraphics
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PrinterJob.java -- This job is the printer control class
|
||||
Copyright (C) 1999, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -61,7 +61,7 @@ public abstract class PrinterJob
|
|||
public static PrinterJob getPrinterJob()
|
||||
{
|
||||
// FIXME: Need to fix this to load a default implementation instance.
|
||||
return null;
|
||||
return new NoPrinterJob();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue