Results 1 to 4 of 4
  1. #1
    ysbn is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Question How to customize JTabbedPane tab header

    I want to change the textual header of tabs inside JTabbedPane. I need it to be a concatenation of two Strings with line break between them.
    For example, if the two Strings are A and B the tab header should look like this:
    ----
    A
    B
    ----

    I know two ways of concatenating Strings with line break:
    1. A + "\n" + B
    2. "<HTML>" + A + "<BR>" + B

    None of the above works when calling addTab() method of JTabbedPane!

    Thanks in advance.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    Java Code:
    tabs.add("<html><body><p>test1</p><p>test2</p></body></html>", panel1);
    html works for me (using paragraph and not break), but it doesn't look fantastic. You might consider creating a custom tabbed component and set the tab that way.

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,993
    Rep Power
    9

    Default

    Html also works fine for me while using addTab(). If you want further help, you'll have to provide an SSCCE that demonstrates the problem.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    ysbn is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default thanks it works now

    I didn't see it first but there was a customized tab component in my code

Similar Threads

  1. Customize JList
    By kcpavan in forum AWT / Swing
    Replies: 1
    Last Post: 12-01-2010, 05:50 AM
  2. customize formatter class to take in custom format?
    By diskhub in forum Advanced Java
    Replies: 1
    Last Post: 05-17-2010, 07:50 PM
  3. customize sorting
    By evermore in forum Advanced Java
    Replies: 5
    Last Post: 03-28-2010, 05:28 AM
  4. Replies: 2
    Last Post: 03-27-2010, 10:01 AM
  5. How to Customize Jfreechart value axis?
    By neeraj.singh in forum AWT / Swing
    Replies: 0
    Last Post: 02-16-2009, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •