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

jtahlborn
Basically, java wasn't designed to be that low level. Other than that, probably no good reason.
800670
Yes, I see, but why isn´t it possible to write the header myself when it consists of usual bytes? That is what I can not understand.
EJP
At a guess it is because either (a) using raw sockets requires privileges and/or (b) Microsoft keep changing the raw sockets API or (c) it's a general-purpose programming language and why would you want to do that?
++sja
You can do raw sockets with third party libraries. They won't be pure java - but you didn't really expect to do raw sockets on your cell phone or TV set top box, or spy and spoof someone's network using an applet.

The FAQ for one such library hints what kind of a mess raw sockets are due to differences in common operating systems; see http://www.savarese.com/software/rocksaw/
At least to some extent the windows API didn't support raw access when java first came out.

So lowest common denominator would be a more likely explanation.
1 - 5
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,121 views