public class G3DRect extends GRect
G3DRect
class is used to represent a rectangle whose
borders are drawn to create a three-dimensional effect. The G3DRect
class is a subclass of GRect
, and therefore
implements all the methods defined for that class. In addition, the
G3DRect
class supports the following methods:
|
The appearance of a G3DRect
object depends on the system on
which it is displayed and is typically more effective if the
G3DRect
is filled.
To use the G3DRect class, the first
step is to construct a new G3DRect
object and add it to an existing GCanvas (assumed here to be
stored in the variable gc ), as follows:
G3DRect rect = new G3DRect(100, 75, 150, 50);
This code creates a |
![]() |
Constructor and Description |
---|
G3DRect(double width,
double height)
Constructs a new 3D rectangle with the specified width and height,
positioned at the origin.
|
G3DRect(double x,
double y,
double width,
double height)
Constructs a new 3D rectangle with the specified bounds.
|
G3DRect(double x,
double y,
double width,
double height,
boolean raised)
Constructs a new 3D rectangle with the specified bounds which is
raised if the final parameter is
true . |
Modifier and Type | Method and Description |
---|---|
boolean |
isRaised()
Tests whether this object appears raised.
|
void |
paint(java.awt.Graphics g)
Implements the
paint operation for this graphical object. |
void |
setRaised(boolean raised)
Sets whether this object appears raised.
|
getBounds, getFillColor, getHeight, getSize, getWidth, isFilled, scale, scale, setBounds, setBounds, setFillColor, setFilled, setSize, setSize
addActionListener, addMouseListener, addMouseMotionListener, contains, contains, fireActionEvent, fireActionEvent, getColor, getLocation, getParent, getX, getY, isVisible, move, movePolar, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, sendBackward, sendForward, sendToBack, sendToFront, setColor, setLocation, setLocation, setParent, setVisible, toString
public G3DRect(double width, double height)
width
- The width of the rectangle in pixelsheight
- The height of the rectangle in pixelspublic G3DRect(double x, double y, double width, double height)
x
- The x-coordinate of the upper left cornery
- The y-coordinate of the upper left cornerwidth
- The width of the rectangle in pixelsheight
- The height of the rectangle in pixelspublic G3DRect(double x, double y, double width, double height, boolean raised)
true
.x
- The x-coordinate of the upper left cornery
- The y-coordinate of the upper left cornerwidth
- The width of the rectangle in pixelsheight
- The height of the rectangle in pixelsraised
- true
if this rectangle should appear raisedpublic void paint(java.awt.Graphics g)
paint
operation for this graphical object. This method
is not called directly by clients.public void setRaised(boolean raised)
raised
- true
if the object appears raised, false
otherwisepublic boolean isRaised()
true
if the object appears raised, false
otherwise