The Artima Developer Community
Sponsored Link

Java Answers Forum
Draw rectangle with dotted lined

1 reply on 1 page. Most recent reply: May 16, 2002 10:23 AM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
james smith

Posts: 8
Nickname: jochem
Registered: Apr, 2002

Draw rectangle with dotted lined Posted: May 16, 2002 2:41 AM
Reply to this message Reply
Advertisement
Hi there, I want to draw a rectangle probably using graphics.drawrect(x,y,z,w);
is there a way to instead of drawing a solid line get it to draw a dotted line instead.


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Draw rectangle with dotted lined Posted: May 16, 2002 10:23 AM
Reply to this message Reply
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

Flat View: This topic has 1 reply on 1 page
Topic: including problem Previous Topic   Next Topic Topic: IP-adres

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use