How to make JTabbedPane Title component take up entire tab width?

Starting with JDK 1.6, JTabbedPane has been enhanced to allow you to specify an arbitrary Component for the title of a tab (I think before, you could only specify a JLabel and/or icon). We make use of this in our application by specifying a Panel with a GridBagLayout and three children: an Icon (on the left), a label (middle), and a close button (right). the middle component, the label, gets all the weightx and has fill set to HORIZONTAL. Everything looks good - as long as the tabs stay on a single row. When another tab is added and the TabbedPane extends to a second row, things don't look: the tabs are allocated alot more white space now - but the Component isn't being given that extra space! Consequently, the icons on the left and right of my label stay next to the label, instead of staying next to the edges of the tab!
Is this a bug in the JDK?
If it's not a bug, how do I make use of all available tab space?

Hi Darryl,
Thanks for the suggestion. Below is a primitive standalone example. It brings up an empty frame and you can click on the "Add Tab" button to add a tab. When you do, you'll see that the tab's "title" area consists of an "i" button, a label, and a "x" button. The tab itself isn't much bigger than those three components, so things look ok. Now, add two more tabs....the 2nd tab still fits on the first row of the TabbedPane, so things still look ok. When you add the third tab, the first tab gets placed on a new 2nd row of the TabbedPane and the tab takes up the whole width of the TabbedPane....but the "i" and the "x" buttons are still scrunched up next to the label - rather than near the edges of the tab, where they would be expected.
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class TabExample extends javax.swing.JFrame {
    public TabExample() {
        initComponents();
     class TabRenderer extends JPanel {
          private JButton infoButton;
          private JLabel label;
          private JButton closeButton;
          public TabRenderer(String title) {
               infoButton = new JButton("i");
               label = new JLabel(title);
               closeButton = new JButton("x");
               setLayout(new GridBagLayout());
               GridBagConstraints gc = new GridBagConstraints();
               gc.gridy = 0;
               gc.gridx = 0;
               gc.anchor = GridBagConstraints.WEST;
               gc.fill = GridBagConstraints.NONE;
               gc.weightx = 0;
               this.add(infoButton, gc);
               gc.gridx = 1;
               gc.anchor = GridBagConstraints.WEST;
               gc.fill = GridBagConstraints.HORIZONTAL;
               gc.weightx = 1.0;
               this.add(label, gc);
               gc.gridx = 2;
               gc.anchor = GridBagConstraints.EAST;
               gc.fill = GridBagConstraints.NONE;
               gc.weightx = 0;
               this.add(closeButton, gc);
    private void initComponents() {
        tabbedPane = new javax.swing.JTabbedPane();
        jButton1 = new javax.swing.JButton();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
        jButton1.setText("Add Tab");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTabHandler(evt);
        getContentPane().add(jButton1, java.awt.BorderLayout.SOUTH);
        pack();
     private void addTabHandler(java.awt.event.ActionEvent evt) {
          int index = tabbedPane.getTabCount();
          tabbedPane.add(new JPanel(), index);
          tabbedPane.setTabComponentAt(index, new TabRenderer("Tab " + index));
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JFrame f = new TabExample();
                    f.setSize(400, 300);
                    f.setVisible(true);
    private javax.swing.JButton jButton1;
    private javax.swing.JTabbedPane tabbedPane;
}

Similar Messages

  • How to make Firefox open automatically a new, empty tab in each start, but keep last sessions?

    How to make Firefox open automatically a new, empty tab in each start? (keep last sessions as well) It will be good, because Firefox wont load the previous sessions last watched tab after start straight away, but keep my previous sessions tab as well in the browser.

    Hello,
    You can change your home page settings to open a blank tab:
    * Tools (or [[Image: New Fx Menu]]) > Options > General
    * Beside "Startup", change to "Show a blank tab"
    * See the article [[Startup, home page and download settings]] for more information
    To retrieve your previous browsing session, first make sure that you are not running in [[Private Browsing - Browse the web without saving information about the sites you visit|Private Browsing mode]]. When you start Firefox, to recover your previous session, you can go to:
    * History (or [[Image: New Fx Menu]] > History) > Restore Previous Session
    * Please see [[Restore previous session - Configure when Firefox shows your most recent tabs and windows]] for more information

  • How to make the title of screen dynamic in ABAP.

    Hi experts,
    I want to make the title of screen dynamic like:-
    --> i have an initial screen in which program takes some input files..and having a screen title as "INPUT FILE" with a read button.
    --> after clicking on read button it reads that file and shows on screen that exel file...here this screen title remains the same as "INPUT FILE" but i want it as "READ FILE". now this screen again having a button as write file.
    -- > Now after clicking on this write button this file gets write in to SAP system here i want my screen title as"WRITTEN FILE".
    Please help me and tell me the way to do it.
    Regards,
    Depque.

    Hi.
    Ypu should use a flag as soon as someone clic on the button, in order to keep a value.
    Then in PBO Module you should ask for the value of this flag
    if w_flag = abap_true ('X')
    set tittlebar number01.
    else.
    set titlebar number02.
    endif.
    Please let us to know if this could help you.
    Regards,
    Gabriela

  • How to make a webpage fill in the entire browser?

    Hello everyone im tring to make my website fill in the entire page and havent had much luck. If you click here http://elitelandscapingct.com/Home.html you can see what I mean. Is the only way to make it fill in the page to make the page width wider??? If thats the case do you guys have a recommened width number I should be around?

    iWeb pages are centered and have a fixed width, which you can change in the inspector.
    You have to take a lot of variables into account to decide what is the best width.
    Who will visit your pages and with what. From a 30" Desktop monitor to the iPhone/iPod touch and other brands of mobile phones, etc.
    Apple recommends a width of 980 pixels. Obviously with their products in mind.
    [Safari Reference Library |http://developer.apple.com/safari/library/navigation/index.html#section=Resour ceTypes&topic=CodingHow-Tos]
    I design my pages to fit a monitor of 1024 pixels wide. Then it also fits nicely when printed on A4 paper. An iWeb page of 980 pixles wide will fit all browsers on all PCs.
    Lately I've been designing webpages with only the iPad in mind :
    http://dailynews.webege.com/ipad/
    Keeps you busy to calculate the exact number of pixels.

  • How to make object in scrolling text reload entire page and not just iFrame?

    I have a section with pictures that are links to other pages. The problem is when an image is clicked the iFrame area loads the new page but the browser remains on the old page...?
    Here's the code im using:
    <div style="height:1959px;width:426px;color:#000000;font:14px/16px Verdana;overflow:auto;">
    <font color="000000"><strong>August 16, 2011 by TitsMgee</strong></font> <a href="http://www.tittymungus.com/*****_Mungus_2/Awkward_Moments_and_Models.html"><img src="http://www.tittymungus.com/images/banners/19.jpg" alt="" title="Awkward Moments Courtesey Victoria Secret" width="398" height="173" class="size-full wp-image-44" /></a><br><br>
    </div>

    Use a target:
    <a href="the url" target="_top"> or
    <a href="the url" target="_new"> or
    <a href="the url" target="_blank"> or
    <a href="the url" target="_self">
    To load in the present page or in an new page or in the same place.
    It's basic HTML. You can search for it.
    BTW since you already defined color in the DIV you need not use <font>.
    it's CSS, so you may want to search for that also.

  • How to make all Button component instances trigger rollOver sound?

    Hello all--
    I am using the Button component (the one shipped with CS3) in
    many places in my AS3 project. I am coding in .as files, not on the
    timeline.
    I have skinned the Button to use the colors I like. Now I
    wish to "skin" it so that all instances generate a rollOver sound,
    and I'll be darned if I can figure out how.
    I know I can listen for ROLL_OVER events in each Button
    instance. But I have many many Buttons and it seems kludgy to add
    that same code to every class I have which tracks a Button. I am
    hoping there is some way I can make *all* instances of Button
    respond to rollOver the same way. I am hoping it is like
    setComponentStyle or changing the skin for the Button; I can do it
    in one place and it works everywhere.
    I guess I can listen on the Stage level for bubble-ups of
    ROLL_OVER, trap those that come from Button instances, and handle
    it from there, but stagewide listeners also seem a tad kludgy.
    Is there some elegant way to make all my Buttons
    automagically generate the same rollOver sound?
    Many thanks,
    Matthew Ford

    It's regrettable there is no reply. But in case someone comes
    across this topic, FYI I put on my main View class (to which all
    other views and GUI are childed) an
    addEventListener(MouseEvent.MOUSE_OVER...). The MOUSE_OVER events
    bubble up to that.
    Then in the listener function I see if the event.target is
    Button. If it is, I trigger the sound.
    Curiously, the supposedly better ROLL_OVER event did not
    bubble up predictably. Sometimes it did and sometimes it did not.
    But the docs say that event is not supposed to bubble for some
    reason.
    I still think there is a better way and I'd like to hear it.
    Maybe I just need to make my own clone and adaptation of the
    Button, but I am not experienced yet with creating components
    (SWCs) and it appears that simply overriding the Button class with
    my own .as file does not work-- the rollOver functions report
    errors that they cannot be overridden.

  • How to make ADF Business Component Connection which is using XATransaction?

    Hi all,
    I'm using ORACLE 10.1.3 ADF business component, how to set this component using XA transaction? Is that possible to use xa transaction manually from application module?
    thanks

    I believe you mean to ask whether ADF BC uses XA Transaction.
    You can use a JDBC datasource based on XA Transaction for ADF BC. You might find this link useful for an overview: [XA Data Source Interface and Oracle Implementation|http://download-uk.oracle.com/docs/cd/B10501_01/java.920/a96654/xadistra.htm#1058741]
    What do you mean by "+Is that possible to use xa transaction manually from application module?+" - Do you mean exposing the transaction of ADF BC outside its AM..? If so, I'm afraid that its not supported.
    Thanks,
    ~Krithika

  • How to make a title randomly 'jumping around', not 'flowing'?

    I'd like to create my own 'watermark title'.
    Idea: the ©k.schluter slightly rotates a bit and randomly (done), and 'jumps' randomly across the screen.
    Apply a 'random generator' to the titles x/y position, makes it moving/flowing.
    What I want is an instant move to a new, random position.
    I miss a parameter - which one?
    Even better would be:
    that title isn't onscreen all time, just 'now&then, here&there'
    thanks in advance!

    I would absolutely love to have conditionals. Also, more access to different kinds of data, like: the bounding boxes of text areas, groups, current states of emitters (all of these have dynamic bounding rectangles.) In the link behavior, a switched alternative to scale: a mathematical function... would be OUTSTANDING (as long as it can be relinked by "chain" in other behaviors. Shouldn't be too difficult to manage -- works just like a spreadsheet; one of the oldest formula applications on computers. I personally would rather see any conditional/language-like instructions implemented as JavaScript and NOT BASIC (or: !BASIC), or even as ActionScript (basically a specialized JavaScript) was implemented in LiveMotion (Adobe, ca: 2000-2003).  I would like to have timers (setTimeout, setInvterval) that would not be interfered with by FCPX retiming and users stretching or collapsing effects in the storyline (an automatic Clip.stop() could be called at the end of the last visible frame in FCPX).
    As for node-based apps, all we really need is a way to integrate Quartz Composer projects/modules into Motion -- with links into and out of the Quartz project. That would be pretty cool too.
    There is, supposedly: FXPlug... but after 30+ years, I'm getting too old to learn another language (Objective C which looks just nasty to this old C programmer) and there is too little information (example code) online about developing plugins with it... at this time... for someone like me, that is. The last serious Mac Programming I did involved the "Toolbox" and "Quickdraw", and a 16/32-bit 68K Motorola microprocessor. By the time the G3's came out, I had pretty much moved over to web technologies (Java, JavaScript, PHP, etc.) Bottom line: I need more help than I can find and the people who are actually developing these things aren't sharing.

  • How to make a webdynpro component to be as a public part of a DC?

    Hi All,
         I've created 2 java web dynpro DCs : DC_A and DC_B in both the same software component.
         I want to a component of DC_B, let's call it Comp_B, to be the "Used Web Dynpro Component" of Comp_A in DC_A.
         I've done the following work:
         1. Expose the Comp_B to be the public part of DC_B
         2. Add DC_A to the Access List of Comp_B
         3. Add DC_B to the "Used DCs" list of DC_A
    But when I use the "Embed an existing component" function of Comp_A, I cannot find the Comp_B of DC_B.
    Anyone can help me?
    Thanks,
    YiNing

    Hi ,
       1) Right click the component B and declare the component B  of DC B to the public part.(Add to the public part)
       2) Now go to Component A , Right Click Used COmponents>Development Component>Show in--> Component Properties .
    then click the Dependicies Tab and click ADD
    here you have add the Component B  From the "MYComponents" Which is Exposed to the public part, and click next.(Configure dependicies as you wish ie Design Time .Deploy Time , Run Time )
    3) After you added the component we have to build it.Right Click the Componenet A
         Used Components>Development Component>Build
    4) Now declare the Component Usage
       Right Click the Componenet A
         Used Components-->Add Used Component
        Now give the Component Usage Name (for eg ComponentBInst) and select Component B
    Now Exchange of data will take place between the component by Context of the interface controller

  • How to make the PAP2 device take our configs as factory default

    Hy there
    I work to an ISP and i want to know how do i make an default configuration for our PAP2 devices.
    I want to make that config as factory default.
    thank you

    If you are referring to resetting the PAP2 back to factory defaults, then try this:
    http://www.sipura.com/Documents/faq/Section_3.html#4
    But if you mean using a tool to get the default settings, then I’m assuming you are in search for a provisioning tool mostly used by VoIP providers to configure the device.
    http://www.sipura.com/Documents/faq/Section_1.html#11
    I think this will also be applicable to the PAP2, but the problem here is you can’t get that tool too easily.

  • How to make a title of region as a link to another page?

    Hi there,
    I need to hyperlink a region title, so when I click in the title I will go to another page in the app without login agian, In other words keep the same session.
    Thanks,
    abdul
    Edited by: dtabed on May 12, 2009 1:40 PM

    Abdul
    The full link would be
    http://host:port/pls[if using mod_plsql handler]/f?p=&APP_ID.:&APP_PAGE_ID.[if to a specific page]:&APP_SESSION.Hope this helps
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • How to make JTabbedPane shown on bottom of window?

    hi.
    I want my JTabbedPane to be displayed on the bottom of the panel. Please suggest a method for JDK 1.3 , not 1.4
    thanx.

    see the api documentation (http://java.sun.com/apis.html)
    you could use constructor JTabbedPane(int tabPlacement) or later the method setTabPlacement(int tabPlacement)
    e.g.:
    JTabbedPane tab = new JTabbedPane(JTabbedPane.BOTTOM);

  • How to make panelHeader title to be in Red color.

    Hi,
    I have to show one of the three panelHeader Tititle to be in red color.
    I have already set the inline style as
    inlineStyle="color:Red;"
    But still it renders with the default color.
    Any pointers ??
    Thanks
    Sumit Yadav
    Edited by: Sumit Yadav on Aug 24, 2011 3:20 PM

    trinidad-config.xml should have
    <?xml version="1.0" encoding="windows-1252"?>
    <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
      <skin-family>dummySkin</skin-family> // this is your css name
    </trinidad-config>trinidad-skin.xml - you have to create this
    <?xml version="1.0" encoding="windows-1252" ?>
    <skins xmlns="http://myfaces.apache.org/trinidad/skin">
      <skin>
        <id>dummySkin.desktop</id> // note here
        <family>dummySkin</family> // note here
        <extends>blafplus-rich.desktop</extends>
        <render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
        <style-sheet-name>styles/dummyCSS.css</style-sheet-name> // note here
      </skin>
    </skins>css -file
    .MyCustomPanelHeader af|panelHeader{color: #006699;background-color:red;}

  • How to make 1 spry menu for the entire site? but not on each page

    i have a website that i wish to have multiple pages available all form the same menu and late and probably at regular intervals add more tabs to the menu
    is there a way to create a spry menu speratley that the page some how references, something like a frameset but without using framesets?
    im sort of new to webdesigning and unsure of the correct terminology, so i am finding it difficult to look up stuff that i don't know the name for, but will gladly go read someting if you point me in the right direction.
    regards
    for now
    wayne

    You can do this with PHP or ColdFusion
    These are "server side" scripting languages so you will have to test your website after you upload to you web hosting account.
    Or if you set up a local server. Without the local server you will get errors when you open them in firefox.
    To use the following what you do is "Cut" the part you want to be on all pages out, "Paste" it into a seperate document and in its place on your page you put one of the following suitable tags.
    You will also have to rename your main file to .php or .cfm as opposed to .html
    Again, whatever page you put one of these tags on, their extention must change match the type of tag used.
    First Method (PHP):
    PHP is the more common method -
    <?php @ require_once ("yourMenu.html"); ?>
    Require_once is basically a safeguard so that you don't add the menu twice onto a page.
    This will only work for PHP 4+
    This method would work for older versions of php too -
    <?php @ include("yourMenu.html"); ?>
    Second Method (ColdFusion):
    This will only work if your host has ColdFusion installled -
    <cfinclude template="bla.html">
    eg index.html
    <html>
    <head>
    <title>Stuff</title>
    <head>
    <body>
    <?php @ require_once("SpryMenu.html"); ?>
    </body>
    </html>
    SpryMenu.html
    <ul id="menubar1" class="MenuBarHorizontal">
        <li><a class="MenuBarItemSubmenu" href="#">Item 1</a>
            <ul>
                <li><a href="#">Item 1.1</a></li>
    </ul>

  • How to Make a Link Appear in Another Window/Tab

    I want to make a text link to another website that is not my
    site by appearing in another window or tab.

    On Fri, 14 Jul 2006 22:39:44 -0400, Alan > wrote:
    >select the text or image.
    >in the Property Inspector, type the full absolute
    address, including the
    >
    http:// part
    >
    >
    http://www.google.com
    >
    >then, in the property inspector, find the TARGET section.
    Set the target to
    >_blank and the link will open in a new window.
    >
    >The F1 help files cover this.
    I know that there are mixed views on whther this is a good
    idea.
    Fortunately - Firefox users have a new Tab appear rather than
    a whole
    window - which in my view is much better.
    I don't have a beta version of IE7 - does this do the same -
    that
    would be progress IMHO.
    MAlcolm
    Malcolm
    webmaster
    http://www.nb-president.org.uk/
    Nnew Edition of 'Steaming Up' now on-line

Maybe you are looking for