Thomas SMETS
Posts: 307
Nickname: tsmets
Registered: Apr, 2002
|
|
Re: Draw rectangle with dotted lined
|
Posted: May 16, 2002 10:23 AM
|
|
You may interested by this : _ http://www.zaval.org/products/lwvcl/ _ http://www.jguru.com/faq/view.jsp?EID=114099
package test.gui.test;
import javax.swing.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.BasicStroke;
import java.awt.Stroke;
import java.awt.geom.*;
import org.apache.log4j.*;
/**
* The purpose of this class is to :
* Show how to draw dotted-line
*
*
* @author <a href="mailto:tsmets@altern.org">Thomas SMETS, Brussels</a>
* @version 0.0.1 initial
*/
public class DottedRectangle
{
JFrame jf = new JFrame ("DottedRectangle");
Category log = Category.getInstance (DottedRectangle.class);
Graphics g;
DottedRectangle ()
{
jf.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
jf.setSize ( 400, 400);
jf.setVisible (true);
g = jf.getContentPane ().getGraphics ();
Graphics2D g2d = (Graphics2D) g;
g.setColor (Color.red);
g2d.setBackground (Color.blue);
g2d.setStroke (
new BasicStroke(
1f,
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND,
1f,
new float[] {2f},
0f) );
g.drawRect (100,100,100,100);
}
/**
*
*/
public static void main (String[] args)
{
BasicConfigurator.resetConfiguration ();
BasicConfigurator.configure ();
DottedRectangle DR = new DottedRectangle ();
}
}
Thomas SMETS, SCJP2 - Brussels
|
|