Regarding JTabbedPane

How can we arrange the different Tab buttons vertically as a list Some thing like
Tab1! !
Tab2! !
Tab3! !
Message was edited by:
EshaPrasad

Read the JTabbedPane API. There's a method that will do it.

Similar Messages

  • Strange Behaviour of JTabbedPane.Please Guide

    Folks
    I am getting a strange Error regarding JTabbedPane.
    In my main class,I am using :
    addTab
    ("One",
    null,
    new A(),
    "Test One");
    nothing happens.The contents of class A is not displayed.
    But when I say:
    addTab
    ("One",
    null,
    new A().call(),
    "Test One");
    the contents of Class A() is displayed..
    Why cant i use new A() DIRECTLY....
    Any idea on this?
    Class A(){
    // This does not work
    A(){
    new B();
    // This works..
    public void call(){
    return new B();
    Even in the constructor of A when I say 'return new B()'..this doesnt work
    Any one experienced this..

    Instantiating (making a new) B in the constructor of A is okay. But the new B must be added to the content pane of A for it to be displayed in A.
    import java.awt.*;
    import javax.swing.*;
    public class bhuru extends JFrame {
      public bhuru() {
        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.addTab("One", null, new A(), "new A()");
        tabbedPane.addTab("Two", null, new A().getB(), "new A().getB()");
        tabbedPane.addTab("Three", null, new B(), "new B()");
        tabbedPane.addTab("Four", null, new C(), "new C()");
        getContentPane().add(tabbedPane);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(400,300);
        setLocationRelativeTo(null);
        setVisible(true);
      public static void main(String[] args) {
        new bhuru();
    class A extends JPanel {
      public A() {
        new B();
      // void return type won't work here
      // you are returning an object of type B
      public B getB() {
        return new B();
    class B extends JPanel {
      public B() {
        setPreferredSize(new Dimension(250,175));
        setBackground(Color.red);
    class C extends JPanel {
      public C() {
        add(new B());
        setBackground(Color.blue);
    }

  • Most Bizarre JTabbedPane behaviour. Help Required!!!

    Folks
    I am getting a Bizarre behaviour regarding JTabbedPane.
    Here it is:
    I am using the addTab() method in my Main class:
    tabbedPane.addTab("One",
    null,
    new SCSCF(),
    "Testing One");
    Nothing is displayed on my Window!!!!!
    But when I say:
    tabbedPane.addTab("One",
    null,
    new SCSCF().show(),
    "Testing One");
    the concerned class details is displayed.
    public class SCSCF {
    public SCSCF(){
    new ScscfGui("Test");
    public Component show(){
    return new ScscfGui("Test");
    Can some please explain this as this is Urgent!!!
    I would like to use the first Option of calling the class directly!!!!!
    ie addTab(...
    new SCSCF(),
    Please can some one help!! Has any one understood my question!!!!

    Now what component is ur SCSCF() class?? Is it a JPanel or what?? Posting some code should help, perhaps...

  • Bizarre problem regd JTabbedPane.Please assist

    Hello there,
    I have a strange situation regarding JTABBEDPANE.
    I am writing this down:
    I have 4 classes.
    1) TabbedPaneDemo (The Main class,having pane options)
    2) SipProxyGui (having all the swing components,extends JPanel)
    3) ScscfGui (extends SipProxyGui)
    4) SCSCF
    When I use the following addTab function in TabbedPaneDemo,I get the correct output:
    tabbedPane.addTab
    ("Scscf",
    null,
    (Component)new ScscfGui("Test"),
    "Testing"
    Now,look at the following below.
    When I define a new class called SCSCF:
    public class SCSCF extends JPanel{
    public SCSCF(){
    new ScscfGui("Test");
    public static void main(String[] args){
    new SCSCF();
    and now say :
    tabbedPane.addTab
    ("Scscf",
    null,
    new SCSCF(),
    "Testing"
    THERE IS NOTHING DISPLAYED ON THE SCREEN!!!!!!!
    Shouldnt this also display the same output!!!!!!
    What is the problem??? Can any one explain!!!

    Join the club.
    I had an unfriendly Openreach engineer come to my property in January to get a line activated. He made me run around the flat myself to find a line, and 10 minutes after he arrived he just said that he can't install a line, they'd have to dig up the pavement and charge me for that.
    Fine I said, and phoned the same day to the provisions team to cancel the new application I made the 2 weeks prior. The lady I spoke to agreed to cancel everything and confirmed that there would be no charge.
    for the months of January till end of March I kept receiving bills and eventually a final demand for a new line installation and several months' line rental. Every time I phoned I spoke to a manager who promised me that the problem is resolved and they have now closed the account, however that never happened. 
    Then they passed the account to a collections agency who phoned me all hours of the day/night - one time they phoned 4 times in a row after 3am on a thursday morning until I picked up.
    Then I went and saw a solicitor, took all the documents etc and got them to write BT a letter and finally it all stopped. However, my credit score was affected by all of this and that I'm still trying to resolve...
    I swore I'd never return to BT but they're the only ones providing FTTC at the moment and Talk-talk got an Openreach engineer out recently who installed the line for me with no quibbles whatsoever.

  • Is JTabbedPane a stable component

    I've seen a several people reporting problems here regarding JTabbedPane.
    Is it a stable component I could consider using in a Swing Application or would I be better off designing a GUI that avoids it.
    I'm still using JDK 1.3 at present.
    Thanks.

    Its not at all difficult, I have used in many projects and have released them successfully and they are still doing great.
    Using JTree and table is little painful but tabbed pane doesnt poses a threat.
    - ananth
    I've seen a several people reporting problems here
    regarding JTabbedPane.
    Is it a stable component I could consider using in a
    Swing Application or would I be better off designing a
    GUI that avoids it.
    I'm still using JDK 1.3 at present.
    Thanks.

  • A few questions regarding BorderLayout, JTabbedPane and JFrame.

    Hello,
    I'm after a little help. I want to know the following:
    1)
    How to you add a gap on the far left and far right so that the components at PAGE_START and PAGE_END when using BorderLayout have visible borders. I have tried the Constructor which lets you specific hGap and vGap but this does not work, I assume it is only when butting components together.
    2)
    When using JTabbedPanes with option
    setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT );is there a way to control painting of the Scroller which scrolls through the tabs? I am currently using a custom UI (subclassing BasicTabbedPaneUI) to paint my tabs however I can not work out how to paint the Scroller.
    3)
    How to I add a custom JFrame Border and remove the blue XP border? Do I need to setUndectored and add my own Icons? I want to achieve something along the lines of what you can see here
    https://substance.dev.java.net/images/screenshots/themes/skins/business1.png
    I will be using a custom L&F although not Substance and currently my L&F does not paint the border/Decorations on the Frame.
    Here is a picture of my app, outlining my problems.
    http://img91.imageshack.us/my.php?image=exampletz1.jpg
    A nudge in the right direction on any of these would be great.
    Thanks

    Hello,
    I'm after a little help. I want to know the
    following:
    1)
    How to you add a gap on the far left and far right so
    that the components at PAGE_START and PAGE_END when
    using BorderLayout have visible borders. I have
    tried the Constructor which lets you specific hGap
    and vGap but this does not work, I assume it is only
    when butting components together. agree vgap and hgap increase the vertical and horizontal distances between objects added to the panel that uses border layout.
    Why not do setBorder(BorderFactory.createEmptyBorder(.....) to do this for you?

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

  • 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

  • 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

  • JTabbedPane with FormLayout problems

    I created form which contain JTabbedPane within JPanel with FormLayout. In the JTabbedPane, I put JPanel with FormLayout. In Design Mode, there is nothing problem, I can put whatever item into the JPanel of JTabbedPane. But in Runtime Mode, JTabbedPane display nothing, many items I've put on it are not displayed. But when I change the Layout into another like XY Layout or FlowLayout, items are displayed correctly.
    any idea to solve this?
    and why JDeveloper doesn't implement SpringLayout?

    Hi user567546, i faced the same problem.
    Fortunately, I solved it by using PanelBuilder instead of Panel,
    take a look at this example:
    http://www.java2s.com/Code/Java/Swing-Components/DemonstratesthebasicFormLayoutsizesconstantminimumpreferred.htm
    Regards,
    Luis R.

  • Positioning objects in a JTabbedPane

    Is the any way to specify the positioning of an object in a JTabbedPane?
    I am placing JPanels which contain JLabels and JTextFields into tabs
    of a JTabbedPane. All the panels are centered in the tab panes.
    This is annoying because one panel contains more labels and fields than
    the others. As result some of the data on the smaller panels isn't visible without scrolling.
    Is there some way to orient all panes NORTHWEST ? So when a user selects a tab the data is visible.
    It seems to me it would be done when adding the tabs (.addTab())
    but I can't figure out how.
    I tried grigBag.setConstraints(jtp, gridBagConstraints) where jtp
    is the tabbed pane. But it did not work.
    Is this just the way the JTabbedPane works ?
    TIA

    Looks to me like you are using FlowLayout - this is the default for JPanels. FlowLayout is a pain in the thingimybob. Try using a more suitable layout manager (e.g. BorderLayout).
    This applies both to to the container you're putting the JTabbedPane into, and the JPanels you're putting within the JTabbedPane.
    You can set the layout when you create a container, for example...
    JPanel panel = new JPanel(new BorderLayout() );
    JTabbedPane tabs = new JTabbedPane();
    panel.add(tabs, "Center");Hope this helps!
    Regards,
    Tim

  • JTabbedPane with subtabs?

    Hello.
    Do you know of any JTabbedPane-like swing component that supports subtabbing? Any open source or free one?
    Thanks and regards.
    Antonio.

    ecard104 wrote:
    can you tell me the method you want to say?I'd prefer to have you look at the API and the tutorial. It would be better for you in the long run. It's spelled out in the tutorial.
    [http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html]
    [http://java.sun.com/javase/6/docs/api/javax/swing/JTabbedPane.html]
    Edited by: Encephalopathic on Sep 1, 2008 10:17 AM

  • Problem of getting event in the jTabbedPane

    Hi,
    I have problem to do a jTextField.setText(), or jTextField.getText() from a jTabbedPane.
    I create a jTabbedPane and have 7 jPanel in it. For the fifth jPanel, all jTextField in there works normally, but for the 6th and 7th one, all jTextField in there doesn't work.
    When I call getText(), I can alwys get "", and when I call setText(), I cannot see any update in the jTextField, even I can know that the content is actually changed. However, I can still capture the event on this 6th and 7th panel.
    Thanks for help!
    Nachi

    There seem to be quite a lot of quotes in the example above.
    My guess is that it works in the manual login because the shell does concatenate some of the escape characters.
    In a Java program, you should not need that amount of escaping...
    Regards,
    Ludovic.

  • JTabbedPane and JScrollPane problem

    Hi all,
    I'm trying to make working JScrollPane into JTabbedPane. I have been trying several times to make it but with no acceptable effects :( I attached below the simple code to show what I'm interested in.
    PANEL1 has its dimension. I'd like to make that the JScrollPane will be active and enabled to roll when user change JFrame size to less than PANEL1 on pane1.
    Please help!
    Thanks for everyone,
    Greetings,
    import java.lang.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Sample     {
    static JFrame fr;
    static JPanel pane1, pane2, pane3;
    static JLabel AAA, BBB, CCC;
    static JPanel PANEL1;
    static JTabbedPane panel;
    public static void main(String args[])     {
              fr = new JFrame("Sample");
              pane1 = new JPanel();
              pane1.setLayout(null);
              pane2 = new JPanel();
              pane2.setLayout(null);
              pane3 = new JPanel();
              pane3.setLayout(null);
              panel = new JTabbedPane();
              Font myfont1 = new Font("SansSerif",0,20);
              Font myfont2 = new Font("SansSerif",0,15);
              Font myfont3 = new Font("SensSerif",1,15);
              AAA = new JLabel("AAA");
              BBB = new JLabel("BBB");
              CCC = new JLabel("CCC");
              AAA.setFont(myfont2);
              BBB.setFont(myfont2);
              CCC.setFont(myfont2);
              AAA.setBounds(20,20,300,20);
              BBB.setBounds(20,50,300,20);
              CCC.setBounds(20,80,300,20);
              PANEL1 = new JPanel();
              PANEL1.setLayout(null);
              PANEL1.setBackground(java.awt.Color.CYAN);
              PANEL1.setBounds(20,15,250,300);
              PANEL1.add(AAA);
              PANEL1.add(BBB);
              PANEL1.add(CCC);
              pane1.add(PANEL1);
              panel.insertTab("A", null, pane1, null, 0);
              panel.setSelectedIndex(0);
              panel.insertTab("B", null, pane2, null, 1);
              panel.setSelectedIndex(0);
              panel.insertTab("C", null, pane3, null, 2);
              panel.setSelectedIndex(0);
              panel.setBounds(0,0,550,450);
              fr.setLayout(null);
              //fr.setResizable(false);
              fr.setBackground(java.awt.Color.CYAN);
              fr.setForeground(java.awt.Color.CYAN);
              fr.add(panel);
              fr.pack();
              fr.setSize(550, 450);
              fr.setLocationRelativeTo(null);
              fr.setVisible(true);
    }

    Unfortunately no :( Besides, I can't understand at
    all this line:
    JTabbedPane (panel)TabbedPane = ... new
    w JTabbedPane(...).add/insertTab( ... new
    JScrollPane(new JPanel(...)) ... )It's to big cut-off like for me. Can you insert it
    into my Sample?
    Regards and thanks,It's only my "dev speak". Put a ";" and a var name (, ...) whereever needed, and remove some"()".
    (Sorry, normally I don't help dev beginners on so more complex problems, with just an easy answer.)

  • 24pt Font Size Tab Text for JTabbedPane

    I'm creating an app for use with Touchscreens and need to make the buttons and such, large enough to fit the tip of a finger.
    I'm having trouble with the JTabbedPane font size and am having trouble finding a way to make the text in the tab larger.
    Same issue with text in a border. Just for looks but would be nice.
    And the text in the window title.
    I've searched the forums and the tutorials but couldn't find anything. Thanks in advance for your assistance.
    Stone

    Hi,
    the text in the window's title is managed by the underlying OS. So, I guess there is no possibility to influence this text. Except you change the display properties of the OS on this computer that runs your app.
    Regards,
    Patrick

Maybe you are looking for