What is tab component of the JTabbedPane?

Working with a JTabbedPane, if you cilck the tab it receives focus onto the text within the tab. Of course the tab itself receives focus, but if you click again, focus is transfered, as I said, onto the component containg the text.
I'd like to implement an action to this component, but cannot determine how to access it. Reading this unanswered thread shows someone else having a very similar problem. It is quite old, so I'm hoping someone has found a solution.
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=236766

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
public class TabbedPaneListener extends JFrame
     JTabbedPane tabbedPane;
     public TabbedPaneListener()
          tabbedPane = new JTabbedPane();
          getContentPane().add(tabbedPane);
          tabbedPane.addChangeListener(new ChangeListener()
               public void stateChanged(ChangeEvent e)
                    System.out.println(e.getSource());
          tabbedPane.addMouseListener(new MouseAdapter()
               public void mouseClicked(MouseEvent e)
                    TabbedPaneUI ui = tabbedPane.getUI();
                    int tab = ui.tabForCoordinate(tabbedPane, e.getX(), e.getY());
                    System.out.println("Clicked on tab: " + tab);
          newTab( "one" );
          newTab( "two" );
          newTab( "three" );
     private void newTab(String text)
          JPanel panel = new JPanel();
          panel.add( new JTextField(text) );
          tabbedPane.add( panel, text );
     public static void main(String args[])
        TabbedPaneListener frame = new TabbedPaneListener();
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setSize(300, 200);
        frame.setLocationRelativeTo( null );
        frame.setVisible(true);
}

Similar Messages

  • Listening to changes in tab selection on the JTabbedPane

    How can I to listen to any new selection in another tab of the JTabbedPane?
    supposed that I want the program to do a certain action each time the user select another tab with the mouse - and an action which is accordingly to the new selected index (of the new selected tab)...

    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTabbedPane.html#addChangeListener(javax.swing.event.ChangeListener)

  • Changing tabs order in the JTabbedPane (DnD)

    Hi,
    I have a JTabbePane with different tabs in it and I want to be able to drag one tab and insert between other two with the mouse. Kind of like you can reorder sheet tabs in MS Excel. Does any one have an idea how this behavior may be implemented?
    Thanks a lot,
    Ilya

    Thanks for this idea. I misunderstood what you meant until Jeremy responded saying you were �right on the money�. I thought you meant that putting another plot in the array but making it transparent was going to help somehow, but now I understand that you mean plotting the �up front� data to a separate XY graph indicator which is transparent and overlaying the original XY graph. I may wind-up doing this. I�m just not excited about linking all the scaling info from one graph to the scaling of the transparent graph and creating the necessary event handling so that when the user scales one graph or changes the auto-scaling, the other graph�s scales gets updated, but perhaps it�s the only way. Thanks again for your input.

  • How to hide/show a component of the JTabbedpane?

    Hi,
    I am working on a JTabbedPane, which hosts many jtables' panes. At some condition, some of panes should be hidden/shown under the user's action. How can I implement this? There is no such mothed to hide a pane instead of remove it.
    Thanks.

    add the panel to a holding panel set as a cardlayout
    (one side is the panel you 'may' want hidden, the other side a blank panel)
    add the holding panel to the tabbedPane
    if the panel is to be hidden (user action), show the blank panel

  • Moving the tabs to right of the jsf page in the adf panel tabbed component

    Hi,
    i want to move the tabs in the panel tabbed component to the right. In the property inspector of this component, it doesn't have an option called right. How can we do this?
    Thanks,
    sudan

    Hi,
    why there is no reply from the community? Does it mean, no one had any requirement like this before or it is not possible in ADF.
    Thanks,
    Sudan

  • Accessing Tab component in prerenderer

    I was trying to set the visibility of my Tab components based on current user roles.
    To my surprise I found out that for the first time the event executed all the tabs
    was not listed as a children of the tabset yet. TabSet getChildrenCount return 0.
    Everything went normal after the second and the subsequent call to prerenderer event.
    Is there any other event I can use to access my Tab component in the first time ? Any work around ? Or should I just hack my way through the JSP files like the old day ?

    I have the same problem. I dont know whether this is by design or it is a bug.
    For your information, the only stage when getChildren() returns the correct value is in the PageBean destroy method, by which time is it useless to do something meaningful with a component.

  • Putting an image in the JTabbedPane top margin .. is it possible ?

    Can I put an image in the top top margin of a JTabbedPane ?
    (I�m considering the top margin that one which contains the tabs selectors...)
    I�m not talking about drop images in the tabs, neither in the JTabbedPane components.. but in that top right empty space... on the right side of the tabs selectors....
    is it possible ?

    I woudln't see why not. You'll probably have to extend JTabbedPane and modify the paint(Grapics) method...

  • How to Fire an Event whenever clicking to Tab A, B, C on the JTabbedPane

    I have created a screen by using JTabbedPane having A,B,C Tabs on it. I need to fire one event whenever I will be clicking on Tab B or C or vice-versa. So that I can display some values from database automatically whenever I will choose Tab B or C.

    What's wrong with the events that are already fired when that happens? Add a ChangeListener to the JTabbedPane and it will receive a ChangeEvent every time a different tab is selected.

  • Firefox crashing when i wanna open or close a tab or a window, also while wanna open any page, now what to do for solving the problem?

    Firefox crashing when i wanna open or close a tab or a window, also while wanna open any page, now what to do for solving the problem?

    Disable McAfee siteadvisor and check the problem still persist or not?

  • I have 9 tabs, but when I try to make a tab group, only the current page shows up as a thumbnail, not all the tabs. I can't get them to work for me. All the tabs are listed on the right side of the tab groups box. What am I doing wrong?

    There's no thumbnails to drag around except one on the left side of the page (the one that's open). The right side of the page lists every tab I have created.

    Perhaps your problem is that '''you must save your browsing history''' in order to use app-tabs that would apply to groups as well but I did not test.
    * http://img232.imageshack.us/img232/4928/clearcachew.png
    I would suggest that if you do not save that stuff in bookmarks, that you will probably have a serious problem soon and lose your tabs, so if you count on them you could lose them. They should stand up to repeated restarts but I would not count of them as app-tabs myself, for one thing it is new, the other is I have to frequently wipe them out and restart, because I actively open new content into them and go back to the beginning of the tab history, and sometimes I can't, and sometimes I lose them by accidentally closing them -- and I must be able to close them in all manners that I close other tabs or I wouldn't be using them.
    There are people who keep 200 tabs open through restarting, that is not for me, I try to clear out the tabs frequently.
    That is what app-tabs are for as opposed to home pages, but I did have a problem when I tested with 120 since as app-tabs only about 65 can be seen at once even though I did reduce the width of app-tabs to about 2/3 the size that they were.. Problem I had when I restarted was that the window enlarged a bit beyond the screen, and my tab counter disappeared until I reduced the count to about 65. I do not allow tabs to scroll so you probably wouldn't have that problem.
    I forgot to test home page with 60 tabs. I do have something set to 75 though have to check that. I tested with 60 pages as home page. Brought firefox down and backup with the 1 app-tab and 60 home pages the app-tab is the same size as the 60 normal tabs from home page.
    Never used group-tabs by choice, since they messed me up I stay clear of them, I don't like them or anything large panoramic type of large thumbnails.

  • What HDMI to Component converter will work with the current generation Apple TV3?

    What HDMI to Component converter will work with the current generation Apple TV3?

    http://www.hdfury.com/products/hdfuryiii-specs/

  • Why isn't the selected tab title bold in JTabbedPane? How can I make it be?

    The selected tab title of JTabbedPanel is not bold. Is there a simple way to set it to be bold when a tab is selected? Thanks in advance.

    1. Simply use the HTML code in it's text like '<html><b>NameOfThisTab</b></html>'.
    2. Extend the JTabbedPane and fine-tune the font it uses.

  • Setting the tab text color in JTabbedPane

    How do I set the text color of tabs? I have to make the text color of one tab to blue and the other tab text color to red. Thanks.

    I tried giving the below but text color is the default it did not change. 'this' is the JTabbedPane. Any other suggessions? Thanks.
    this.setForegroundAt(0,Color.blue);
    this.setForegroundAt(1,Color.red);

  • The bookmark tab went from the right side to the left side. I did not change that. what cause the change from the right side to the left side?

    The bookmark tab went from the right side to the left side. I did not change that. what cause the change from the right side to the left side? Also the the Mozilla Firefox tab on the upper left hand corner changed.
    Its was a red colored tab and now its blue in color. I did not change any thing!

    Hey jimmiet,
    There were some recent ui changes around the downloads manager. What version where you on before? Anyway, you can customize things in Firefox really easily. Take a look at [[Customize Firefox controls, buttons and toolbars|this article on customizing Firefox]] for details. Should be a piece of cake to move the bookmarks button.
    As for the color of the button, you might be in [[Private Browsing - Browse the web without saving information about the sites you visit|Private Browsing]] mode. That changes the color of the button from orange to a purplish color.
    Matt

  • What does the field  "Version of the Reporting Component" in the table RSZC

    Hi Experts,
                       Was wondering if any of you have the answer to the following:
    The table RSZCOMPDIR stores details of the queries.
    Now the field "Version of the Reporting Component" in this table contains many different values viz. 0, 11, 13, 15, 100, 101, 102 etc.)
    However, am not sure if this field denotes the object type....for e.g. bot calculated & restricted key figues may have version 15 etc.
    So, in a nutshell, what does the field  "Version of the Reporting Component" in the table RSZCOMPDIR signify?
    Thanks,
    Bala

    I have not seen this done for CVI but I believe for all Microsoft functions such as this you would use ActiveX to call the Word, Excel, and possibly powerpoint ActiveX classes.
    Ian M.
    National Instruments

Maybe you are looking for

  • I accidentally updated to Firefox 4, but my computer is too old. How can I undo the download and get back to pre-Firefox 4?

    I had already removed the previous firefox icon from my computer, and after having replaced it in my applications folder, I discovered that it would not run on my computer.

  • White keyboard needs to toggle power every time computer is started

    I need to toggle power every time computer is started. OSX doesn't 'see' the keyboard when restarting or starting. ALSO When running XP in bootcamp, I can get XP to 'see' the keyboard, but I can't get it to work at all. Please help.

  • [ABAP-HR] FM to delimit Object in OM

    Hi Gurus, I have a request to delimit a custom infotype via report, I would like to know if there is a FM that would delimit OM infotypes. I have seen HR_INFOTYPE_OPERATION to delimit PA infotypes, is this applicable to OM infotypes? The initial requ

  • Wait time by objects

    Hello, I need to fetch a listing of objects having highest wait time caused by holding sessions which have locked them and also others waiting sessions are waiting for these holding session to release locks on these objects. To put simply 1) List of

  • My Flash 8 crashes!

    Hello, Errr... Since yesterday my Macromadia Flash 8 doesn't want to start... And I really don't know why. It crashes when the "white-red Flash 8 window" is loading. Precisely at the Initialising Fonts... Damn, I repaired it, I uninstalled and reinst