How do you increase the thickness of lines?

Hi
Hope you can help, im writing an applet which requires lines to be drawn on screen. I know how to draw the actual line but i'm having problems with the thickness of the line.
I would like to make the line thicker but im not sure how to do this
Any help would be much appreciated

Look at the Stroke object that Graphics2D uses. One way to use it is like so:
Graphics2D g2 = (Graphics2D)g;
int lineThickness = 4;
g2.setStroke(new BasicStroke(lineThickness));Here's a more detailed example that uses a JApplet:
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import javax.swing.JPanel;
class GraphicsEg2
    private JPanel mainPanel = new JPanel();
    private JPanel graphicsPanel = new JPanel()
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            myPaint(g);
    public GraphicsEg2()
        mainPanel.setPreferredSize(new Dimension(800, 800));
        mainPanel.setLayout(new BorderLayout());
        mainPanel.add(graphicsPanel);
    private void myPaint(Graphics g)
        drawMyRect(g);
        drawMyEllipse((Graphics2D)g);
    private void drawMyEllipse(Graphics2D g2)
        Ellipse2D myEllipse = new Ellipse2D.Double(10.0, 10.0, 200.0, 100.0);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setStroke(new BasicStroke(5));
        g2.setPaint(Color.white);
        g2.fill(myEllipse);
        g2.setPaint(Color.red);
        g2.draw(myEllipse);
    private void drawMyRect(Graphics g)
        Graphics2D g2 = (Graphics2D)g;
        Line2D line = new Line2D.Double(10, 10, 40, 40);
        g2.setColor(Color.blue);
        g2.setStroke(new BasicStroke(10));
        g2.draw(line);
        Rectangle2D rect = new Rectangle2D.Double(20, 20, 600, 400);
        g2.draw(rect);
        g2.setPaint(new GradientPaint(0, 0, Color.blue, 300, 200, Color.green, true));
        g2.fill(rect);
    public JPanel getMainPanel()
        return mainPanel;
}and the JApplet code:
import java.awt.Dimension;
import javax.swing.JApplet;
public class GraphicsEgApplet extends JApplet
    public void init()
        try
            javax.swing.SwingUtilities.invokeAndWait(new Runnable()
                public void run()
                    createGUI();
        catch (Exception e)
            System.err.println("createGUI didn't successfully complete");
    private void createGUI()
        getContentPane().add(new GraphicsEg2().getMainPanel());
        setSize(new Dimension(700, 600));
}Edited by: petes1234 on Feb 12, 2008 5:17 PM

Similar Messages

  • How do I increase the number of lines presented in a drop down list?

    When I am entering a single character/number for each of a random selection of three letters in a password verification, I get a drop down list from A to S only, the first 20. Accessing letter T to number 9 means scrolling down. How can I increase the number of lines in a drop down box to 36?

    Hi canddski,
    If you are taking about an interface on a website, this is up to the ui designer. But there is a reflow that depends on screensize for the Firefox UI.
    You can use asp to control the list:
    [http://forums.asp.net/t/1970301.aspx?How+can+i+display+selected+no+of+records+from+datatable+using+dropdown+list+without+database+]
    but also try asking on stackoverflow.com

  • How do you increase the volumne size of a hard drive partition?

    how do you increase the volumne size of a hard drive partition? the drive is set up into 3 partitions C, HP_tools and, recovery, C has space and would like to move some to HP_tools that is full. when I run backup I get drive full. I have run backup now to an external drive so that is not an issue.

    Hi,
    Firstly please don't keep anything in HP_TOOLS except things have been there. You can use Windows systems tool called Disk  Management. Please use the following tutorial:
      http://www.howtogeek.com/howto/windows-vista/resiz​e-a-partition-for-free-in-windows-vista/
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How do you increase the font size to bigger than 24, using the typewriter tool in Adobe Acrobat Pro 9 for Mac?

    How do you increase the font size to bigger than 24, using the typewriter tool in Adobe Acrobat Pro 9 for Mac?   Often I just want to label an item on a map that is in PDF and want to use a simple label rather than a Text Box for labeling, but have yet to find a way to increase the font size beyond 24.   Can someone help me with this? - JML

    Read this:
    https://forums.adobe.com/thread/1468782?sr=stream&ru=2382437

  • How do you change the spacing between lines of text?

    using Dreamweaver 6 how do you change the spcing between lines of text. Not seeing it as a option in the page properties menu.

    Try CSS line-height property.
    Kenneth Kawamoto
    [link removed by moderator]

  • How do you increase the number of messages retained in your inbox?

    How do you increase the number of messages retained in the inbox?

    settings - mail - email account - mail days to sync - choose the desired option.

  • Apple Mail (Mavericks), Viewing size of list is too small.how do you increase the size of the email message list.  The font is too small, I can hardly read them.

    In Apple Mail, using Mavericks, how do you increase the size of the email message list that displays on the left side of the screen?
    The font size is so small.
    Thanks.

    Thank you for responding.  After investigating and checking further, it was clear that only one of your suggestions changes the font size of the list of emails, also called the In-box.  And that is the display resolution.
    However, changing the display resolution affects the dots per inch of everything, everywhere and makes it larger.
    Given the high end fee Apple charges for their products, and the generally well developed software they provide, it is hard to imagine they have not corrected this obvious slight of effort on the inbox text. At times Apple's "one-size-fits-all" and "it's our way or no way" mentality astounds me and makes me want to run back to Microsoft.
    Evidently this is a well known mistake, which has yet to receive any attention.
    Again, thank you for your effort and assistance on my behalf.

  • How do you increase the font size on Photoshop menu?

    I can barely read the Photoshop menu - it is like microfiche - how do you increase the size of the fonts in the menu?

    click edit>preferences>interface>ui font size.
    restart ps to see the changes.

  • How do you increase the vibration intensity on a Iphone 4.

    Here's my question: How do you increase the vibration intensity on a Iphone 4.  Yes, iphone 4 does have the normal vibration intensity, but I want to increase the vibration strength.

    No can do

  • How can I Increase the Thickness of Blinking Cursor in adobe reader?

    I sometimes refer to another part of file of pdf and to get back, blinking cursor is supposed to help me but it is tiny blinking I have hard time to find it back.
    How can I increase the thickiness of blinking cursor in adobe reader?

    Do you mean "Recent Tags" which has an icon a blue-colored folder with a primitive looking magnifying glass over the folder?
    That folder does have a limit of 10 results. If you want to create an "All Tags" item on the Boomarks Menu, you can do that by creating your own "smart folder." The process I use is a little involved, so bear with me (also, see the screen shots).
    The query used by Recent Tags is:
    place:type=6&sort=14'''&maxResults=10'''
    So for All Tags we will drop the maximum results limit:
    place:type=6&sort=14
    ''If you prefer your tags in alphabetical order instead of having the most recently used at the top, use this instead:''
    place:type=6&sort=1
    Go ahead and select the line you want and right-click > copy it.
    Next, click the bookmarks drop-down button, expand the Bookmarks Toolbar, right-click any existing item, and choose New Bookmark.
    In Location, paste the query, and in name, type All Tags (or your preferred description). When you click Add Bookmark, Firefox will add it, but it doesn't show the blue search folder icon. Drag the bookmark to the menu, and it will turn into a functioning search folder.
    Success?

  • How do you increase the voicemail volume on an iPhone 4s ( Verizon ). The phone volume is fine. It is when I retrieve voicemails. Even the speakerphone is faint. I have adjusted the side volume buttons and the volume control in settings.What am I missing?

    How do I increase the voicemail volume on an iPhone 4s ( Verizon )? The phone volume is fine. I have adjusted both side volume buttons as well as the volume control in settings.

    Number one - that person has given you false information...the Apple store genius bar supports all Apple products whether in or out of warranty.  Checking is free, service on an out of warranty item is not free.
    Try a reboot by holding both the power and home buttons until the apple logo appears, ignore the red slider if that appears.
    Since you show that you have iOS 7.0.3 you might want to update that iOS to 7.0.4...plug the iPhone in so you are on a solid power source, then while on a WiFi go to Settings > General > Software Update and update to 7.0.4.

  • How do you find the number of lines in a file?

    I need to count how many lines there are in a file, I am using a BufferedReader to read in the data, but how can I find the number of lines?
    Thanks

    That depends. How do you define a line? Is it a specific number of
    characters, a String that's terminated by a newline character or some
    combination thereof?

  • How do you increase the maximum number of migration batches using EAC?

    When I try to run a new batch, I'm getting the following error message:
    The maximum number of migration batches is already running. Please remove a batch before you add another one.
    How do I increase the maximum number of migration batches using EAC? Thanks for your help.

    Hi WinndowsGuy,
    Is there any update on this thread?
    Thanks,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Simon Wu
    TechNet Community Support

  • How do you increase the size of the tabs in excel?

    Hello,
    I am working with Excel on the new 27" iMac, can anyone inform how you are able to increase the size of the tabs on each worksheets?
    The software is OfficeMacs 2011.
    Thanks,
                  A

    http://answers.microsoft.com/en-us/mac?auth=1

  • How do you increase the video size with a button?

    I'm trying to set up a demo for a meeting. I want to show how
    you can increase the size of the video.
    Example:
    http://video.google.com/videoplay?docid=-1532523169750528353
    There are two buttons in the bottom right corner of the
    player that will increase the video size.

    I havn't tried this but I would thinkg that this could work:
    If you have a video object on your stage (the object that the video
    actually plays in) you could probably make a button that simply
    changes the dimensions of it such as:
    setProperty("theVideoPlayer",_height, 240);
    setProperty("theVideoPlayer",_width, 320);
    The movie should adjust to fit the screen, however if you
    make the movie larger than or a different aspect ratio than the
    original, it will be blurred or distorted respectively. Make your
    original movie, therefore, at the largest size you want it to be
    seen. Keep the aspect ration the same always.

Maybe you are looking for

  • How to write to mounted disc image

    I need to add a file to a disc image I created, but it always comes up no write no matter what I do. Anyone know a good tip to do this? Thanks.

  • Win7/32 Preview Problem with Adobe Reader XI

    we need Win7/32 with Adobe Reader XI. The Preview function in the explorer does not yet work. Windows is in German, Adobe Reader in English Thanks for your help

  • How do you set up more than one Personal domain name to your .Mac account

    I have registered 3 domain names changed all the cnames to web.mac.com. Now on the menu to set Personal domain on my .Mac account it only lets you add 0ne Domain name? How do we add more or is there a limit?

  • A Bunch of Droid X questions...still figuring out how to use it

    I got my Droid X about a week ago, I love it! But there are some things that I am still trying to figure out, who knows if they are even an option on the phone. Any help would be greatly appreciated. 1) My calendar doesn't show both evens from my per

  • Validations to Leave Request

    Hi Gurus, We are using ESS in ERP2005. I have a clarifications, that where to add the validations for the leave request eg: to check the employee has enough leaves, and incase of any cusomer specific conditons has to be checked against leave where it