Results 1 to 3 of 3
  1. #1
    blackstone is offline Member
    Join Date
    Nov 2007
    Posts
    6
    Rep Power
    0

    Default Adding Tabs to JTabbedPane

    Hello! I'm mildly new at Java. I've been using it for a little over a year now, but I just started learning the GUI stuff. I'm experimenting with JTabbedPane at the moment. I'm trying to add a new tab to my JTabbedPane if the user clicks a certain button. I have the tab adding perfectly fine, but my question is this: Is it possible for me to bring the tab to the front as soon as it is added? If there are several other tabs already in the pane, I want the new tab to show up in front immediately, without the user having to go and click on the tab.

    I was looking at the Java API and found quite a few methods pertaining to focus, but I didn't really understand it. Is this what I need to use? Or is there something else?

    Thank you in advance!
    Blackstone

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
    tabbedPane.addTab(tabName, component);
    int count = tabbedPane.getTabCount();
    tabbedPane.setSelectedIndex(count-1);

  3. #3
    blackstone is offline Member
    Join Date
    Nov 2007
    Posts
    6
    Rep Power
    0

Similar Threads

  1. Adding information to a JTable in a JTabbedPane
    By bigpappatrader in forum AWT / Swing
    Replies: 0
    Last Post: 12-05-2007, 07:09 AM
  2. help drag and drop in JTabbedPane
    By RO86 in forum AWT / Swing
    Replies: 0
    Last Post: 08-14-2007, 01:22 PM
  3. Help with JTabbedPane
    By lenny in forum SWT / JFace
    Replies: 1
    Last Post: 08-07-2007, 06:18 AM
  4. Same component on all JTabbedPane
    By java_novice in forum AWT / Swing
    Replies: 4
    Last Post: 08-06-2007, 09:09 AM
  5. resize tabs in jtabbedpane
    By osval in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 03:02 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
  •