ArrayIndexOutOfBound in JTabbedPane

Hi all,
I am getting following bug when adding tab to JTabbedPane.
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
at javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.updateView(BasicTabbedPaneUI.java:3340)
at javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.stateChanged(BasicTabbedPaneUI.java:3323)
     at javax.swing.JViewport.fireStateChanged(JViewport.java:1384)
     at javax.swing.JViewport$ViewListener.componentResized(JViewport.java:1302)
     at java.awt.Component.processComponentEvent(Component.java:5867)
     at java.awt.Component.processEvent(Component.java:5821)
     at java.awt.Container.processEvent(Container.java:2058)
     at java.awt.Component.dispatchEventImpl(Component.java:4413)
     at java.awt.Container.dispatchEventImpl(Container.java:2116)
     at java.awt.Component.dispatchEvent(Component.java:4243)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Bug is not occuring every time. and I cannot reproduce it.
If anybody knows solution , please help me.
Thanks in advance

Bug is not occuring every time. and I cannot reproduce it.That shows a concurrency issue. Make sure to launch your GUI on the EDT using SwingUtilities#invokeLater.
The Java™ Tutorials: [Concurrency in Swing|http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html]
db

Similar Messages

  • 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)

  • How to Give MouseEvents for JTabbedPane??

    Hi All,
    I have some 10 tabs in a single JTabbedPane,So if i want to enlight the tab like when i just take my mouse cursor onto any tab it should have some effect/color changing,it should be higlighted in a different way compared to the other tabs.How can i implement this mechanism???
    Thanks in advance.
    regards,
    Viswanadh

    UIManager.put("TabbedPane.selected", Color.YELLOW );This will, however, affect all tabbed panes in your application.

  • Animated GIF in JTabbedPane - repaint madness!

    Loading and animated GIF into the icon for a JTabbedPAne just works, but it causes the paintComponent method on the main part of the panel to be called repeatedly. Anyway to distinguish between the two areas? The icon repaints automatically but I don't want to have to repaint the rest of the panel unnecessarily.

    I've run into the same problem simon, the only way I came over this was to do my own animation for the gif. Bit of a bother really. Anyone have any other solutions?

  • Mouse clicks not detected on JTabbedPane

    Hi all,
    I have a JPanel placed inside a JTabbedPane. I want to double-click on the JPanel and bring up a JDialog. This works fine if the JPanel is not in a JTabbedPane, but if it is on a JTabbedPane, then the mouse clicks are not detected. I'd greatly appreciate any help you can give me.

    Here is a sample program that seems to work:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class TestInternalFrame extends JFrame
         public TestInternalFrame()
              JDesktopPane desktop = new JDesktopPane();
              setContentPane( desktop );
              JInternalFrame internal = new JInternalFrame( "Internal Frame" );
              desktop.add( internal );
              internal.setLocation( 50, 50 );
              internal.setSize( 300, 300 );
              internal.setVisible( true );
              JTabbedPane tabbedPane = new JTabbedPane();
              internal.getContentPane().add(tabbedPane);
              tabbedPane.setPreferredSize( new Dimension(300, 200) );
              JPanel panel = new JPanel();
              tabbedPane.add( "Empty Panel", panel );
              panel.addMouseListener( new MouseAdapter()
                   public void mouseClicked(MouseEvent e)
                        System.out.println(e.getClickCount());
         public static void main(String args[])
    TestInternalFrame frame = new TestInternalFrame();
    frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    frame.setSize(400, 400);
    frame.setVisible(true);

  • How do I left justify the text in the tabs of a JTabbedPane.

    In 1.3.1 this used to work by supplying an HTML string with <div align="left"> but when I run with 1.4.1 this is now broken and I get center justification.
    Does anybody know a way to get the text in the tabs to be left justified.
    Thanks,
    Philip

    First, I found while using JTabbedPane that the "standard" behavior is to allow to a tab the exact space needed to display the tab text. Hence with this behavior, there is actualy no difference of "left" or "center" aligned text. So I assumed that you found a way or another to make your tabs wider than the "string width"...
    Here is a solution:
    You can override the TabbedPaneUI class and ajust the "layoutLabel()" method. Here is the code..
    //Your code using the tabbedPane
    JTabbedPane tp = new JTabbedPane();
    tp.setUI(new LeftTabbedPaneUI());
    //File containing the overrided TabbedPaneUI
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.text.View;
    class LeftTabbedPaneUI extends javax.swing.plaf.metal.MetalTabbedPaneUI {
            //I also overrided this function just to force tabs wider than
            //the displayed "String Width". I asume that you found another
            //way to do this so you can delete this function in your
            //implementation
         protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics){
              return 150;
        protected void layoutLabel(int tabPlacement,
                                   FontMetrics metrics, int tabIndex,
                                   String title, Icon icon,
                                   Rectangle tabRect, Rectangle iconRect,
                                   Rectangle textRect, boolean isSelected ) {
            textRect.x = textRect.y = iconRect.x = iconRect.y = 0;
         View v = getTextViewForTab(tabIndex);
         if (v != null) {
             tabPane.putClientProperty("html", v);
         //This Line is added to avoid writing on tab border while aligned to left.
         //You can comment this line to test and or adjust the "5" pixel space
         Rectangle rec = new Rectangle(tabRect.x+5,tabRect.y,tabRect.width,tabRect.height);
            SwingUtilities.layoutCompoundLabel((JComponent) tabPane,
                                               metrics, title, icon,
                                               SwingUtilities.CENTER,
                                               SwingUtilities.LEFT,
                                               SwingUtilities.CENTER,
                                               SwingUtilities.TRAILING,
                                               rec,
                                               iconRect,
                                               textRect,
                                               textIconGap);
         tabPane.putClientProperty("html", null);
         int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
         int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
         iconRect.x += xNudge;
         iconRect.y += yNudge;
         textRect.x += xNudge;
         textRect.y += yNudge;
    }Here I overrided the "Metal" implementation of the tab but you must override the implementation of the used Look And Feel,
    ex. "com.sun.java.swing.plaf.window.WindowsTabbedPaneUI" for the windows LAF.

  • How can I change the font of the titles in a JTabbedPane

    Hi
    I use a JTabbedPane in a project and use windows LookAndFeel.
    I want to distinguish the selected Tab titels by changing the font of the title. Is there anybody who can help me. I can not find any component used as the title. They are only there when I create the tabs with.
    myTabbedPan.addTab("aTitle",aPanel);
    How TabbedPan use the string "aTitle" to create Tab "Buttons". Is there a component or... I can not get it
    Thanks
    nan2000

    Unfortunately, you have to sub-class the WindowsTabbedPaneUI to do that, and override the convenient methods.
    After that, you have to specify to the UIManager this new class it have to use to display the JTabbedPane components.
    Denis

  • 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++;
    }

  • Urgent - How to add a new control instead of tabs in JTabbedPane

    Hi,
    Please give me an idea or a sample program for how to add a new control
    in JTabbedpane instead of tabs that means overlay any Java controls or pane
    in the tabpane empty place next to tabs

    "Urgent" is not relevant to the question. Your question is no more important than anybody elses.
    My answer in this posting show a limited solution:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=636289
    Otherwise I suggest you try using a layered pane approach:
    http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html

  • How to address a component in a background tab in a JTabbedPane

    Hello and greetings for everybody, this is my first post here. I have a question:
    I want to write a simple little chat program, which makes use of a JTabbedpane, and if the user gets a private message from another user, it would open a new tab with the given user's nick in the tab title, and would create a JTextArea on the opened tab and write the message to that specific JTextarea. My question: Is it possible to write on the JTextarea, while the given tab is in the background? How can I address that specific JTextarea on the specified tab?
    Thank you very much in advance for the answers, and I wis you all a nice day!

    // create a Map<String, JTextArea>
    public static void privMsg(String nick) {
            if (mainwindow.tabpane.indexOfTab(nick)==-1) {  // look for the nick in the map, not on the tabbedpane (if map.get(nick) != null
                javax.swing.JScrollPane panel=new javax.swing.JScrollPane();
                javax.swing.JTextArea msgBox=new javax.swing.JTextArea();
                msgBox.setEditable(false);
                msgBox.setAutoscrolls(true);
                msgBox.setLineWrap(true);
                panel.setViewportView(msgBox);
                mw.tabpane.addTab(nick,panel);
                mw.tabpane.setSelectedIndex(mw.tabpane.indexOfTab(nick));
                msgBox.append("Private conversation: "+nick+"\n");
                // add the nick and the msgBox to the map
            // if the nick already has been added to the map, (meaning there's already a tab open for that nick), then get that textpane and write to it. That's the basic idea behind MVC, which you'd do yourself a huge favor by reading into. You separate the display of the data from the data itself. That way when you update the data (Model), you don't have to deal with gui code (View). The actions the user takes are also separated into the Controller.

  • How can we prevent JTabbedPanes from transferring focus to components outside of the tabs during tab traversal?

    Hi,
    I noticed a strange focus traversal behavior of JTabbedPane.
    During tab traversal (when the user's intention is just to switch between tabs), the focus is transferred to a component outside of the tabs (if there is a component after/below the JTabbedPane component), if using Java 6. For example, if using the SSCCE below...
    import java.awt.BorderLayout;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    public class TabbedPaneTest extends JPanel {
        public TabbedPaneTest() {
            super(new BorderLayout());
            JTabbedPane tabbedPane = new JTabbedPane();
            tabbedPane.addTab("Tab 1", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
            tabbedPane.addTab("Tab 2", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
            tabbedPane.addTab("Tab 3", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);
            tabbedPane.addTab("Tab 4", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(tabbedPane);
            JButton button = new JButton("Dummy component that gains focus when switching tabs");
            panel.add(button, BorderLayout.SOUTH);
             * To replicate the focus traversal issue, please follow these steps -
             * 1) Run this program in Java 6; and then
             * 2) Click on a child component inside any tab; and then
             * 3) Click on any other tab (or use the mnemonic keys ALT + 1 to ALT 4).
            button.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    System.err.println("Gained focus (not supposed to when just switching tabs).");
            add(new JScrollPane(panel));
        private JPanel buildPanelWithChildComponents() {
            JPanel panel = new JPanel();
            BoxLayout boxlayout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
            panel.setLayout(boxlayout);
            panel.add(Box.createVerticalStrut(3));
            for (int i = 0; i < 4; i++) {
                panel.add(new JTextField(10));
                panel.add(Box.createVerticalStrut(3));
            return panel;
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("Test for Java 6");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.add(new TabbedPaneTest());
                    frame.pack();
                    frame.setVisible(true);
    ... Then we can replicate this behavior by following these steps:
    1) Run the program in Java 6; and then
    2) Click on a child component in any of the tabs; and then
    3) Click on any other tab (or use the mnemonic keys 'ALT + 1' to 'ALT + 4').
    At step 3 (upon selecting any other tab), the focus would go to the component below the JTabbedPane first (hence the printed message in the console), before actually going to the selected tab.
    This does not occur in Java 7, so I'm assuming it is a bug that is fixed. And I know that Oracle suggests that we should use Java 7 nowadays.
    The problem is: We need to stick to Java 6 for a certain application. So I'm looking for a way to fix this issue for all our JTabbedPane components while using Java 6.
    So, is there a way to prevent JTabbedPanes from passing the focus to components outside of the tabs during tab traversal (e.g. when users are just switching between tabs), in Java 6?
    Note: I've read the release notes between Java 6u45 to Java 7u15, but I was unable to find any changes related to the JTabbedPane component. So any pointers on this would be deeply appreciated.
    Regards,
    James

    Hi Kleopatra,
    Thanks for the reply.
    Please allow me to clarify first: Actually the problem is not that the child components (inside tabs) get focused before the selected tab. The problem is: the component outside of the tabs gets focused before the selected tab. For example, the JButton in the SSCCE posted above gets focused when users switch between tabs, despite the fact that the JButton is not a child component of the JTabbedPane.
    It is important for me to prevent this behavior because it causes a usability issue for forms with 'auto-scrolling' features.
    What I mean by 'auto-scrolling' here is: a feature where the form automatically scrolls down to show the current focused component (if the component is not already visible). This is a usability improvement for long forms with scroll bars (which saves the users' effort of manually scrolling down just to see the focused component).
    To see this feature in action, please run the SSCCE below, and keep pressing the 'Tab' key (the scroll pane will follow the focused component automatically):
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextField;
    import javax.swing.JViewport;
    import javax.swing.SwingUtilities;
    public class TabbedPaneAutoScrollTest extends JPanel {
        private AutoScrollFocusHandler autoScrollFocusHandler;
        public TabbedPaneAutoScrollTest() {
            super(new BorderLayout());
            autoScrollFocusHandler = new AutoScrollFocusHandler();
            JTabbedPane tabbedPane = new JTabbedPane();
            tabbedPane.addTab("Tab 1", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
            tabbedPane.addTab("Tab 2", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
            tabbedPane.addTab("Tab 3", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);
            tabbedPane.addTab("Tab 4", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(tabbedPane);
            JButton button = new JButton("Dummy component that gains focus when switching tabs");
            panel.add(button, BorderLayout.SOUTH);
             * To replicate the focus traversal issue, please follow these steps -
             * 1) Run this program in Java 6; and then
             * 2) Click on a child component inside any tab; and then
             * 3) Click on any other tab (or use the mnemonic keys ALT + 1 to ALT 4).
            button.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    System.err.println("Gained focus (not supposed to when just switching tabs).");
            button.addFocusListener(autoScrollFocusHandler);
            JScrollPane scrollPane = new JScrollPane(panel);
            add(scrollPane);
            autoScrollFocusHandler.setScrollPane(scrollPane);
        private JPanel buildPanelWithChildComponents(int numberOfChildComponents) {
            final JPanel panel = new JPanel(new GridBagLayout());
            final String labelPrefix = "Dummy Field ";
            final Insets labelInsets = new Insets(5, 5, 5, 5);
            final Insets textFieldInsets = new Insets(5, 0, 5, 0);
            final GridBagConstraints gridBagConstraints = new GridBagConstraints();
            JTextField textField;
            for (int i = 0; i < numberOfChildComponents; i++) {
                gridBagConstraints.insets = labelInsets;
                gridBagConstraints.gridx = 1;
                gridBagConstraints.gridy = i;
                panel.add(new JLabel(labelPrefix + (i + 1)), gridBagConstraints);
                gridBagConstraints.insets = textFieldInsets;
                gridBagConstraints.gridx = 2;
                textField = new JTextField(22);
                panel.add(textField, gridBagConstraints);
                textField.addFocusListener(autoScrollFocusHandler);
            return panel;
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("Test for Java 6 with auto-scrolling");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.add(new TabbedPaneAutoScrollTest());
                    frame.setSize(400, 300);
                    frame.setVisible(true);
    * Crude but simple example for auto-scrolling to focused components.
    * Note: We don't actually use FocusListeners for this feature,
    *       but this is short enough to demonstrate how it behaves.
    class AutoScrollFocusHandler extends FocusAdapter {
        private JViewport viewport;
        private JComponent view;
        public void setScrollPane(JScrollPane scrollPane) {
            viewport = scrollPane.getViewport();
            view = (JComponent) viewport.getView();
        @Override
        public void focusGained(FocusEvent event) {
            Component component = (Component) event.getSource();
            view.scrollRectToVisible(SwingUtilities.convertRectangle(component.getParent(),
                    component.getBounds(), view));
    Now, while the focus is still within the tab contents, try to switch to any other tab (e.g. by clicking on the tab headers, or by using the mnemonic keys 'ALT + 1' to 'ALT + 4')...
    ... then you'll notice the following usability issue:
    1) JRE 1.6 causes the focus to transfer to the JButton (which is outside of the tabs entirely) first; then
    2) In response to the JButton gaining focus, the 'auto-scrolling' feature scrolls down to the bottom of the form, to show the JButton. At this point, the tab headers are hidden from view since there are many child components; then
    3) JRE 1.6 transfers the focus to the tab contents; then
    4) The 'auto-scrolling' feature scrolls up to the selected tab's contents, but the tab header itself is still hidden from view (as a side effect of the behavior above); then
    5) Users are forced to manually scroll up to see the tab headers whenever they are just switching between tabs.
    In short, the tab headers will be hidden when users switch tabs, due to the Java 6 behavior posted above.
    That is why it is important for me to prevent the behavior in my first post above (so that it won't cause usability issues when we apply the 'auto-scrolling' feature to our forms).
    Best Regards,
    James

  • JTabbedPane: Components before and after the tabs themselves.

    I want to make Google Chrome..!
    Well, really, I want to have GUI stuff up in the title pane. In particular, I want the tabs of a TabbedPane up there.
    I've concluded that the easiest way to accomplish this (hopefully in a somewhat LaF-neutral way) is to set the frame to be undecorated, and instead implement my own frame with handling and all. I'd set a JFrame undecorated, and put a JTabbedPane over the entire thing, sticking the application icon to the left of the tabs, and the minimize, maximize, close buttons to the far right of the tabs themselves.
    If anyone have any other suggestions to this initial problem, I would seriously appreciate to hear about them.
    But given the above solution: How would I go about getting a component to the left of the tabs, and some other components to the right of the tabs, of a JTabbedPane? A LaF-neutral solution would be very much appreciated - but I have faint hopes here, so pointers for how to accomplish this using LaF-tricks will be appreciated too.
    I've seen that laf-widget from kirill, https://laf-widget.dev.java.net/, does something like it (the magnifying-glass icon to the left of the tabs) for several LaFs. However, I must admit that I'm not yet well enough versed to understand how he does it - and also it seems like a somewhat complicated process, whereby one "physically" change the LaF in question (bytecode manipulates it), injecting the laf-widget stuff (and I still don't know how the JTabbedPane or TabbedPaneUI is modulated to inject that icon).
    Any help or pointers will be much appreciated!
    Thanks,
    Endre.

    Could you elaborate slightly on that? I don't get your "what's left" idea..?
    I think the JTabbedPane should have this functionality built-in. It is a truly obvious need, to the extent that it has had to be solved several times by others.
    From an answer to this problem on StackOverflow: The JideTabbedPane from the Jide open source parts have an setTabLeadingComponent. However, Jide doesn't manage to follow the active LaF (the installs its own UI delegate), so I don't instantly want to jump on it.

  • Adding a new Tab to an existing JTabbedPane not working

    Hello all,
    I am trying to add & display a new tab to an existing JTabbedPane when the user
    clicks on a button. For some reason the new tab, being added is not being displayed, and I don't know why. I have called invalidate(), validate() on the parent containers but haven't had any luck. I have also played around with SwingUtilities.invokeLater() and the Event thread, but have been unsuccessfull.
    Any help would be greatly appreciated.
          * This class is the parent that holds the internalFrame which is the
          * main parent for all subsequent containers
         public class QuoteRequestGUI implements QuoteRequestGUI_IF {
              protected JInternalFrame internalFrame_newQuoteRequest = new JInternalFrame("Quote Request");
              protected JTabbedPane tabbedPane = new JTabbedPane();
               * Create a new internal frame to which all the components of a new
               * QR will be added
              public JInternalFrame createNewQuoteRequestFrame() {
                   // Add a tabbed pane to the internal frame
                   internalFrame_newQuoteRequest.add(createQuoteRequestTabbedPane());
                   // .... Set various internalFrame properties
                   return internalFrame_newQuoteRequest;
              public JTabbedPane createQuoteRequestTabbedPane() {
                   // Create a new quote request details instance
                   QuoteRequestDetailsGUI_IF quoteRequestDetailsGUI =
                        new QuoteRequestDetailsGUI(quoteRequestStatusPassed);
                   // Create a new tab that will host all details of the quote request     
                   tabbedPane.addTab("Quote Request Details",
                             quoteRequestDetailsGUI.createQuoteRequestDetailsPanel());
                   return tabbedPane;
         public class QuoteRequestDetailsGUI extends QuoteRequestGUI implements QuoteRequestDetailsGUI_IF {
              private ProductDetailsGUI_IF productDetailsGUI = new ProductDetailsGUI();
               * Panel that will act as a container for both quote request and buyer
               * details
              public JPanel createQuoteRequestDetailsPanel() {
                   // Panel that will contain quoteRequest, buyer and buttons
                   JPanel panel_quoteRequestDetails = new JPanel();
                   // Create an intermediate panel so that components can be layed out properly
                   JPanel panel_quoteRequestIntermediatePanel = new JPanel();
                   // Set layout manager for panel
                   panel_quoteRequestIntermediatePanel.setLayout(
                        new BoxLayout(panel_quoteRequestIntermediatePanel,BoxLayout.PAGE_AXIS));
                   // Add the buttons
                   panel_quoteRequestIntermediatePanel.add(createQuoteRequestDetailsButtons());
                   // Add the intermediate panel to the main panel
                   panel_quoteRequestDetails.add(panel_quoteRequestIntermediatePanel);
                   return panel_quoteRequestDetails;
               * Panel that will hold all the buttons for the quote request details tabbed panel
              public JPanel createQuoteRequestDetailsButtons() {
                   // Panel to act as a container for the buttons
                   JPanel panel_quoteRequestDetailsButtons = new JPanel();
                   // Create, register action listeners and add buttons to the panel
                   JButton button_saveTabbedPane = new JButton("Save");
                   button_saveTabbedPane.addActionListener(new ActionListener() {
                        public void actionPerformed (ActionEvent actionEvent) {
                               saveTabbedPaneListener();
                   panel_quoteRequestDetailsButtons.add(button_saveTabbedPane);
                   return panel_quoteRequestDetailsButtons;
               * Display the save (product details) tabbed pane
               * @todo - Implement the save tabbed pane selected method
              public void saveTabbedPaneListener() {
                        log.info("tab count before added : " + tabbedPane.getTabCount());
                        // The product details of a particular quote request
                        tabbedPane.addTab("Product Details",
                                  productDetailsGUI.createProductDetailsPanel());
                        log.info("tab count after added : " + tabbedPane.getTabCount());
                        tabbedPane.invalidate();
                        tabbedPane.validate();
                        internalFrame_newQuoteRequest.revalidate();
         public class ProductDetailsGUI implements ProductDetailsGUI_IF {
               * Panel that will act as a container for both the product details (incl
               * table) and the buttons
              public JPanel createProductDetailsPanel() {
                   // Main product details panel
                   JPanel panel_productDetails = new JPanel();
                   // Add the scroll pane to the panel
                   panel_productDetails.add(new JButton("ok"));
                   // Add the buttons to the panel
                   // Add the scroll pane to the panel
                   panel_productDetails.add(new JButton("cancel"));
                   return panel_productDetails;
         }

    MS,
    Try copying one existing TAB and use that, this happens only when there is improper xml content. You can open the xml in the browser/visual studio for better clarity and then try making the changes. Doing IIS Reset will be required but in the meanwhile you
    can put the original RCDC which will work till the time you make any change in new TAB.
    Regards,
    Manuj Khurana

  • Creating a dropdown for the tabs that use JTabbedPane

    Hi all,
    I have an application that uses a JTabbedPane to create tabs. Currently it uses the default to scroll if there are more tabs than what can be fit on the screen. I would also like to provide a dropdown next to the scroll arrows so that the user can see all the tabs on a dropdown list and select one w/o having to scroll left and right. I've seen this done on the NetBeans IDE 4.1 and 5.0. Is this something I can leverage from the Swing API (using JDK 5), grab from some open-source library, or must code myself? Let me know how I can do this. Thanks in advance!
    -los

    Thanks for the reply!
    I understand what you are describing but am a bit puzzled on a couple of things (maybe because I just got into Swing).
    My biggest question is on how to place the combo box in the tabbed pane next to the scrolling arrows. I'm looking at the JTabbedPane Javadoc and I do not see a place where one can add other components such as this combo box (other than the tabs themselves).
    Another question is that the combo box will have a width the size of the longest text contained in the box. How do I remove this length and just show the dropdown arrow. When the user clicks this arrow, the combo box appears with the list of items, i.e. I want to mimic what the NetBeans IDE does.
    Thanks in advanced!
    -los

  • Sender ADapter Monitor- ArrayIndexOutOfBOunds Exception

    Hi
    As me subject line reads,  I am getting an "ArrayIndeXOutofBOunds 9" exception at the sender adapter monitor logs in the RWB.
    I have an a<i>dapter monitor module</i> that picks up the file from the source  and pushes the file to a target directory based on some condition. I am able to see the file being pushed to the target directory but not able to view the "pipeline steps" in the message monitor.
    Do you think a restart of the server might fix the issue/ do you think there is a problem in my code. I have used just one array and i have checked that array if it is being accessed out of its bounds?
    Thanks
    krishna

    Hi,
    >>>>>ArrayIndeXOutofBOunds 9"
    looks like an error in code
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Maybe you are looking for

  • How to Slice Video, and Audio at same time

    Hello Everyone. When I click on Control K, it dose create a Slice in my Timeline, I want to create a Slice for my Audio as well,  at the same time. But every time I Slice a Video, and when I want to delete the Slice portion of the movie that I cut, t

  • Apple tv mirroring no button updates ok

    Apple tv mirroring missing

  • Sharepoint 2010 - Multiple line of text column with Plain text type

    Hi All, I have list where multiple lines of text with plain type column is used. When I start entering information in multiline text box in new form, I faced following problem, I typed enough information so that scroll bar is visible. When I stopped

  • Can check the scheduler is correct

    {BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'my_job1', job_type => 'PLSQL_BLOCK', job_action => ' DECLARE Type ty_tab1 is table of tb_fn%rowtype index by PLS_INTEGER; ltab1 ty_tab1; BEGIN DELETE FROM tb_snap; SELECT * BULK COLLECT into ltab1 FROM

  • ENterprise Manager SNMP Traps

    Hi all, I have configured the Database Control (not Grid Control) to send SNMP alert in our monitoring system. I have added notification rules per target (Instance, Cluster, Database, Host, ASM, Listener). For Each notification rule I have added the