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:
@@ -0,0 +1,224 @@
|
||||
/* SwingButtonPeer.java -- A Swing based peer for AWT buttons
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.ButtonPeer;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
* A Swing based peer for the AWT button.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingButtonPeer
|
||||
extends SwingComponentPeer
|
||||
implements ButtonPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* A specialized Swing button to be used as AWT button.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
class SwingButton
|
||||
extends JButton
|
||||
implements SwingComponent
|
||||
{
|
||||
/**
|
||||
* Overridden so that this method returns the correct value even without a
|
||||
* peer.
|
||||
*
|
||||
* @return the screen location of the button
|
||||
*/
|
||||
public Point getLocationOnScreen()
|
||||
{
|
||||
return SwingButtonPeer.this.getLocationOnScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden so that the isShowing method returns the correct value for the
|
||||
* swing button, even if it has no peer on its own.
|
||||
*
|
||||
* @return <code>true</code> if the button is currently showing,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isShowing()
|
||||
{
|
||||
boolean retVal = false;
|
||||
if (SwingButtonPeer.this.awtComponent != null)
|
||||
retVal = SwingButtonPeer.this.awtComponent.isShowing();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden, so that the Swing button can create an Image without its
|
||||
* own peer.
|
||||
*
|
||||
* @param w the width of the image
|
||||
* @param h the height of the image
|
||||
*
|
||||
* @return an image
|
||||
*/
|
||||
public Image createImage(int w, int h)
|
||||
{
|
||||
return SwingButtonPeer.this.createImage(w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden, so that the Swing button can create a Graphics without its
|
||||
* own peer.
|
||||
*
|
||||
* @return a graphics instance for the button
|
||||
*/
|
||||
public Graphics getGraphics()
|
||||
{
|
||||
return SwingButtonPeer.this.getGraphics();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this button.
|
||||
*
|
||||
* @return this button
|
||||
*/
|
||||
public JComponent getJComponent()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by forwarding it to
|
||||
* <code>processMouseEvent()</code> after having retargetted it to this
|
||||
* button.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processMouseEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse motion events by forwarding it to
|
||||
* <code>processMouseMotionEvent()</code> after having retargetted it to
|
||||
* this button.
|
||||
*
|
||||
* @param ev the mouse motion event
|
||||
*/
|
||||
public void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processMouseMotionEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles key events by forwarding it to
|
||||
* <code>processKeyEvent()</code> after having retargetted it to this
|
||||
* button.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleKeyEvent(KeyEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processKeyEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens for ActionEvents on the Swing button and triggers corresponding
|
||||
* ActionEvents on the AWT button.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
class SwingButtonListener implements ActionListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Receives notification when an action was performend on the button.
|
||||
*
|
||||
* @param event the action event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
Button b = (Button) SwingButtonPeer.this.awtComponent;
|
||||
ActionListener[] l = b.getActionListeners();
|
||||
if (l.length == 0)
|
||||
return;
|
||||
ActionEvent ev = new ActionEvent(b, ActionEvent.ACTION_PERFORMED,
|
||||
b.getActionCommand());
|
||||
for (int i = 0; i < l.length; ++i)
|
||||
l[i].actionPerformed(ev);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new SwingButtonPeer.
|
||||
*
|
||||
* @param theButton the AWT button for this peer
|
||||
*/
|
||||
public SwingButtonPeer(Button theButton)
|
||||
{
|
||||
SwingButton button = new SwingButton();
|
||||
button.setText(theButton.getLabel());
|
||||
button.addActionListener(new SwingButtonListener());
|
||||
init(theButton, button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label of the button. This call is forwarded to the setText method
|
||||
* of the managed Swing button.
|
||||
*
|
||||
* @param label the label to set
|
||||
*/
|
||||
public void setLabel(String label)
|
||||
{
|
||||
((SwingButton) swingComponent).setText(label);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/* SwingCanvasPeer.java -- A canvas peer based on Swing
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.peer.CanvasPeer;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
|
||||
/**
|
||||
* A CanvasPeer to be used together with the Swing peers.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingCanvasPeer
|
||||
extends SwingComponentPeer
|
||||
implements LightweightPeer, CanvasPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a new <code>SwingCanvasPeer</code> for the specified Canvas.
|
||||
*
|
||||
* @param canvas the canvas.
|
||||
*/
|
||||
public SwingCanvasPeer(Canvas canvas)
|
||||
{
|
||||
init(canvas, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/* SwingComponent.java -- An interface that defines a Swing component for peers
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
* Defines some additional methods that the Swing components must implement
|
||||
* in order to work with the Swing peers. This is usually achieved by
|
||||
* subclassing a Swing component and forwarding the method calls to some
|
||||
* protected JComponent method.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public interface SwingComponent
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the actual swing compenent.
|
||||
*
|
||||
* @return the actual swing compenent
|
||||
*/
|
||||
JComponent getJComponent();
|
||||
|
||||
/**
|
||||
* Handles a mouse event. This is usually forwarded to
|
||||
* {@link Component#processMouseMotionEvent(MouseEvent)} of the swing
|
||||
* component.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
void handleMouseEvent(MouseEvent ev);
|
||||
|
||||
/**
|
||||
* Handles a mouse motion event. This is usually forwarded to
|
||||
* {@link Component#processMouseEvent(MouseEvent)} of the swing
|
||||
* component.
|
||||
*
|
||||
* @param ev the mouse motion event
|
||||
*/
|
||||
void handleMouseMotionEvent(MouseEvent ev);
|
||||
|
||||
/**
|
||||
* Handles a key event. This is usually forwarded to
|
||||
* {@link Component#processKeyEvent(KeyEvent)} of the swing
|
||||
* component.
|
||||
*
|
||||
* @param ev the key event
|
||||
*/
|
||||
void handleKeyEvent(KeyEvent ev);
|
||||
}
|
||||
@@ -0,0 +1,994 @@
|
||||
/* SwingComponentPeer.java -- An abstract base class for Swing based peers
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BufferCapabilities;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.BufferCapabilities.FlipContents;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
|
||||
/**
|
||||
* The base class for Swing based component peers. This provides the basic
|
||||
* functionality needed for Swing based component peers. Many methods are
|
||||
* implemented to forward to the Swing component. Others however forward
|
||||
* to the component's parent and expect the toplevel component peer to provide
|
||||
* a real implementation of it. These are for example the key methods
|
||||
* {@link #getGraphics()} and {@link #createImage(int, int)}, as well as
|
||||
* {@link #getLocationOnScreen()}.
|
||||
*
|
||||
* This class also provides the necesary hooks into the Swing painting and
|
||||
* event handling system. In order to achieve this, it traps paint, mouse and
|
||||
* key events in {@link #handleEvent(AWTEvent)} and calls some special methods
|
||||
* ({@link #peerPaint(Graphics)}, {@link #handleKeyEvent(KeyEvent)},
|
||||
* {@link #handleMouseEvent(MouseEvent)} and
|
||||
* {@link #handleMouseMotionEvent(MouseEvent)}) that call the corresponding
|
||||
* Swing methods.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingComponentPeer
|
||||
implements ComponentPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* The AWT component for this peer.
|
||||
*/
|
||||
protected Component awtComponent;
|
||||
|
||||
/**
|
||||
* The Swing component for this peer.
|
||||
*/
|
||||
protected SwingComponent swingComponent;
|
||||
|
||||
/**
|
||||
* Creates a SwingComponentPeer instance. Subclasses are expected to call
|
||||
* this constructor and thereafter call {@link #init(Component, JComponent)}
|
||||
* in order to setup the AWT and Swing components properly.
|
||||
*/
|
||||
protected SwingComponentPeer()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the AWT and Swing component for this peer. It is expected that
|
||||
* subclasses call this from within their constructor.
|
||||
*
|
||||
* @param awtComp the AWT component for this peer
|
||||
* @param swingComp the Swing component for this peer
|
||||
*/
|
||||
protected void init(Component awtComp, SwingComponent swingComp)
|
||||
{
|
||||
awtComponent = awtComp;
|
||||
swingComponent = swingComp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public int checkImage(Image img, int width, int height, ImageObserver ob)
|
||||
{
|
||||
return Toolkit.getDefaultToolkit().checkImage(img, width, height, 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
|
||||
*/
|
||||
public Image createImage(ImageProducer prod)
|
||||
{
|
||||
Image image = Toolkit.getDefaultToolkit().createImage(prod);
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty image with the specified <code>width</code> and
|
||||
* <code>height</code>.
|
||||
*
|
||||
* This is implemented to let the parent component create the image. This
|
||||
* eventually goes up to the top-level component peer, which is then expected
|
||||
* to deliver the image.
|
||||
*
|
||||
* @param width the width of the image to be created
|
||||
* @param height the height of the image to be created
|
||||
*
|
||||
* @return the created image
|
||||
*/
|
||||
public Image createImage(int width, int height)
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.createImage(width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the component. This is called by {@link Component#disable()}.
|
||||
*/
|
||||
public void disable()
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes the component peer. This should release all resources held by the
|
||||
* peer. This is called when the component is no longer in use.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
awtComponent = null;
|
||||
swingComponent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the component. This is called by {@link Component#enable()}.
|
||||
*/
|
||||
public void enable()
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color model of the component. This is currently not used.
|
||||
*
|
||||
* @return the color model of the component
|
||||
*/
|
||||
public ColorModel getColorModel()
|
||||
{
|
||||
// FIXME: When this peer method will be used, we need to provide an
|
||||
// implementation of this, probably forwarding to the toplevel peer, like
|
||||
// in the other methods.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font metrics for the specified font. This is called by
|
||||
* {@link Component#getFontMetrics(Font)}.
|
||||
*
|
||||
* This is implemented to query the font metrics from the parent component.
|
||||
* This will eventually call the top-level component peer, which is then
|
||||
* expected to deliver a font metrics object.
|
||||
*
|
||||
* @param f the font for which to query the font metrics
|
||||
*
|
||||
* @return the font metrics for the specified font
|
||||
*/
|
||||
public FontMetrics getFontMetrics(Font f)
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.getFontMetrics(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Graphics} object suitable for drawing on this component.
|
||||
* This is called by {@link Component#getGraphics()}.
|
||||
*
|
||||
* This is implemented to query the graphics from the parent component and
|
||||
* adjust the clip and translation to match this component.
|
||||
* This will eventually call the top-level component peer, which is then
|
||||
* expected to deliver a graphics object.
|
||||
*
|
||||
* @return a graphics object suitable for drawing on this component
|
||||
*/
|
||||
public Graphics getGraphics()
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
Graphics g = parentPeer.getGraphics();
|
||||
g.translate(awtComponent.getX(), awtComponent.getY());
|
||||
g.setClip(0, 0, awtComponent.getWidth(), awtComponent.getHeight());
|
||||
return g;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of this component in screen coordinates. This is
|
||||
* called by {@link Component#getLocationOnScreen()}.
|
||||
*
|
||||
* This is implemented to query the parent component peer for its screen
|
||||
* location and adds the offset of this component to it. This will eventually
|
||||
* call the top-level component's peer, which is then expected to provide
|
||||
* it's screen location.
|
||||
*
|
||||
* @return the location of this component in screen coordinates
|
||||
*/
|
||||
public Point getLocationOnScreen()
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
Point location = parentPeer.getLocationOnScreen();
|
||||
location.x += awtComponent.getX();
|
||||
location.y += awtComponent.getY();
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum size for the component. This is called by
|
||||
* {@link Component#getMinimumSize()}.
|
||||
*
|
||||
* This is implemented to return the Swing component's minimum size.
|
||||
*
|
||||
* @return the minimum size for the component
|
||||
*/
|
||||
public Dimension getMinimumSize()
|
||||
{
|
||||
Dimension retVal;
|
||||
if (swingComponent != null)
|
||||
retVal = swingComponent.getJComponent().getMinimumSize();
|
||||
else
|
||||
retVal = new Dimension(0, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred size for the component. This is called by
|
||||
* {@link Component#getPreferredSize()}.
|
||||
*
|
||||
* This is implemented to return the Swing component's preferred size.
|
||||
*
|
||||
* @return the preferred size for the component
|
||||
*/
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
Dimension retVal;
|
||||
if (swingComponent != null)
|
||||
retVal = swingComponent.getJComponent().getPreferredSize();
|
||||
else
|
||||
retVal = new Dimension(0, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the toolkit that created this peer.
|
||||
*
|
||||
* @return the toolkit that created this peer
|
||||
*/
|
||||
public Toolkit getToolkit()
|
||||
{
|
||||
return Toolkit.getDefaultToolkit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public void handleEvent(AWTEvent e)
|
||||
{
|
||||
switch (e.getID())
|
||||
{
|
||||
case PaintEvent.UPDATE:
|
||||
case PaintEvent.PAINT:
|
||||
Graphics g = getGraphics();
|
||||
Rectangle clip = ((PaintEvent)e).getUpdateRect();
|
||||
g.clipRect(clip.x, clip.y, clip.width, clip.height);
|
||||
//if (this instanceof LightweightPeer)
|
||||
// {
|
||||
if (e.getID() == PaintEvent.UPDATE)
|
||||
awtComponent.update(g);
|
||||
else
|
||||
awtComponent.paint(g);
|
||||
// }
|
||||
// We paint the 'heavyweights' at last, so that they appear on top of
|
||||
// everything else.
|
||||
peerPaint(g);
|
||||
|
||||
g.dispose();
|
||||
break;
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
case MouseEvent.MOUSE_CLICKED:
|
||||
case MouseEvent.MOUSE_ENTERED:
|
||||
case MouseEvent.MOUSE_EXITED:
|
||||
handleMouseEvent((MouseEvent) e);
|
||||
break;
|
||||
case MouseEvent.MOUSE_MOVED:
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
handleMouseMotionEvent((MouseEvent) e);
|
||||
break;
|
||||
case KeyEvent.KEY_PRESSED:
|
||||
case KeyEvent.KEY_RELEASED:
|
||||
case KeyEvent.KEY_TYPED:
|
||||
handleKeyEvent((KeyEvent) e);
|
||||
break;
|
||||
default:
|
||||
// Other event types are not handled here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the component invisible. This is called from
|
||||
* {@link Component#hide()}.
|
||||
*
|
||||
* This is implemented to call setVisible(false) on the Swing component.
|
||||
*/
|
||||
public void hide()
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the component can receive keyboard input
|
||||
* focus. This is called from {@link Component#isFocusTraversable()}.
|
||||
*
|
||||
* This is implemented to return isFocusable() from the Swing component.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, replaced by isFocusable().
|
||||
*/
|
||||
public boolean isFocusTraversable()
|
||||
{
|
||||
return swingComponent != null ?
|
||||
swingComponent.getJComponent().isFocusable() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the component can receive keyboard input
|
||||
* focus. This is called from {@link Component#isFocusable()}.
|
||||
*
|
||||
* This is implemented to return isFocusable() from the Swing component.
|
||||
*/
|
||||
public boolean isFocusable()
|
||||
{
|
||||
return swingComponent != null ?
|
||||
swingComponent.getJComponent().isFocusable() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum size for the component. This is called by
|
||||
* {@link Component#minimumSize()}.
|
||||
*
|
||||
* This is implemented to return the Swing component's minimum size.
|
||||
*
|
||||
* @return the minimum size for the component
|
||||
*/
|
||||
public Dimension minimumSize()
|
||||
{
|
||||
Dimension retVal;
|
||||
if (swingComponent != null)
|
||||
retVal = swingComponent.getJComponent().getMinimumSize();
|
||||
else
|
||||
retVal = new Dimension(0, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred size for the component. This is called by
|
||||
* {@link Component#getPreferredSize()}.
|
||||
*
|
||||
* This is implemented to return the Swing component's preferred size.
|
||||
*
|
||||
* @return the preferred size for the component
|
||||
*/
|
||||
public Dimension preferredSize()
|
||||
{
|
||||
Dimension retVal;
|
||||
if (swingComponent != null)
|
||||
retVal = swingComponent.getJComponent().getPreferredSize();
|
||||
else
|
||||
retVal = new Dimension(0, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
public void paint(Graphics graphics)
|
||||
{
|
||||
// FIXME: I don't know what this method is supposed to do.
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
public boolean prepareImage(Image img, int width, int height, ImageObserver ob)
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.prepareImage(img, width, height, ob);
|
||||
}
|
||||
|
||||
public void print(Graphics graphics)
|
||||
{
|
||||
// FIXME: I don't know what this method is supposed to do.
|
||||
}
|
||||
|
||||
/**
|
||||
* Repaints the specified rectangle of this component. This is called from
|
||||
* {@link Component#repaint(long, int, int, int, int)}.
|
||||
*
|
||||
* This is implemented to call repaint() on the Swing component.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public void repaint(long tm, int x, int y, int width, int height)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().repaint(tm, x, y, width, height);
|
||||
else
|
||||
{
|
||||
PaintEvent ev = new PaintEvent(awtComponent, PaintEvent.UPDATE,
|
||||
new Rectangle(x, y, width, height));
|
||||
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that this component receives the focus. This is called from
|
||||
* {@link Component#requestFocus()}.
|
||||
*
|
||||
* This calls requestFocus() on the Swing component.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, apparently replaced by argument
|
||||
* form of the same method.
|
||||
*/
|
||||
public void requestFocus()
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().requestFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that this component receives the focus. This is called from
|
||||
* {@link Component#requestFocus()}.
|
||||
*
|
||||
* This calls requestFocus() on the Swing component.
|
||||
*
|
||||
* @param source TODO
|
||||
* @param bool1 TODO
|
||||
* @param bool2 TODO
|
||||
* @param x TODO
|
||||
*
|
||||
* @return TODO
|
||||
*/
|
||||
public boolean requestFocus(Component source, boolean bool1, boolean bool2, long x)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().requestFocus();
|
||||
return swingComponent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the peer that the bounds of this component have changed. This
|
||||
* is called by {@link Component#reshape(int, int, int, int)}.
|
||||
*
|
||||
* This is implemented to call setBounds() on the Swing component.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public void reshape(int x, int y, int width, int height)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background color of the component. This is called by
|
||||
* {@link Component#setBackground(Color)}.
|
||||
*
|
||||
* This is implemented to call setBackground() on the Swing component.
|
||||
*
|
||||
* @param color the background color to set
|
||||
*/
|
||||
public void setBackground(Color color)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setBackground(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the peer that the bounds of this component have changed. This
|
||||
* is called by {@link Component#setBounds(int, int, int, int)}.
|
||||
*
|
||||
* This is implemented to call setBounds() on the Swing component.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public void setBounds(int x, int y, int width, int height)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cursor of the component. This is called by
|
||||
* {@link Component#setCursor(Cursor)}.
|
||||
*
|
||||
* This is implemented to call setCursor() on the Swing component.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, apparently no longer needed.
|
||||
*/
|
||||
public void setCursor(Cursor cursor)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setCursor(cursor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled/disabled state of this component. This is called by
|
||||
* {@link Component#setEnabled(boolean)}.
|
||||
*
|
||||
* This is implemented to call setEnabled() on the Swing component.
|
||||
*
|
||||
* @param enabled <code>true</code> to enable the component,
|
||||
* <code>false</code> to disable it
|
||||
*/
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font of the component. This is called by
|
||||
* {@link Component#setFont(Font)}.
|
||||
*
|
||||
* This is implemented to call setFont() on the Swing component.
|
||||
*
|
||||
* @param font the font to set
|
||||
*/
|
||||
public void setFont(Font font)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setFont(font);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the foreground color of the component. This is called by
|
||||
* {@link Component#setForeground(Color)}.
|
||||
*
|
||||
* This is implemented to call setForeground() on the Swing component.
|
||||
*
|
||||
* @param color the foreground color to set
|
||||
*/
|
||||
public void setForeground(Color color)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setForeground(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visibility state of the component. This is called by
|
||||
* {@link Component#setVisible(boolean)}.
|
||||
*
|
||||
* This is implemented to call setVisible() on the Swing component.
|
||||
*
|
||||
* @param visible <code>true</code> to make the component visible,
|
||||
* <code>false</code> to make it invisible
|
||||
*/
|
||||
public void setVisible(boolean visible)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the component visible. This is called by {@link Component#show()}.
|
||||
*
|
||||
* This is implemented to call setVisible(true) on the Swing component.
|
||||
*/
|
||||
public void show()
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the graphics configuration of the component. The color model
|
||||
* of the component can be derived from the configuration.
|
||||
*
|
||||
* This is implemented to return the GraphicsConfiguration of the parent
|
||||
* component. This will eventually call the toplevel component peer, which
|
||||
* is expected to provide a real implementation.
|
||||
*
|
||||
* @return the graphics configuration of the component
|
||||
*/
|
||||
public GraphicsConfiguration getGraphicsConfiguration()
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.getGraphicsConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of an older API, no longer needed.
|
||||
*/
|
||||
public void setEventMask(long mask)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>.
|
||||
*
|
||||
* This is not yet implemented.
|
||||
*
|
||||
* @return <code>true</code> if this component has been obscured,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isObscured()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this component peer can determine if the
|
||||
* component has been obscured, <code>false</code> otherwise.
|
||||
*
|
||||
* This is not yet implemented.
|
||||
*
|
||||
* @return <code>true</code> if this component peer can determine if the
|
||||
* component has been obscured, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean canDetermineObscurity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coalesces the specified paint event.
|
||||
*
|
||||
* @param e the paint event
|
||||
*/
|
||||
public void coalescePaintEvent(PaintEvent e)
|
||||
{
|
||||
// Nothing to do here yet.
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the cursor. This is not yet implemented.
|
||||
*/
|
||||
public void updateCursorImmediately()
|
||||
{
|
||||
// Nothing to do here yet.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if this component can handle wheel scrolling,
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
* This is not yet implemented and returns <code>false</code>.
|
||||
*
|
||||
* @return true, if this component can handle wheel scrolling,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public boolean handlesWheelScrolling()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience method that creates a volatile image. The volatile
|
||||
* image is created on the screen device on which this component is
|
||||
* displayed, in the device's current graphics configuration.
|
||||
*
|
||||
* This is implemented to let the parent component peer create an image.
|
||||
* This eventually ends up in the toplevel component peer, which is then
|
||||
* responsible for creating the real image.
|
||||
*
|
||||
* @param width width of the image
|
||||
* @param height height of the image
|
||||
*
|
||||
* @see VolatileImage
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public VolatileImage createVolatileImage(int width, int height)
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.createVolatileImage(width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a number of image buffers that implement a buffering
|
||||
* strategy according to the given capabilities.
|
||||
*
|
||||
* This is implemented to forward to the parent component peer. Eventually
|
||||
* this ends up in the top level component peer, which is then responsible
|
||||
* for doing the real work.
|
||||
*
|
||||
* @param numBuffers the number of buffers
|
||||
* @param caps the buffering capabilities
|
||||
*
|
||||
* @throws AWTException if the specified buffering strategy is not
|
||||
* implemented
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
parentPeer.createBuffers(numBuffers, caps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the back buffer of this component.
|
||||
*
|
||||
* This is implemented to forward to the parent. Eventually this ends
|
||||
* up in the toplevel component, which is then responsible for providing
|
||||
* a back buffer.
|
||||
*
|
||||
* @return the back buffer of this component.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public Image getBackBuffer()
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.getBackBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a page flip, leaving the contents of the back buffer in
|
||||
* the specified state.
|
||||
*
|
||||
* This is implemented to forward to the parent. Eventually this ends
|
||||
* up in the toplevel component, which is then responsible for doing the real
|
||||
* work.
|
||||
*
|
||||
* @param contents the state in which to leave the back buffer
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public void flip(FlipContents contents)
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
parentPeer.flip(contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the resources created by createBuffers.
|
||||
*
|
||||
* This is implemented to forward to the parent component peer. Eventually
|
||||
* this ends up in the top level component peer, which is then responsible
|
||||
* for doing the real work.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public void destroyBuffers()
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
parentPeer.destroyBuffers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bounds of this component peer.
|
||||
*
|
||||
* This is implemented to forward to the Swing component.
|
||||
*
|
||||
* @return component peer bounds
|
||||
* @since 1.5
|
||||
*/
|
||||
public Rectangle getBounds()
|
||||
{
|
||||
Rectangle retVal;
|
||||
if (swingComponent != null)
|
||||
retVal = swingComponent.getJComponent().getBounds();
|
||||
else
|
||||
retVal = new Rectangle();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reparent this component under another container.
|
||||
*
|
||||
* @param parent
|
||||
* @since 1.5
|
||||
*/
|
||||
public void reparent(ContainerPeer parent)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bounds of this component peer.
|
||||
*
|
||||
* This is implemented to forward to the swing component.
|
||||
*
|
||||
* @param x the new x co-ordinate
|
||||
* @param y the new y co-ordinate
|
||||
* @param width the new width
|
||||
* @param height the new height
|
||||
* @param z the new stacking level
|
||||
* @since 1.5
|
||||
*/
|
||||
public void setBounds(int x, int y, int width, int height, int z)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setBounds(x, y, width, height);
|
||||
// FIXME: Somehow handle the Z order.
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this component supports being reparented.
|
||||
*
|
||||
* @return true if this component can be reparented,
|
||||
* false otherwise.
|
||||
* @since 1.5
|
||||
*/
|
||||
public boolean isReparentSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Layout this component peer.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void layout()
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().doLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers 'heavyweight' painting of the components. This usually calls
|
||||
* paint() on the Swing component.
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
*/
|
||||
protected void peerPaint(Graphics g)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().paint(g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events on the component. This is usually forwarded to the
|
||||
* SwingComponent's processMouseEvent() method.
|
||||
*
|
||||
* @param e the mouse event
|
||||
*/
|
||||
protected void handleMouseEvent(MouseEvent e)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.handleMouseEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse motion events on the component. This is usually forwarded
|
||||
* to the SwingComponent's processMouseMotionEvent() method.
|
||||
*
|
||||
* @param e the mouse motion event
|
||||
*/
|
||||
protected void handleMouseMotionEvent(MouseEvent e)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.handleMouseMotionEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles key events on the component. This is usually forwarded to the
|
||||
* SwingComponent's processKeyEvent() method.
|
||||
*
|
||||
* @param e the key event
|
||||
*/
|
||||
protected void handleKeyEvent(KeyEvent e)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.handleKeyEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the AWT component for this peer.
|
||||
*
|
||||
* @return the AWT component for this peer
|
||||
*/
|
||||
public Component getComponent()
|
||||
{
|
||||
return awtComponent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/* SwingContainerPeer.java -- A Swing based peer for AWT containers
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Shape;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
|
||||
/**
|
||||
* A peer for Container to be used with the Swing based AWT peers.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingContainerPeer
|
||||
extends SwingComponentPeer
|
||||
implements ContainerPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a new SwingContainerPeer.
|
||||
*
|
||||
* @param awtCont
|
||||
*/
|
||||
public SwingContainerPeer(Container awtCont)
|
||||
{
|
||||
init(awtCont, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the insets of the container.
|
||||
*
|
||||
* This is implemented to return the insets of the Swing container.
|
||||
*
|
||||
* @return the insets of the container
|
||||
*/
|
||||
public Insets insets()
|
||||
{
|
||||
Insets retVal;
|
||||
if (swingComponent != null)
|
||||
retVal = swingComponent.getJComponent().getInsets();
|
||||
else
|
||||
retVal = new Insets(0, 0, 0, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the insets of the container.
|
||||
*
|
||||
* This is implemented to return the insets of the Swing container.
|
||||
*
|
||||
* @return the insets of the container
|
||||
*/
|
||||
public Insets getInsets()
|
||||
{
|
||||
Insets retVal;
|
||||
if (swingComponent != null)
|
||||
retVal = swingComponent.getJComponent().getInsets();
|
||||
else
|
||||
retVal = new Insets(0, 0, 0, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the validation of this containers begins.
|
||||
*/
|
||||
public void beginValidate()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the validation of this containers ended.
|
||||
*/
|
||||
public void endValidate()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the layout of this containers begins.
|
||||
*/
|
||||
public void beginLayout()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the layout of this containers ended.
|
||||
*/
|
||||
public void endLayout()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>false</code> unconditionally. This method is not used at
|
||||
* the moment.
|
||||
*
|
||||
* @return <code>false</code>
|
||||
*/
|
||||
public boolean isPaintPending()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>false</code> unconditionally. This method is not used at
|
||||
* the moment.
|
||||
*
|
||||
* @return <code>false</code>
|
||||
*/
|
||||
public boolean isRestackSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not used at the moment.
|
||||
*/
|
||||
public void cancelPendingPaint(int x, int y, int width, int height)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not used at the moment.
|
||||
*/
|
||||
public void restack()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers painting of a component. This calls peerPaint on all the child
|
||||
* components of this container.
|
||||
*
|
||||
* @param g the graphics context to paint to
|
||||
*/
|
||||
protected void peerPaint(Graphics g)
|
||||
{
|
||||
Container c = (Container) awtComponent;
|
||||
Component[] children = c.getComponents();
|
||||
for (int i = children.length - 1; i >= 0; --i)
|
||||
{
|
||||
Component child = children[i];
|
||||
ComponentPeer peer = child.getPeer();
|
||||
boolean translated = false;
|
||||
boolean clipped = false;
|
||||
Shape oldClip = g.getClip();
|
||||
try
|
||||
{
|
||||
g.translate(child.getX(), child.getY());
|
||||
translated = true;
|
||||
g.setClip(0, 0, child.getWidth(), child.getHeight());
|
||||
clipped = true;
|
||||
if (peer instanceof SwingComponentPeer)
|
||||
((SwingComponentPeer) peer).peerPaint(g);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (translated)
|
||||
g.translate(- child.getX(), - child.getY());
|
||||
if (clipped)
|
||||
g.setClip(oldClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by dispatching it to the correct component.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
protected void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
Component comp = awtComponent.getComponentAt(ev.getPoint());
|
||||
ComponentPeer peer = comp.getPeer();
|
||||
if (awtComponent != comp && !comp.isLightweight() && peer instanceof SwingComponentPeer)
|
||||
{
|
||||
ev.translatePoint(comp.getX(), comp.getY());
|
||||
ev.setSource(comp);
|
||||
((SwingComponentPeer) peer).handleMouseEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by dispatching it to the correct component.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
protected void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
Component comp = awtComponent.getComponentAt(ev.getPoint());
|
||||
ComponentPeer peer = comp.getPeer();
|
||||
if (awtComponent != comp && !comp.isLightweight() && peer instanceof SwingComponentPeer)
|
||||
{
|
||||
ev.translatePoint(comp.getX(), comp.getY());
|
||||
((SwingComponentPeer) peer).handleMouseMotionEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
/* SwingFramePeer.java -- An abstract Swing based peer for AWT frames
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.FramePeer;
|
||||
|
||||
/**
|
||||
* An abstract base class for FramePeer implementations based on Swing.
|
||||
* This class provides the ability to display and handle AWT MenuBars that
|
||||
* are based on Swing.
|
||||
*
|
||||
* As a minimum, a subclass must implement all the remaining abstract methods
|
||||
* as well as the following methods:
|
||||
* <ul>
|
||||
* <li>{@link ComponentPeer#getLocationOnScreen()}</li>
|
||||
* <li>{@link ComponentPeer#getGraphics()}</li>
|
||||
* <li>{@link ComponentPeer#createImage(int, int)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public abstract class SwingFramePeer
|
||||
extends SwingWindowPeer
|
||||
implements FramePeer
|
||||
{
|
||||
/**
|
||||
* The menu bar to display.
|
||||
*/
|
||||
SwingMenuBarPeer menuBar = null;
|
||||
|
||||
/**
|
||||
* Creates a new SwingFramePeer.
|
||||
*
|
||||
* @param frame the frame
|
||||
*/
|
||||
public SwingFramePeer(Frame frame)
|
||||
{
|
||||
super(frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the menu bar to display in this frame.
|
||||
*
|
||||
* @param mb the menu bar to set
|
||||
*/
|
||||
public void setMenuBar(MenuBar mb)
|
||||
{
|
||||
menuBar = (SwingMenuBarPeer) mb.getPeer();
|
||||
menuBar.setFramePeer(this);
|
||||
menuBar.setWidth(awtComponent.getWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers 'heavyweight' painting of the frame. This will paint a menu bar
|
||||
* if present as well as the child components of this frame.
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
*/
|
||||
protected void peerPaint(Graphics g)
|
||||
{
|
||||
super.peerPaint(g);
|
||||
if (menuBar != null)
|
||||
menuBar.peerPaint(g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size and location of this frame. This resizes the menubar to fit
|
||||
* within the frame.
|
||||
*
|
||||
* @param x the X coordinate of the screen location
|
||||
* @param y the Y coordinate of the screen location
|
||||
* @param w the width of the frame
|
||||
* @param h the height of the frame
|
||||
*/
|
||||
public void setBounds(int x, int y, int w, int h)
|
||||
{
|
||||
super.setBounds(x, y, w, h);
|
||||
if (menuBar != null)
|
||||
menuBar.setWidth(w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the insets of this frame peer. This fetches the insets
|
||||
* from the superclass and adds the insets of the menubar if one is present.
|
||||
*
|
||||
* @return the insets of the frame
|
||||
*/
|
||||
public Insets getInsets()
|
||||
{
|
||||
Insets insets = super.getInsets();
|
||||
if (menuBar != null)
|
||||
insets.top += menuBar.getHeight();
|
||||
return insets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of the menu on the screen. This is needed internally
|
||||
* by the {@link SwingMenuBarPeer} in order to determine its screen location.
|
||||
*
|
||||
* @return the location of the menu on the screen
|
||||
*/
|
||||
public Point getMenuLocationOnScreen()
|
||||
{
|
||||
Insets i = super.getInsets();
|
||||
return new Point(i.top, i.left);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to provide the ability to handle menus.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
protected void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
Point p = ev.getPoint();
|
||||
Insets i = super.getInsets();
|
||||
if (menuBar != null)
|
||||
{
|
||||
int menuHeight = menuBar.getHeight();
|
||||
if (p.y >= i.top && p.y <= i.top + menuHeight)
|
||||
menuBar.handleMouseEvent(ev);
|
||||
else
|
||||
{
|
||||
ev.translatePoint(0, -menuHeight);
|
||||
super.handleMouseMotionEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
super.handleMouseEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to provide the ability to handle menus.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
protected void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
Point p = ev.getPoint();
|
||||
Insets i = super.getInsets();
|
||||
if (menuBar != null)
|
||||
{
|
||||
int menuHeight = menuBar.getHeight();
|
||||
if (p.y >= i.top && p.y <= i.top + menuHeight)
|
||||
menuBar.handleMouseMotionEvent(ev);
|
||||
else
|
||||
{
|
||||
ev.translatePoint(0, -menuHeight);
|
||||
super.handleMouseMotionEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
super.handleMouseMotionEvent(ev);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
/* SwingLabelPeer.java -- A Swing based peer for AWT labels
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Label;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.LabelPeer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
|
||||
/**
|
||||
* A Label peer based on {@link JLabel}.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingLabelPeer
|
||||
extends SwingComponentPeer
|
||||
implements LabelPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* A spezialized Swing label used to paint the label for the AWT Label.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
private class SwingLabel
|
||||
extends JLabel
|
||||
implements SwingComponent
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns this label.
|
||||
*
|
||||
* @return <code>this</code>
|
||||
*/
|
||||
public JComponent getJComponent()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by forwarding it to
|
||||
* <code>processMouseEvent()</code>.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
processMouseEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse motion events by forwarding it to
|
||||
* <code>processMouseMotionEvent()</code>.
|
||||
*
|
||||
* @param ev the mouse motion event
|
||||
*/
|
||||
public void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
processMouseMotionEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles key events by forwarding it to <code>processKeyEvent()</code>.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleKeyEvent(KeyEvent ev)
|
||||
{
|
||||
processKeyEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden so that this method returns the correct value even without a
|
||||
* peer.
|
||||
*
|
||||
* @return the screen location of the button
|
||||
*/
|
||||
public Point getLocationOnScreen()
|
||||
{
|
||||
return SwingLabelPeer.this.getLocationOnScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden so that the isShowing method returns the correct value for the
|
||||
* swing button, even if it has no peer on its own.
|
||||
*
|
||||
* @return <code>true</code> if the button is currently showing,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isShowing()
|
||||
{
|
||||
boolean retVal = false;
|
||||
if (SwingLabelPeer.this.awtComponent != null)
|
||||
retVal = SwingLabelPeer.this.awtComponent.isShowing();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden, so that the Swing button can create an Image without its
|
||||
* own peer.
|
||||
*
|
||||
* @param w the width of the image
|
||||
* @param h the height of the image
|
||||
*
|
||||
* @return an image
|
||||
*/
|
||||
public Image createImage(int w, int h)
|
||||
{
|
||||
return SwingLabelPeer.this.createImage(w, h);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>SwingLabelPeer</code> for the specified AWT label.
|
||||
*
|
||||
* @param label the AWT label
|
||||
*/
|
||||
public SwingLabelPeer(Label label)
|
||||
{
|
||||
super();
|
||||
SwingLabel swingLabel = new SwingLabel();
|
||||
swingLabel.setText(label.getText());
|
||||
swingLabel.setHorizontalAlignment(label.getAlignment());
|
||||
swingLabel.setOpaque(true);
|
||||
init(label, swingLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text of the label. This is implemented to set the text on the
|
||||
* Swing label.
|
||||
*
|
||||
* @param text the text to be set
|
||||
*/
|
||||
public void setText(String text)
|
||||
{
|
||||
((JLabel) swingComponent.getJComponent()).setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the horizontal alignment of the label. This is implemented to
|
||||
* set the alignment on the Swing label.
|
||||
*
|
||||
* @param alignment the horizontal alignment
|
||||
*
|
||||
* @see Label#LEFT
|
||||
* @see Label#RIGHT
|
||||
* @see Label#CENTER
|
||||
*/
|
||||
public void setAlignment(int alignment)
|
||||
{
|
||||
((JLabel) swingComponent.getJComponent()).setHorizontalAlignment(alignment);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
/* SwingMenuBarPeer.java -- A Swing based peer for AWT menu bars
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
|
||||
import javax.swing.JMenuBar;
|
||||
|
||||
/**
|
||||
* A Swing based peer for the AWT menu bar. This is a little bit different from
|
||||
* the other peers, since the AWT MenuBar is not derived from the AWT
|
||||
* component.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingMenuBarPeer
|
||||
implements MenuBarPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* The AWT menu bar.
|
||||
*/
|
||||
MenuBar awtMenuBar;
|
||||
|
||||
/**
|
||||
* The Swing menu bar.
|
||||
*/
|
||||
SwingMenuBar menuBar;
|
||||
|
||||
/**
|
||||
* The peer of the frame that contains this menu bar.
|
||||
*/
|
||||
SwingFramePeer framePeer;
|
||||
|
||||
/**
|
||||
* A specialized JMenuBar that can be used as 'backend' for AWT MenuBars.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
private class SwingMenuBar
|
||||
extends JMenuBar
|
||||
{
|
||||
/**
|
||||
* Overridden in order to provide a parent frame for this menu bar. The
|
||||
* menu bar still is not inside the component hierarchy, we are faking
|
||||
* here.
|
||||
*/
|
||||
public Container getParent()
|
||||
{
|
||||
Container result = null;
|
||||
if (framePeer != null)
|
||||
result = (Container) framePeer.awtComponent;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unconditionally returns <code>true</code>, since we assume that when the
|
||||
* menubar has a peer, it must be showing.
|
||||
*
|
||||
* @return <code>true</code>
|
||||
*/
|
||||
public boolean isShowing()
|
||||
{
|
||||
// FIXME: This might be wrong. Maybe find a better way to do that.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by forwarding it to
|
||||
* <code>processMouseEvent()</code>.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processMouseEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the menubar's screen location by asking the SwingFramePeer
|
||||
* for it.
|
||||
*
|
||||
* @return the screen location of the menu bar
|
||||
*/
|
||||
public Point getLocationOnScreen()
|
||||
{
|
||||
return framePeer.getMenuLocationOnScreen();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>SwingMenuBarPeer</code> instance.
|
||||
*
|
||||
* @param awtMenuBar the AWT menu bar
|
||||
*/
|
||||
public SwingMenuBarPeer(MenuBar awtMenuBar)
|
||||
{
|
||||
this.awtMenuBar = awtMenuBar;
|
||||
menuBar = new SwingMenuBar();
|
||||
menuBar.setDoubleBuffered(false);
|
||||
// Add all the menus that are already in the MenuBar.
|
||||
for (int i = 0; i < awtMenuBar.getMenuCount(); i++)
|
||||
{
|
||||
Menu menu = awtMenuBar.getMenu(i);
|
||||
menu.addNotify();
|
||||
addMenu(awtMenuBar.getMenu(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>SwingFramePeer</code> of the frame that holds this menu.
|
||||
*
|
||||
* @param peer the <code>SwingFramePeer</code> to set
|
||||
*/
|
||||
public void setFramePeer(SwingFramePeer peer)
|
||||
{
|
||||
framePeer = peer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a menu to the menu bar.
|
||||
*
|
||||
* @param m the menu to add
|
||||
*/
|
||||
public void addMenu(Menu m)
|
||||
{
|
||||
SwingMenuPeer menuPeer = (SwingMenuPeer) m.getPeer();
|
||||
menuBar.add(menuPeer.menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a help menu to the menu bar.
|
||||
*
|
||||
* @param m the menu to add
|
||||
*/
|
||||
public void addHelpMenu(Menu menu)
|
||||
{
|
||||
// FIXME: We should manage the help menu differently, so that it always
|
||||
// appears at the rightmost position.
|
||||
SwingMenuPeer menuPeer = (SwingMenuPeer) menu.getPeer();
|
||||
menuBar.add(menuPeer.menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the menu with the specified index.
|
||||
*
|
||||
* @param index the index of the menu to remove
|
||||
*/
|
||||
public void delMenu(int index)
|
||||
{
|
||||
menuBar.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes this peer. This releases any reference to the AWT and Swing
|
||||
* components.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
menuBar = null;
|
||||
awtMenuBar = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a font for the menu bar.
|
||||
*
|
||||
* @param font the font to set
|
||||
*/
|
||||
public void setFont(Font font)
|
||||
{
|
||||
menuBar.setFont(font);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the menu bar. This is called from the top level
|
||||
* component peers to adjust the width of the menubar when their sizes
|
||||
* change.
|
||||
*
|
||||
* @param w the width to set
|
||||
*/
|
||||
public void setWidth(int w)
|
||||
{
|
||||
menuBar.setSize(w, menuBar.getPreferredSize().height);
|
||||
menuBar.doLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the menu bar.
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
*/
|
||||
public void peerPaint(Graphics g)
|
||||
{
|
||||
menuBar.paint(g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the height of the menubar.
|
||||
*
|
||||
* @return the height of the menu bar
|
||||
*/
|
||||
public int getHeight()
|
||||
{
|
||||
return menuBar.getPreferredSize().height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
Point point = ev.getPoint();
|
||||
for (int i = 0; i < awtMenuBar.getMenuCount(); i++)
|
||||
{
|
||||
Menu menu = awtMenuBar.getMenu(i);
|
||||
SwingMenuPeer peer = (SwingMenuPeer) menu.getPeer();
|
||||
int x1 = peer.getX();
|
||||
int x2 = x1 + peer.getWidth();
|
||||
if (point.x >= x1 && point.x <= x2)
|
||||
{
|
||||
ev.translatePoint(peer.getX(), peer.getY());
|
||||
peer.handleMouseEvent(ev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse motion events.
|
||||
*
|
||||
* @param ev the mouse motion event
|
||||
*/
|
||||
public void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
Point point = ev.getPoint();
|
||||
for (int i = 0; i < awtMenuBar.getMenuCount(); i++)
|
||||
{
|
||||
Menu menu = awtMenuBar.getMenu(i);
|
||||
SwingMenuPeer peer = (SwingMenuPeer) menu.getPeer();
|
||||
int x1 = peer.getX();
|
||||
int x2 = x1 + peer.getWidth();
|
||||
if (point.x >= x1 && point.x <= x2)
|
||||
{
|
||||
ev.translatePoint(peer.getX(), peer.getY());
|
||||
peer.handleMouseMotionEvent(ev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/* SwingMenuItemPeer.java -- A Swing based peer for AWT menu items
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.peer.MenuItemPeer;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
/**
|
||||
* A Swing based peer for the AWT MenuItem.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingMenuItemPeer
|
||||
implements MenuItemPeer
|
||||
{
|
||||
/**
|
||||
* The AWT menu item.
|
||||
*/
|
||||
MenuItem awtMenuItem;
|
||||
|
||||
/**
|
||||
* The Swing menu item.
|
||||
*/
|
||||
JMenuItem menuItem;
|
||||
|
||||
/**
|
||||
* Receives ActionEvents from the Swing menu item and forwards them
|
||||
* to the ActionListeners of the AWT MenuItem.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
private class SwingMenuItemListener implements ActionListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Receives notification when the action has been performed.
|
||||
*
|
||||
* @param event the action event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
event.setSource(awtMenuItem);
|
||||
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>SwingMenuItemPeer</code>.
|
||||
*
|
||||
* @param awtMenuItem the AWT menu item
|
||||
*/
|
||||
public SwingMenuItemPeer(MenuItem awtMenuItem)
|
||||
{
|
||||
this.awtMenuItem = awtMenuItem;
|
||||
menuItem = new JMenuItem(awtMenuItem.getLabel());
|
||||
menuItem.addActionListener(new SwingMenuItemListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the menu item.
|
||||
*/
|
||||
public void disable()
|
||||
{
|
||||
menuItem.setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the menu item.
|
||||
*/
|
||||
public void enable()
|
||||
{
|
||||
menuItem.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled state to <code>enabled</code>.
|
||||
*
|
||||
* @param enabled if the menu item should be enabled or not
|
||||
*/
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
menuItem.setEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label for the menu item.
|
||||
*
|
||||
* @param text the label to set
|
||||
*/
|
||||
public void setLabel(String text)
|
||||
{
|
||||
menuItem.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes the menu item. This releases any reference to the Swing and AWT
|
||||
* menu item.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
menuItem = null;
|
||||
awtMenuItem = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font for this menu item.
|
||||
*
|
||||
* @param font the font to set
|
||||
*/
|
||||
public void setFont(Font font)
|
||||
{
|
||||
menuItem.setFont(font);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/* SwingMenuPeer.java -- A Swing based peer for AWT menus
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.MenuPeer;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
|
||||
/**
|
||||
* A Swing based peer for the AWT menu.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingMenuPeer
|
||||
implements MenuPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* The AWT menu.
|
||||
*/
|
||||
Menu awtMenu;
|
||||
|
||||
/**
|
||||
* The Swing menu.
|
||||
*/
|
||||
SwingMenu menu;
|
||||
|
||||
/**
|
||||
* A specialized JMenu that can be used as 'backend' for an AWT menu.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
private class SwingMenu
|
||||
extends JMenu
|
||||
{
|
||||
|
||||
/**
|
||||
* Unconditionally returns <code>true</code>, since we assume that when the
|
||||
* menu has a peer, it must be showing.
|
||||
*
|
||||
* @return <code>true</code>
|
||||
*/
|
||||
public boolean isShowing()
|
||||
{
|
||||
// FIXME: This might be wrong. Maybe find a better way to do that.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden so that we can provide a location even without a real peer
|
||||
* attached.
|
||||
*
|
||||
* @return the screen location of this menu
|
||||
*/
|
||||
public Point getLocationOnScreen()
|
||||
{
|
||||
Point parentLoc = getParent().getLocationOnScreen();
|
||||
parentLoc.x += getX();
|
||||
parentLoc.y += getY();
|
||||
return parentLoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by forwarding them to
|
||||
* <code>processMouseEvent()</code>.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processMouseEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by forwarding them to
|
||||
* <code>processMouseMotionEvent()</code>.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processMouseMotionEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>SwingMenuPeer</code> instance.
|
||||
*
|
||||
* @param awtMenu the AWT menu
|
||||
*/
|
||||
public SwingMenuPeer(Menu awtMenu)
|
||||
{
|
||||
this.awtMenu = awtMenu;
|
||||
menu = new SwingMenu();
|
||||
menu.setDoubleBuffered(false);
|
||||
menu.setText(awtMenu.getLabel());
|
||||
for (int i = 0; i < awtMenu.getItemCount(); i++)
|
||||
{
|
||||
MenuItem item = awtMenu.getItem(i);
|
||||
item.addNotify();
|
||||
SwingMenuItemPeer peer = (SwingMenuItemPeer) item.getPeer();
|
||||
menu.add(peer.menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a menu item to this menu.
|
||||
*
|
||||
* @param item the menu item to add
|
||||
*/
|
||||
public void addItem(MenuItem item)
|
||||
{
|
||||
SwingMenuItemPeer menuItemPeer = (SwingMenuItemPeer) item.getPeer();
|
||||
menu.add(menuItemPeer.menuItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a separator to the menu.
|
||||
*/
|
||||
public void addSeparator()
|
||||
{
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a menu item from the menu.
|
||||
*
|
||||
* @param index the index of the menu item to remove
|
||||
*/
|
||||
public void delItem(int index)
|
||||
{
|
||||
menu.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the menu.
|
||||
*/
|
||||
public void disable()
|
||||
{
|
||||
menu.setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the menu.
|
||||
*/
|
||||
public void enable()
|
||||
{
|
||||
menu.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled state of the menu to <code>enabled</code>.
|
||||
*
|
||||
* @param enabled if the menu should be enabled or not
|
||||
*/
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
menu.setEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label of the menu.
|
||||
*
|
||||
* @param text the label to set
|
||||
*/
|
||||
public void setLabel(String text)
|
||||
{
|
||||
menu.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases any reference to the AWT and Swing menu instances.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
menu = null;
|
||||
awtMenu = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font for the menu.
|
||||
*
|
||||
* @param font the font to set
|
||||
*/
|
||||
public void setFont(Font font)
|
||||
{
|
||||
menu.setFont(font);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by forwarding them to the Swing menu.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
menu.handleMouseEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse motion events by forwarding them to the Swing menu.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
menu.handleMouseMotionEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the X coordinate of the upper left corner of the menu. This is
|
||||
* used internally by the SwingMenuBarPeer.
|
||||
*
|
||||
* @return the X coordinate of the upper left corner of the menu
|
||||
*/
|
||||
int getX()
|
||||
{
|
||||
return menu.getX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the menu. This is used internally by the
|
||||
* SwingMenuBarPeer.
|
||||
*
|
||||
* @return the X coordinate of the upper left corner of the menu
|
||||
*/
|
||||
int getWidth()
|
||||
{
|
||||
return menu.getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Y coordinate of the upper left corner of the menu. This is
|
||||
* used internally by the SwingMenuBarPeer.
|
||||
*
|
||||
* @return the X coordinate of the upper left corner of the menu
|
||||
*/
|
||||
public int getY()
|
||||
{
|
||||
return menu.getY();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/* SwingPanelPeer.java -- A PanelPeer based on Swing
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Panel;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
import java.awt.peer.PanelPeer;
|
||||
|
||||
/**
|
||||
* A panel peer based on Swing.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
// TODO: Maybe base implementation on JPanel. However, this doesn't seem
|
||||
// necessary, but might be good for more consistend Look.
|
||||
public class SwingPanelPeer
|
||||
extends SwingContainerPeer
|
||||
implements PanelPeer, LightweightPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>SwingPanelPeer</code> for the specified
|
||||
* AWT panel.
|
||||
*
|
||||
* @param panel the AWT panel
|
||||
*/
|
||||
public SwingPanelPeer(Panel panel)
|
||||
{
|
||||
super(panel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,367 @@
|
||||
/* SwingTextFieldPeer.java -- A Swing based peer for AWT textfields
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.TextField;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
import java.awt.peer.TextFieldPeer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
* A TextFieldPeer based on Swing JTextField.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class SwingTextFieldPeer
|
||||
extends SwingComponentPeer
|
||||
implements TextFieldPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* A specialized Swing textfield for use in the peer.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
private class SwingTextField
|
||||
extends JTextField
|
||||
implements SwingComponent
|
||||
{
|
||||
|
||||
/**
|
||||
* Overridden to provide normal behaviour even without a real peer
|
||||
* attached.
|
||||
*
|
||||
* @return the location of the textfield on screen
|
||||
*/
|
||||
public Point getLocationOnScreen()
|
||||
{
|
||||
return SwingTextFieldPeer.this.getLocationOnScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden so that the isShowing method returns the correct value for the
|
||||
* swing button, even if it has no peer on its own.
|
||||
*
|
||||
* @return <code>true</code> if the button is currently showing,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isShowing()
|
||||
{
|
||||
boolean retVal = false;
|
||||
if (SwingTextFieldPeer.this.awtComponent != null)
|
||||
retVal = SwingTextFieldPeer.this.awtComponent.isShowing();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden, so that the Swing button can create an Image without its
|
||||
* own peer.
|
||||
*
|
||||
* @param w the width of the image
|
||||
* @param h the height of the image
|
||||
*
|
||||
* @return an image
|
||||
*/
|
||||
public Image createImage(int w, int h)
|
||||
{
|
||||
return SwingTextFieldPeer.this.createImage(w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this textfield.
|
||||
*
|
||||
* @return <code>this</code>
|
||||
*/
|
||||
public JComponent getJComponent()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse events by forwarding it to the swing textfield.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
public void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processMouseEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse motion events by forwarding it to the swing textfield.
|
||||
*
|
||||
* @param ev the mouse motion event
|
||||
*/
|
||||
public void handleMouseMotionEvent(MouseEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processMouseMotionEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles key events by forwarding it to the swing textfield.
|
||||
*
|
||||
* @param ev the key event
|
||||
*/
|
||||
public void handleKeyEvent(KeyEvent ev)
|
||||
{
|
||||
ev.setSource(this);
|
||||
processKeyEvent(ev);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>SwingTextFieldPeer</code> instance for the specified
|
||||
* AWT textfield.
|
||||
*
|
||||
* @param textField the AWT textfield
|
||||
*/
|
||||
public SwingTextFieldPeer(TextField textField)
|
||||
{
|
||||
SwingTextField swingTextField = new SwingTextField();
|
||||
swingTextField.setText(textField.getText());
|
||||
init(textField, swingTextField);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum size of the textfield.
|
||||
*
|
||||
* @param len not used here
|
||||
*
|
||||
* @return the minimum size of the textfield
|
||||
*/
|
||||
public Dimension minimumSize(int len)
|
||||
{
|
||||
return swingComponent.getJComponent().getMinimumSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred size of the textfield.
|
||||
*
|
||||
* @param len not used here
|
||||
*
|
||||
* @return the preferred size of the textfield
|
||||
*/
|
||||
public Dimension preferredSize(int len)
|
||||
{
|
||||
return swingComponent.getJComponent().getPreferredSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum size of the textfield.
|
||||
*
|
||||
* @param len not used here
|
||||
*
|
||||
* @return the minimum size of the textfield
|
||||
*/
|
||||
public Dimension getMinimumSize(int len)
|
||||
{
|
||||
return swingComponent.getJComponent().getMinimumSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred size of the textfield.
|
||||
*
|
||||
* @param len not used here
|
||||
*
|
||||
* @return the preferred size of the textfield
|
||||
*/
|
||||
public Dimension getPreferredSize(int len)
|
||||
{
|
||||
return swingComponent.getJComponent().getPreferredSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the echo character.
|
||||
*
|
||||
* @param echoChar the echo character to be set
|
||||
*/
|
||||
public void setEchoChar(char echoChar)
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the echo character.
|
||||
*
|
||||
* @param echoChar the echo character to be set
|
||||
*/
|
||||
public void setEchoCharacter(char echoChar)
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end index of the current selection.
|
||||
*
|
||||
* @return the end index of the current selection
|
||||
*/
|
||||
public int getSelectionEnd()
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start index of the current selection.
|
||||
*
|
||||
* @return the start index of the current selection
|
||||
*/
|
||||
public int getSelectionStart()
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current content of the textfield.
|
||||
*
|
||||
* @return the current content of the textfield
|
||||
*/
|
||||
public String getText()
|
||||
{
|
||||
return ((JTextField) swingComponent.getJComponent()).getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content of the textfield.
|
||||
*
|
||||
* @param text the text to set
|
||||
*/
|
||||
public void setText(String text)
|
||||
{
|
||||
((JTextField) swingComponent.getJComponent()).setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current selection.
|
||||
*
|
||||
* @param startPos the start index of the selection
|
||||
* @param endPos the start index of the selection
|
||||
*/
|
||||
public void select(int start_pos, int endPos)
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the editable flag of the text field.
|
||||
*
|
||||
* @param editable <code>true</code> to make the textfield editable,
|
||||
* <code>false</code> to make it uneditable
|
||||
*/
|
||||
public void setEditable(boolean editable)
|
||||
{
|
||||
((JTextField) swingComponent.getJComponent()).setEditable(editable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current caret position.
|
||||
*
|
||||
* @return the current caret position
|
||||
*/
|
||||
public int getCaretPosition()
|
||||
{
|
||||
return ((JTextField) swingComponent.getJComponent()).getCaret().getDot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current caret position.
|
||||
*
|
||||
* @param pos the caret position to set
|
||||
*/
|
||||
public void setCaretPosition(int pos)
|
||||
{
|
||||
((JTextField) swingComponent.getJComponent()).getCaret().setDot(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the character at the specified location.
|
||||
*
|
||||
* @param x the X coordinate of the point to query
|
||||
* @param y the Y coordinate of the point to query
|
||||
*
|
||||
* @return the index of the character at the specified location
|
||||
*/
|
||||
public int getIndexAtPoint(int x, int y)
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounds of the character at the specified index.
|
||||
*
|
||||
* @param pos the index of the character
|
||||
*
|
||||
* @return the bounds of the character at the specified index
|
||||
*/
|
||||
public Rectangle getCharacterBounds(int pos)
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used.
|
||||
*/
|
||||
public long filterEvents(long filter)
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used.
|
||||
*/
|
||||
public InputMethodRequests getInputMethodRequests()
|
||||
{
|
||||
// TODO: Must be implemented.
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/* SwingToolkit.java -- A base toolkit for Swing peers
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Label;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Panel;
|
||||
import java.awt.TextField;
|
||||
import java.awt.peer.ButtonPeer;
|
||||
import java.awt.peer.CanvasPeer;
|
||||
import java.awt.peer.LabelPeer;
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
import java.awt.peer.MenuItemPeer;
|
||||
import java.awt.peer.MenuPeer;
|
||||
import java.awt.peer.PanelPeer;
|
||||
import java.awt.peer.TextFieldPeer;
|
||||
|
||||
import gnu.java.awt.ClasspathToolkit;
|
||||
|
||||
/**
|
||||
* A base implementation for {@link java.awt.Toolkit} that provides the
|
||||
* Swing based widgets. Concrete implementations still must provide the
|
||||
* remaining abstract methods.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public abstract class SwingToolkit extends ClasspathToolkit
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a SwingButtonPeer.
|
||||
*
|
||||
* @param button the AWT button
|
||||
*
|
||||
* @return the Swing button peer
|
||||
*/
|
||||
protected ButtonPeer createButton(Button button)
|
||||
{
|
||||
return new SwingButtonPeer(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SwingCanvasPeer.
|
||||
*
|
||||
* @param canvas the AWT canvas
|
||||
*
|
||||
* @return the Swing canvas peer
|
||||
*/
|
||||
protected CanvasPeer createCanvas(Canvas canvas)
|
||||
{
|
||||
return new SwingCanvasPeer(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SwingLabelPeer.
|
||||
*
|
||||
* @param label the AWT label
|
||||
*
|
||||
* @return the Swing label peer
|
||||
*/
|
||||
protected LabelPeer createLabel(Label label)
|
||||
{
|
||||
return new SwingLabelPeer(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SwingMenuPeer.
|
||||
*
|
||||
* @param menu the AWT menu
|
||||
*
|
||||
* @return the Swing menu peer
|
||||
*/
|
||||
protected MenuPeer createMenu(Menu menu)
|
||||
{
|
||||
return new SwingMenuPeer(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SwingMenuBarPeer.
|
||||
*
|
||||
* @param menuBar the AWT menubar
|
||||
*
|
||||
* @return the Swing menu bar peer
|
||||
*/
|
||||
protected MenuBarPeer createMenuBar(MenuBar menuBar)
|
||||
{
|
||||
return new SwingMenuBarPeer(menuBar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SwingMenuItemPeer.
|
||||
*
|
||||
* @param menuItem the AWT menu item
|
||||
*
|
||||
* @return the Swing menu item peer
|
||||
*/
|
||||
protected MenuItemPeer createMenuItem(MenuItem menuItem)
|
||||
{
|
||||
return new SwingMenuItemPeer(menuItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SwingPanelPeer.
|
||||
*
|
||||
* @param panel the AWT panel
|
||||
*
|
||||
* @return the Swing panel peer
|
||||
*/
|
||||
protected PanelPeer createPanel(Panel panel)
|
||||
{
|
||||
return new SwingPanelPeer(panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SwingTextFieldPeer.
|
||||
*
|
||||
* @param textField the AWT text field
|
||||
*
|
||||
* @return the Swing text field peer
|
||||
*/
|
||||
protected TextFieldPeer createTextField(TextField textField)
|
||||
{
|
||||
return new SwingTextFieldPeer(textField);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/* SwingWindowPeer.java -- An abstract base for Swing based window peers
|
||||
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 gnu.java.awt.peer.swing;
|
||||
|
||||
import java.awt.Window;
|
||||
import java.awt.peer.WindowPeer;
|
||||
|
||||
/**
|
||||
* An abstract base class for Swing based WindowPeer implementation. Concrete
|
||||
* implementations of WindowPeers should subclass this class in order to get
|
||||
* the correct behaviour.
|
||||
*
|
||||
* As a minimum, a subclass must implement all the remaining abstract methods
|
||||
* as well as the following methods:
|
||||
* <ul>
|
||||
* <li>{@link ComponentPeer#getLocationOnScreen()}</li>
|
||||
* <li>{@link ComponentPeer#getGraphics()}</li>
|
||||
* <li>{@link ComponentPeer#createImage(int, int)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public abstract class SwingWindowPeer
|
||||
extends SwingContainerPeer
|
||||
implements WindowPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a new instance of WindowPeer.
|
||||
*
|
||||
* @param window the AWT window
|
||||
*/
|
||||
public SwingWindowPeer(Window window)
|
||||
{
|
||||
super(window);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<!-- package.html - describes classes in gnu.java.awt.peer.swing package.
|
||||
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. -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Swing based AWT peers</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Swing based AWT peers.</h1>
|
||||
<p>This package defines an abstract set of AWT peers that is based on Swing
|
||||
widgets. This can be used as an implementation base for peer implementors
|
||||
who don't have access to native widgets or who want to build a quick
|
||||
prototype of a peer set without implementing all of the AWT widgets.
|
||||
</p>
|
||||
<p>An actual implementation would have to provide the following:
|
||||
<ul>
|
||||
<li>A concrete implementation of {@link java.awt.Toolkit}, possibly based
|
||||
on {@link SwingToolkit}. This implementation must provide all the missing
|
||||
methods of the <code>SwingToolkit</code>.</li>
|
||||
<li>Concrete implementations of {@link java.awt.peer.DialogPeer},
|
||||
{@link java.awt.peer.FramePeer} and {@link java.awt.peer.WindowPeer},
|
||||
ideally based on their <code>SwingXXXPeer</code> counterparts.
|
||||
Some methods must be specially
|
||||
overridden in those peers to provide useful functionality, like
|
||||
<code>getLocationOnScreen()</code>. See the API documentation for more
|
||||
details</li>
|
||||
<li>An implementation of {@link java.awt.Image}. These must be provided by
|
||||
the toplevel component peers.</li>
|
||||
<li>An implementation of {@link java.awt.Graphics}. This must also be
|
||||
provided by the toplevel peers.</li>
|
||||
<li>An implementation of {@link java.awt.Font}. This must be
|
||||
provided by the toolkit.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user