Java Graphics Draw drawFocus(Graphics g, int x, int y, int w, int h)

Here you can find the source of drawFocus(Graphics g, int x, int y, int w, int h)

Description

Draws a focus border.

License

Open Source License

Parameter

Parameter Description
g a parameter
x a parameter
y a parameter
w a parameter
h a parameter

Declaration

public static void drawFocus(Graphics g, int x, int y, int w, int h) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * /*  ww  w  .  ja  v  a2s  .  c  o m*/
 * Contributors:
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

import java.awt.BasicStroke;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Stroke;

public class Main {
    /**
     * Draws a focus border.
     * 
     * @param g
     * @param x
     * @param y
     * @param w
     * @param h
     */
    public static void drawFocus(Graphics g, int x, int y, int w, int h) {
        Graphics2D g2d = (Graphics2D) g;
        Stroke old = g2d.getStroke();
        g2d.setStroke(
                new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1f, new float[] { 1f, 2f }, 1));
        g2d.drawLine(x, y, x + w - 1, y);
        g2d.drawLine(x, y + h, x + w - 1, y + h);
        g2d.drawLine(x, y, x, y + h - 1);
        g2d.drawLine(x + w, y, x + w, y + h - 1);
        g2d.setStroke(old);
    }
}

Related

  1. drawEtchedRect(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
  2. drawFilledBox(Graphics2D g, int x, int y, int width, int height)
  3. drawFilledOctagon(Graphics2D g, int x, int y, float size)
  4. drawFilter(Graphics g, Color c, double transparency, int midx, int midy, int rx, int ry)
  5. drawFleche1(Graphics g, double x, double y, double x1, double y1, int L)
  6. drawFocus(Graphics2D g2, int iX, int iY, int iWidth, int iHeight)
  7. drawFrank(Graphics g, int x, int y)
  8. drawGatter(Graphics g, int xDist, int yDist)
  9. drawGlow(Graphics2D g2, Area area, double width, Color color)