Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JTabbedPane title alignment

viklund_andersOct 6 2010 — edited Oct 9 2010
Hi,

I need guidance how to align the tab title text
"Right" title - right alignment
"Left" title -left alignment

Thanks!
import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class MainClass {
  static void addIt(JTabbedPane tabbedPane, String text) {
    JLabel label = new JLabel(text);
    JButton button = new JButton(text);
    JPanel panel = new JPanel();
    tabbedPane.addTab(text, panel);
  }

  public static void main(String[] args) {
    JFrame f = new JFrame("JTabbedPane Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTabbedPane tabbedPane = new JTabbedPane( JTabbedPane.LEFT);
    addIt(tabbedPane, "Tab One long title");
    addIt(tabbedPane, "Right"); //why is this title centered?
    addIt(tabbedPane, "Left");  //why is this title centered?
    f.add(tabbedPane);
    f.setSize(300, 200);
    f.setVisible(true);
  }
}
Edited by: user6102378 on 2010-okt-07 10:04

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 6 2010
Added on Oct 6 2010
11 comments
8,057 views