Java Code Examples for java.awt.Graphics.fill3DRect()

The following are Jave code examples for showing how to use fill3DRect() of the java.awt.Graphics class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: javase   File: PaintFillColor.java   View Source Code Vote up 6 votes
public void paint(Graphics g) {
	super.paint(g);
	g.setColor(Color.blue);
	g.setFont(new Font("宋体", Font.BOLD, 20));
	g.drawRect(100, 300, 150, 100);
	g.drawRoundRect(300, 200, 200, 200, 200, 200);
	/*
	 * x - 要绘制矩形的 x 坐标。 y - 要绘制矩形的 y 坐标。 width - 要绘制矩形的宽度。 height -
	 * 要绘制矩形的高度。 arcWidth - 4 个角弧度的水平直径。 arcHeight - 4 个角弧度的垂直直径。
	 */
	g.setColor(Color.red);
	g.fillRect(100, 100, 100, 100);
	g.setColor(Color.green);
	g.fillOval(200, 100, 150, 150);
	// 填充夜色 圆形填充

	g.fill3DRect(150, 450, 50, 50, false);
	g.fillArc(200, 450, 50, 50, 50, 50);
	g.fillRect(250, 450, 50, 50);
	g.fillRoundRect(300, 450, 50, 50, 50, 50);
	g.drawString("如果", 400, 150);
}
 
Example 2
Project: LivroJavaComoProgramar10Edicao   File: LinesRectsOvalsJPanel.java   View Source Code Vote up 6 votes
@Override
public void paintComponent(Graphics g)
{
   super.paintComponent(g); 
   this.setBackground(Color.WHITE);

   g.setColor(Color.RED);
   g.drawLine(5, 30, 380, 30);

   g.setColor(Color.BLUE);
   g.drawRect(5, 40, 90, 55);
   g.fillRect(100, 40, 90, 55);

   g.setColor(Color.BLACK);
   g.fillRoundRect(195, 40, 90, 55, 50, 50);
   g.drawRoundRect(290, 40, 90, 55, 20, 20);

   g.setColor(Color.GREEN);   
   g.draw3DRect(5, 100, 90, 55, true);
   g.fill3DRect(100, 100, 90, 55, false);

   g.setColor(Color.MAGENTA);
   g.drawOval(195, 100, 90, 55);
   g.fillOval(290, 100, 90, 55);
}
 
Example 3
Project: TrabalhoFinalEDA2   File: mxConnectionHandler.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void paint(Graphics g)
{
	if (bounds != null)
	{
		if (connectIcon != null)
		{
			g.drawImage(connectIcon.getImage(), bounds.x, bounds.y,
					bounds.width, bounds.height, null);
		}
		else if (handleEnabled)
		{
			g.setColor(Color.BLACK);
			g.draw3DRect(bounds.x, bounds.y, bounds.width - 1,
					bounds.height - 1, true);
			g.setColor(Color.GREEN);
			g.fill3DRect(bounds.x + 1, bounds.y + 1, bounds.width - 2,
					bounds.height - 2, true);
			g.setColor(Color.BLUE);
			g.drawRect(bounds.x + bounds.width / 2 - 1, bounds.y
					+ bounds.height / 2 - 1, 1, 1);
		}
	}
}
 
Example 4
Project: Tarski   File: mxConnectionHandler.java   View Source Code Vote up 5 votes
/**
 * 
 */
public void paint(Graphics g) {
  if (bounds != null) {
    if (connectIcon != null) {
      g.drawImage(connectIcon.getImage(), bounds.x, bounds.y, bounds.width, bounds.height, null);
    } else if (handleEnabled) {
      g.setColor(Color.BLACK);
      g.draw3DRect(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1, true);
      g.setColor(Color.GREEN);
      g.fill3DRect(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2, true);
      g.setColor(Color.BLUE);
      g.drawRect(bounds.x + bounds.width / 2 - 1, bounds.y + bounds.height / 2 - 1, 1, 1);
    }
  }
}
 
Example 5
Project: openjdk-jdk10   File: LightweightEventTest.java   View Source Code Vote up 5 votes
@Override
public void paint(Graphics g) {

    super.paint(g);
    Rectangle bounds = getBounds();
    if (superIsButton) {
        return;
    }
    Dimension size = getSize();
    Color oldColor = g.getColor();

    // draw border
    g.setColor(getBackground());
    g.fill3DRect(0, 0, size.width, size.height, false);
    g.fill3DRect(3, 3, size.width - 6, size.height - 6, true);

    // draw text
    FontMetrics metrics = g.getFontMetrics();
    int centerX = size.width / 2;
    int centerY = size.height / 2;
    int textX = centerX - (metrics.stringWidth(labelString) / 2);
    int textY = centerY
            + ((metrics.getMaxAscent() + metrics.getMaxDescent()) / 2);
    g.setColor(getForeground());
    g.drawString(labelString, textX, textY);

    g.setColor(oldColor);
}