Java Utililty Methods Draw Rectangle

List of utility methods to do Draw Rectangle

  1. HOME
  2. Java
  3. D
  4. Draw Rectangle

Description

The list of methods to do Draw Rectangle are organized into topic(s).

Method

void drawRect(Graphics g, int left, int top, int width, int height, int lineWidth)
_more_
left = left - lineWidth / 2;
top = top - lineWidth / 2;
width = width + lineWidth;
height = height + lineWidth;
for (int i = 0; i < lineWidth; i++) {
 g.drawRect(left, top, width, height);
 left = left + 1;
 top = top + 1;
...
void drawRect(Graphics g, int x, int y, int w, int h)
draw Rect
if (w < 0) {
 int nx = x + w;
 x = nx;
 w = -w;
if (h < 0) {
 int ny = y + h;
 y = ny;
...
void drawRect(Graphics g, int x, int y, int w, int h)
draw Rect
g.fillRect(x, y, w + 1, 1);
g.fillRect(x, y + 1, 1, h);
g.fillRect(x + 1, y + h, w, 1);
g.fillRect(x + w, y + 1, 1, h);
void drawRect(Graphics g, Rectangle r)
draw Rect
if (g == null || r == null) {
 return;
g.drawRect(r.x, r.y, r.width, r.height);
void drawRect(Rectangle r, Graphics2D g)
DrawRect
g.drawRect(r.x, r.y, r.width, r.height);
void drawRectOrOval(Graphics2D g, boolean oval, int arc, int x, int y, int width, int height)
draw Rect Or Oval
if (oval) {
 g.drawOval(x, y, width, height);
} else {
 if (arc == 0) {
 g.drawRect(x, y, width, height);
 } else {
 g.drawRoundRect(x, y, width, height, arc, arc);
void drawRectPlot(Graphics2D g, int x, int y, int size)
Draws a rectangle centered on (x, y)
g.drawRect(x - size / 2, y - size / 2, size, size);
void drawRoundRect(Graphics g, int left, int top, int width, int height, int arcWidth, int arcHeight, int lineWidth)
_more_
left = left - lineWidth / 2;
top = top - lineWidth / 2;
width = width + lineWidth;
height = height + lineWidth;
for (int i = 0; i < lineWidth; i++) {
 g.drawRoundRect(left, top, width, height, arcWidth, arcHeight);
 if ((i + 1) < lineWidth) {
 g.drawRoundRect(left, top, width - 1, height - 1, arcWidth, arcHeight);
...
void drawThickRect(Graphics g, int x, int y, int w, int h, int d)
draw Thick Rect
g.fillRect(x, y, w, d);
g.fillRect(x, y + d, d, h - 2 * d);
g.fillRect(x, y + h - d, w, d);
g.fillRect(x + w - d, y + d, d, h - 2 * d);
void drawThickRect(Graphics g, int x, int y, int width, int height, int thickness)
Draw a thick rectangle - another of the things missing from the AWT
for (int i = 0; i < thickness; i++)
 g.drawRect(x + i, y + i, width - 2 * i, height - 2 * i);


AltStyle によって変換されたページ (->オリジナル) /