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 5 of 5

Thread: TitledBorder Size and Color

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    27
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default TitledBorder Size and Color

    I created a titledBorder. How can I change the size and the color of my border?
    Thanks in advance


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: TitledBorder Size and Color

    As always, the API is your best friend: BorderFactory (Java Platform SE 7 )
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Lotus2013 (January 28th, 2014)

  4. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    27
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default Re: TitledBorder Size and Color

    Thank you. I checked it but there's something that I don't understand. for creating a TitledBorder, there are 6 ways:
    1: createTitledBorder(Border border)
    2: createTitledBorder(Border border, String title)
    3: createTitledBorder(Border border, String title, int titleJustification, int titlePosition)
    4: createTitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)
    5: createTitledBorder(String title)
    6: createTitledBorder(String title)

    but none of these specifies the thickness of the border itself.

    --- Update ---

    I did this to make it work but it doesn't work :

    Border title = BorderFactory.createLineBorder(myColor, 2);
    headerPanel.setBorder(BorderFactory.createTitledBo rder(title, "ورود", TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION, myFont, myColor));

  5. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: TitledBorder Size and Color

    What do you mean when you say it doesn't work? What happens if you user a thicker line, like 10?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. The Following User Says Thank You to KevinWorkman For This Useful Post:

    Lotus2013 (January 28th, 2014)

  7. #5
    Junior Member
    Join Date
    Oct 2013
    Posts
    27
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default Re: TitledBorder Size and Color

    I don't know why the last time I tried, It didn't show the title. Then I changed the code and again pasted this code and it worked. Everything was OK. Thankssssss

Similar Threads

  1. Re: How to Change JTextArea font, font size and color
    By binokyo10 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 5th, 2012, 12:12 PM
  2. How to Change JTextArea font, font size and color
    By Flash in forum Java Swing Tutorials
    Replies: 7
    Last Post: January 14th, 2012, 10:47 PM
  3. text color changer based on words/ word classification by color
    By knoxy5467 in forum Java Theory & Questions
    Replies: 25
    Last Post: June 15th, 2011, 07:52 AM
  4. Change font color and size
    By javanovice in forum AWT / Java Swing
    Replies: 2
    Last Post: April 20th, 2010, 09:57 AM
  5. How to Change JTextArea font, font size and color
    By Flash in forum Java Code Snippets and Tutorials
    Replies: 4
    Last Post: July 8th, 2008, 01:45 PM

Tags for this Thread