Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Shapes: How to Outline with Thick Borders?

  1. #1
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Question Shapes: How to Outline with Thick Borders?

    The program I am currently writing allows users to "select" objects that bounce around the screen. When an object is selected, the program draws a border around it so that the user can know that it is selected. However, the method I currently use to draw the outline, Graphics's drawOval() method, only draws a single pixel border, and this border is often not think enough to distinguish from the actual shape it is meant to outline.

    Does anyone know of a way to draw a think border around a shape?
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Shapes: How to Outline with Thick Borders?

    Set the Graphics Stroke....(or change the color).
    For instance:
    Stroke previousStroke = g.getStroke();
    g.setStroke(new BasicStroke(2.0f));//2 pixel width
    g.drawOval(...)
    g.setStroke(previousStroke);

    ...assuming g is a Graphics2D instance

  3. The Following User Says Thank You to copeg For This Useful Post:

    snowguy13 (January 4th, 2012)

  4. #3
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: Shapes: How to Outline with Thick Borders?

    Ah! I knew there had to be a simple way to do it!

    Okay, thank you very much!
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

Similar Threads

  1. Adding an array of shapes to a GUI window
    By cslx99 in forum AWT / Java Swing
    Replies: 3
    Last Post: December 8th, 2011, 06:03 AM
  2. Combining Shapes + Text
    By aussiemcgr in forum Java Theory & Questions
    Replies: 5
    Last Post: February 17th, 2011, 10:15 AM
  3. How I can create those shapes with Java?
    By Learner in forum AWT / Java Swing
    Replies: 3
    Last Post: November 18th, 2010, 02:10 AM
  4. demarkating portions of images in different shapes
    By forgetlosing in forum Java Theory & Questions
    Replies: 0
    Last Post: March 25th, 2010, 08:41 AM
  5. Converting Images to Shapes
    By Ian in forum Java Theory & Questions
    Replies: 2
    Last Post: February 7th, 2010, 05:18 PM

Tags for this Thread