JTabbedPane new tab problem

I have a question regarding the TabbedPane, and forgive my ignorance as I've only just started. I am attempting to create a telnet/SSL application that allows you to open and close new tabs while the window's running, much like any tabbed web browser. I see there's a getTabCount() method, but it doesn't seem to work as I expected, or I'm using it incorrectly. Basically, each tab is supposed to have its own jTextArea to allow the user to connect to a remote host using a non-secure or secure method. The method that performs the action is below. If I put the "tabcount" int in the setTabComponentAt(), an index out of bounds error is returned in the stack trace and it appears to default to 0; if I put 0 in there as it is below, the stack trace goes away and the TabbedCommunicator class creates the tab with the close button. It just never seems to want to have more than one tab at a time. Any input is welcome and appreciated
private void performNewTab(java.awt.event.ActionEvent evt) {                              
        int tabcount = jTabbedPane1.getTabCount();
        tabcount++;
        String title = "untitled_" + tabcount;
        jTabbedPane1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        jTabbedPane1.addTab(title, jScrollPane3);
        jTabbedPane1.setTabComponentAt(0,new TabbedCommunicator(jTabbedPane1));
        jTabbedPane1.getAccessibleContext().setAccessibleName("");
        return;
    }

Before posting, I was aware of how the tab components are accessed. For whatever reason, I left out the "tabcount--;" that was there after the title for the tab. If I adjusted the code to not hard-code to 0, I still received the same stack trace error (ArrayIndexOutOfBounds) as I did before the tabcount--; was added. It's as if the tabbed pane itself can only hold one tab, and in order to have multiple tabs, you've got to have multiple tabbed panes. The setTabComponentAT() method is being used to create the closeable tab. That portion of the code works great when the application is first started, as well as when the tab is closed, then the File->New Tab menu is accessed. But if the closeable tab is still there and File->New Tab is accessed, it persists at creating only one tab, and that tab's closeable feature doesn't work..
The stack trace is:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 >= 1
at java.util.Vector.elementAt(Vector.java:427)
at javax.swing.JTabbedPane.getTabComponentAt(JTabbedPane.java:2363)
at javax.swing.JTabbedPane.setTabComponentAt(JTabbedPane.java:2340)
at clientgui.JavaCommunicationsGUI.performNewTab(JavaCommunicationsGUI.java:398)
at clientgui.JavaCommunicationsGUI.access$100(JavaCommunicationsGUI.java:41)
at clientgui.JavaCommunicationsGUI$2.actionPerformed(JavaCommunicationsGUI.java:296)

Similar Messages

  • Safari 5.0.3, open link in new tab problem

    I have a Mac 10.6.5.
    When I open safari it works fine, then if I right click on a link I see the options open in a new tab, or window (and many other options), when I click open link in a new tab it works, then in the new tab I have a problem: If I right click on a link I can't see anymore the option "open in a new tab", all I can see is, open link, open link in a new window, download linked file and copy link, if I click on open link in a new window it opens a blank tab :s.
    Also right click options are always limited in a new tab and, if I right click on a picture in the new tab I can't see the same options that are normally listed when I fist open a window.
    How can I fix it, is someone else having this problem?
    .

    Hi and welcome......
    Try troubleshooting the Safari .plist file.
    Quit Safari if it's open (Command + Q)
    Open a Finder window. Select your Home Folder in the Sidebar on the left. It has a small house icon. Then open the Library folder then the Preferences folder.
    Move the com.apple.Safari.plist file from the Preferences folder to the Desktop.
    Relaunch Safari. Now launch Safari. If Tabs work as they should, move that .plist file to the Trash.
    Carolyn

  • New Tab problems

    V. 21.0
    I have turned off the "New Tab Page" feature because i don't want all the history i just want my home page. How do i get each NEW TAB to only show my HomePage?

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Custom installed search engines are located in the searchplugins folder in the Firefox profile folder.
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    You can delete the search.json file and possible search-metadata.json and search.sqlite files in the Firefox profile folder to reset the search engines to the default.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox

  • Open link in a new tab problem.

    When I want to open a link to a new tab by pressing my mouse scroller, it just won't work. Anyone have any solution? It still works after I changed to Firefox 4 after a few days. But it didn't work now. :(

    Uninstall the Ask toolbar and it should work again. There is a compatibility issue with the Ask toolbar and Firefox that prevents new tabs from being opened.
    There are a couple of places to check for the Ask toolbar:
    * Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
    * Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons

  • Safari open link in new tab problem

    Safari opens links in same tab when it should open each link in a new tab.
    In preferences, tabs, Open pages in tabs instead of windows: if I select, Always
    When I browse, click on a link, the link opens in the page I am viewing and also a new tab.
    If I select never
    When I browse, click on a link, the page opens in the tab I am viewing and also a new tab (about 75% of the time).
    If I select automatically, Safari will selectively open the link in the same page and a new tab at the same time, or sometimes just open a new tab.
    What's up, Safari 6?
    How can I fix this annoying behavior?

    I pulled the plist to the trash, reset Safari, restarted. Everything seems to be working as it should. I'm guessing this was some sort of preference or cache corruption. If the weird behavior returns, I'll report back.

  • Auto new tab problem

    why auto open advertsing new tab while using firefox.

    What page opens if you open a new tab?
    You can check the <b>browser.newtab.url</b> pref on the <b>about:config</b> page and set that pref to your preferred new tab page.
    * the default new tab page with the tiles is <b>about:newtab</b>
    * the default home page is <b>about:home</b>
    * for a blank page you can use <b>about:blank</b>
    The browser.newtabpage.enabled pref should be set to true to use the page set via browser.newtab.url as the new tab page.
    You can open the <b>about:config</b> page via the location/address bar.
    You can accept the warning and click "I'll be careful" to continue.
    *http://kb.mozillazine.org/about:config
    See this article about the New Tab page (about:newtab):
    *https://support.mozilla.org/kb/new-tab-page-show-hide-and-customize-top-sites

  • I am having a problem adding a new tab, everyone is telling me to get rid of "ask toolbar" however I do NOT have ask, not at all. And yet I still can not find out what to do. Please help!

    Hello, I am having trouble opening a new tab on firefox. Everyone has told me to delete the "ask toolbar" but the thing is I do NOT have that, searched over and over and it is NOT on my firefox. Yet I still can not fix the new tab problem. Any help please?!

    Try this?
    * http://kb.mozillazine.org/Uninstalling_toolbars

  • Download file (PDF) and open on a new tab

    Hi All,
    Jdeveloper version: 11.1.2.1.0
    Use Case:
    When user press the command button, system should retrieve PDF document from the database (BLOB file) and display on a new tab
    Problem:
    Managed to retrieve the file, but it replaces the current page rather than opening a new tab
    I've tried few suggestions from below link, but still no luck:
    - How do I open a page in new window using af:commandLink?
    - https://kr.forums.oracle.com/forums/thread.jspa?threadID=637676
    My Code:
    ==============================================================
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    +// get an ADF attributevalue from the ADF page definitions+
    AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("DsgnFileData");
    if (attr == null)
    +{+
    return;
    +}+
    +// the value is a BlobDomain data type+
    BlobDomain blob = (BlobDomain) attr.getInputValue();
    try
    +{+
    ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
    HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
    ServletOutputStream out = response.getOutputStream();
    response.setHeader("Cache-Control", "max-age=0");
    response.setHeader("Content-Disposition", "inline; filename=Report.pdf");
    response.setContentType("application/pdf");
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    IOUtils.copy(blob.getInputStream(), byteArrayOutputStream);
    out.write(byteArrayOutputStream.toByteArray());
    out.flush();
    out.close();
    FacesContext.getCurrentInstance().responseComplete();
    +}+
    catch (IOException e)
    +{+
    +// handle errors+
    e.printStackTrace();
    FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), "");
    FacesContext.getCurrentInstance().addMessage(null, msg);
    +}+
    ==============================================================
    Has anyone managed to do this? Help please
    Thank you
    Regards,
    Andi

    response.setHeader("Content-Disposition", "inline; filename=Report.pdf");You must use "attachment" instead of "inline".
    Edit:
    Just noticed that you want to show document :)
    You can try to use something like this to call your servlet(and use "inline"):
    String script = "window.open('" + url + "', '_blank');
    ExtendedRenderKitService service = Service.getRenderKitService(FacesContext.getCurrentInstance(), ExtendedRenderKitService.class);
    service.addScript(FacesContext.getCurrentInstance(), script);
    {code}
    But you can't control browser behaviour, so if this will open in new tab or new window depends on browser settings.
    Dario.
    Edited by: kdario on Nov 7, 2012 11:51 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • When opening Firefox one of my homepages is often replaced by the new tab.

    For the last several versions of Firefox one of my two homepages on opening the browser is frequently replaced by a new tab; clicking on the home icon always opens the missing homepage (along with a second copy of the other one that is open), but this is now getting annoying. I was hoping an update would fix the problem, but of course this has not happened.
    The problem began several FF versions ago just about the same time I updated CCleaner, so I considered the possibility that the latter was deleting something that interferred with my FF tabs; after having uninstalled that version of CCleaner, however, and reinstalled the previous one - the use of which had never coincided with the tab problem - the continued issue with the new tab was clearly not due to CCleaner, so I could only assume that the problem was with FF itself. (Note: I had not installed any new plug-ins or extensions at the time the problem began.)
    Thanks.

    Hello All.
    I cannot be sure if it is related, or indeed is the cause of the problem with the new tab, but in the last couple of days it has become evident that Google has been modifying some pages, including the Gmail logon page.
    1) Yesterday I found that on the logon page the field for the password had gone; the username field was there with a blue button below it saying 'Next', which I had to use to bring up the password field;
    2) Today, after attempting to login to my e-mail, I was taken to a security checkup/update page for my account, which I completed - except for providing a 'recovery phone number' - but I was given no way of getting into my e-mail; if I logged out and in again I was again taken to the same security update page. Eventually, I went to a google support page via a search engine and saw a link for Gmail that took me straight into my e-mail - I was still logged in - and I replaced the Gmail address for my Firefox homepage again and now I can get into my e-mail. (Part of my problem here may have been that I refused to give a phone number; the form asked me to complete it by adding a number, which I would have to have verified so I could not fake it, i.e. 01234...)
    Given how long I have had the new tab problem - since at least FF32.0 - Google may not be the problem, but changes such as I have described do sometimes take some time and can clearly cause problems. Are any of you Gmail users?
    Ian.

  • JFrame.pack() causes problems with jtabbedpane(making new tabs)and resizing

    I have a JFrame with a JTabbedPane inside of it. Inside of each tab I put a JPanel with a JTextArea in it. When I create a new tab, I do something like textArea.requestFocusInWindow();
    However, this will not work unless I do a frame.pack() right after I created the new tab and right before that line of code.
    This in turn causes another problem. If I resize the jframe and then create a new tab, the window will snap back to the size it had before creating the tab. I assume this has to do with the pack() function, however nothing else I try will make the cursor blink in the JTextArea.
    Is there a solution to this...either something to make the cursor blink or something other than the pack function to update the JFrame?
    Thank you

    This posting should help you out:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=581478

  • JTabbedPane slow first new tab

    I have noticed something strange with my Swing user interface. I'm going to describe the symptoms and hopefully someone can help me narrow the problem to a bit of code that I can post. Currently, I have no idea about which part of my code may be causing the problem.
    I have a JTabbedPane with one tab that contains a JTable. This part of the GUI is displayed at start up. If a user opens a text file, the text is added to a JTextArea and then displayed in a new tab. The first time that I open a text file there is a noticeable delay before it is displayed. Every subsequent file that is opened is displayed very quickly in a new tab. Why would there be such a delay with the first new tab that is added but not the other?
    Thanks
    Message was edited by:
    Jstats

    Sounds like initialization is your enemy. You should use a profiler to check.

  • Problem with opening new tabs, when I right-click on a link and open in new tab it doesn't automatically load up like firefox 3.6 always did. Is there anyway to fix this?

    for example there's a link a friend sent me in my e-mail and I right-click on it, and select "Open in a new tab" it pops open like normal, except it does not load the page, I have to click the box and press enter to even get it to load it. In previous versions I have never had that problem, current version of Mozilla Firefox I am using is version 4, previous was 3.6 hope this helps figure this out.

    You can middle-click a link to open the link in a new tab.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • Tabs only open in a new window. Ctl T opens a new window NOT a new tab help-last update this problem started. How do I set FF back to open tabs in 1 window

    Tabs only open in a new window. Ctl T opens a new window NOT a new tab help-last update this problem started 2 days ago. How do I set FF back to open tabs in 1 window?
    There is no plus sign and going into optins and changing settings has not worked. I have uninstall FF and reinstall-keeping my personalization-and that was no help.
    Right clicking on FF Icon to open a new tab, or going up to FF drop down tab and clicking on new tab both do not work.
    Help everything opens a new window not a new tab. there seems to be no way to reset this or to chose a different optin. I just downloaded new tabs at end addon and it didn't do a thing.

    as a first troubleshooting step - does it work like normally when you open & run firefox in [[Safe Mode|safemode]] by pressing the shift key while you open firefox (all other instances have to be closed before)...

  • Add button to JTabbedPane to add new tab

    Does anyone know how to add a JButton to a JTabbed pane (in the tab bar) so that it is always at the end of all the tabs and when it is clicked it will add a new tab into the tabbed pane.
    The functionallity I am looking for is the same as that provided by the button in the tab bar for Firefox and Internet Explorer.

    Along the line of what TBM was saying:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class NewTabDemo implements Runnable
      JTabbedPane tabs;
      ChangeListener listener;
      int numTabs;
      public static void main(String[] args)
        SwingUtilities.invokeLater(new NewTabDemo());
      public void run()
        listener = new ChangeListener()
          public void stateChanged(ChangeEvent e)
            addNewTab();
        tabs = new JTabbedPane();
        tabs.add(new JPanel(), "Tab " + String.valueOf(numTabs), numTabs++);
        tabs.add(new JPanel(), "+", numTabs++);
        tabs.addChangeListener(listener);
        JFrame frame = new JFrame(this.getClass().getName());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(tabs, BorderLayout.CENTER);
        frame.pack();
        frame.setSize(new Dimension(400,200));
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      private void addNewTab()
        int index = numTabs-1;
        if (tabs.getSelectedIndex() == index)
          tabs.add(new JPanel(), "Tab " + String.valueOf(index), index);
          tabs.removeChangeListener(listener);
          tabs.setSelectedIndex(index);
          tabs.addChangeListener(listener);
          numTabs++;
    }

  • Problem adding a new tab to e-Recruiting

    Hi,
    I am facing the following problem in adding a new tab in the E-Recruitment (Manpower Requisition) application. The developer had created a new BSP page of the following information.
    Name space: SAP
    Application: ZHR_MPOWER_REQ
    Controller URL: MPR.DO
    A customized element (9001) had also been created with the above information.
    I have also created a context ZTEST and a Container Seq '1000' and under the Container Seq, I have allocated a few assignment of Element of which I have assigned the new element - 9001.
    Having assigned the above, I am still unable to see the new tab in the link. Please let me know if there are any missing steps.
    Thanks.

    Dear,
    Just want to check, r u able to Run the Custom BSP as a Standard alone application ?.
    Have you Configure T77RCF_APPl_LOG table ?.
    Alvin, i could not see why you could not see the BSP Page.
    Please got to t-code  SLG1 and check the log's why it's not coming.
    Could you please give more details, what you have done.
    Thanks & Regards
    Sabba Ravi

Maybe you are looking for