Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6537821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:39:45+00:00 2026-05-25T10:39:45+00:00

I have Line2D and Arc2D objects laid out on my JPanel by Graphics2D drawing.

  • 0

I have Line2D and Arc2D objects laid out on my JPanel by Graphics2D drawing. You can have a look a part of it on this question ” How to make pixel perfect Line2D in – Graphics2D “. Now what I want to achieve is, I want to create two parallel lines and arcs for all Line2D and Arc2D objects. Visually,

Normal Line2D and Arc2D drawn currently,

enter image description here

Want to decorate it like this,

enter image description here

My Thoughts so far,

I might be able to achieve this by creating two different line and give an offset +gap and -gap from my normal line position. However This will make lots of objects which I don’t want to.

Now, is it possible to make my normal line thicker like this,

enter image description here

and give them a border and delete middle bit from it?

Is it possible to achieve this? if yes, May I please have some direction.

Thank you for any kind of help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:39:46+00:00Added an answer on May 25, 2026 at 10:39 am

    Use a BasicStroke and draw it twice, thicker and thinner.

    One line drawn twice

    import java.awt.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    import javax.swing.*;
    
    import javax.imageio.ImageIO;
    import java.io.File;
    
    class PaintThick {
    
        public static void main(String[] args) throws Exception {
            int size = 150;
            final BufferedImage bi = new BufferedImage(
                size,size,BufferedImage.TYPE_INT_RGB);
            Graphics2D g = bi.createGraphics();
    
            double pad = 20;
            Line2D.Double line1 = new Line2D.Double(
                pad,pad,(double)(size-pad),(double)(size-pad));
            int cap = BasicStroke.CAP_BUTT;
            int join = BasicStroke.JOIN_MITER;
            BasicStroke thick = new BasicStroke(15,cap,join);
            BasicStroke thinner = new BasicStroke(13,cap,join);
    
            g.setColor(Color.WHITE);
            g.fillRect(0,0,size,size);
    
            g.setColor(Color.BLACK);
            g.setStroke(thick);
            g.draw(line1);
    
            g.setColor(Color.WHITE);
            g.setStroke(thinner);
            g.draw(line1);
    
            ImageIO.write(bi,"png",new File("img.png"));
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(
                        null, new JLabel(new ImageIcon(bi)));
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

G'day, I have JPanel with some Line2D objects on it. Issue is when I
How can I make a multi lined UISegmentedControl. I need it to have 6
Have a n-tire web application and search often times out after 30 secs. How
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have question on limiting the resizing the text Tk widget. I have the
I have the simple code: f = open('out.txt','w') f.write('line1\n') f.write('line2') f.close() Code runs on
I have this output from SQL table: array{ data => line1 line2 line3 }
This must be a really basic question: I am trying to use Matplotlib. Here's
I have a simple array like this: $input = array('Line1', 'Line2', 'Line3'); And want
I have the below, which has worked fine until I added the last part:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.