Java Code Examples for javax.swing.JTabbedPane

The following examples show how to use javax.swing.JTabbedPane. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
void updateTabName(String name) {
  if (DEBUG) {
    System.out.println(">>>>>" + name + "  " + MainPanel.getTabbIndex(this));
    StackTraceElement[] s = new Throwable().getStackTrace();
    System.out.println("  .(" + s[1].getFileName() + ":" + s[1].getLineNumber() + ") ");
    System.out.println("  .(" + s[2].getFileName() + ":" + s[2].getLineNumber() + ") ");
  }
  Container tabb = getParent();
  while (!(tabb instanceof JTabbedPane)) {
    tabb = tabb.getParent();
  }

  JTabbedPane tabbedPane = (JTabbedPane) tabb;
  int index = MainPanel.getTabbIndex(this);
  tabbedPane.setTitleAt(index, name);
  // tabUI = new TabUI(name);
  // tabbedPane.setTabComponentAt(index, tabUI);
}
 
Example 2
Source Project: bigtable-sql   Source File: UIFactory.java    License: Apache License 2.0 6 votes vote down vote up
public JTabbedPane createTabbedPane(int tabPlacement, boolean dndTabbedPane)
{
	JTabbedPane pnl;

     if (dndTabbedPane)
     {
        pnl = new DnDSquirrelTabbedPane(_prefs, _app);
     }
     else
     {
        pnl = new SquirrelTabbedPane(_prefs, _app);
     }

     pnl.setTabPlacement(tabPlacement);
	fireTabbedPaneCreated(pnl);

	return pnl;
}
 
Example 3
public OutlookBarMain() throws Exception {
  setLayout(new BorderLayout());

  JTabbedPane tabs = new JTabbedPane();

  { // the metal look and feel
    UIManager
      .setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    LookAndFeelAddons.setAddon(MetalLookAndFeelAddons.class);
    tabs.addTab("Metal L&F", makeOutlookPanel(SwingConstants.CENTER));
  }

  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

  { // the windows look and feel
    LookAndFeelAddons.setAddon(WindowsLookAndFeelAddons.class);
    tabs.addTab("Windows L&F", makeOutlookPanel(SwingConstants.LEFT));
  }

  add("Center", tabs);
}
 
Example 4
/**
 * Initializes the widgets.
 */
@Override
protected void initGUI() {
	super.initGUI();

	setLayout(new BorderLayout());

	m_TabbedPane = new JTabbedPane();
	add(m_TabbedPane, BorderLayout.CENTER);

	m_TextCode = new JTextArea();
	m_TextCode.setFont(GUIHelper.getMonospacedFont());
	m_TabbedPane.addTab("Write", new BaseScrollPane(m_TextCode));

	m_PanePreview = new JEditorPane();
	m_PanePreview.setEditable(false);
	m_PanePreview.setContentType("text/html");
	m_TabbedPane.addTab("Preview", new BaseScrollPane(m_PanePreview));

	m_TabbedPane.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			update();
		}
	});
}
 
Example 5
Source Project: iBioSim   Source File: CloseTabPaneUI.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void componentAdded(ContainerEvent e) {
	JTabbedPane tp = (JTabbedPane) e.getContainer();
	Component child = e.getChild();
	if (child instanceof UIResource) {
		return;
	}
	int index = tp.indexOfComponent(child);
	String title = tp.getTitleAt(index);
	boolean isHTML = BasicHTML.isHTMLString(title);
	if (isHTML) {
		if (htmlViews == null) { // Initialize vector
			htmlViews = createHTMLVector();
		}
		else { // Vector already exists
			View v = BasicHTML.createHTMLView(tp, title);
			htmlViews.insertElementAt(v, index);
		}
	}
	else { // Not HTML
		if (htmlViews != null) { // Add placeholder
			htmlViews.insertElementAt(null, index);
		} // else nada!
	}
}
 
Example 6
public void initializeComponents() {
	channelBox = new JCheckBox("Filter by channel", false);
	
	allSets = new SettingsPanel(r);
	rSets = new SettingsPanel(r);
	gSets = new SettingsPanel(r);
	bSets = new SettingsPanel(r);
	
	channelPane = new JTabbedPane();
	channelPane.add("Red", rSets);
	channelPane.add("Green", gSets);
	channelPane.addTab("Blue", bSets);
	
	cardPanel = new JPanel(new CardLayout());
	cardPanel.add(allSets, "all");
	cardPanel.add(channelPane, "rgb");
}
 
Example 7
Source Project: netbeans   Source File: CollapsiblePanel.java    License: Apache License 2.0 6 votes vote down vote up
public HookPanel(VCSCommitPanel master, Collection<? extends VCSHook> hooks, VCSHookContext hookContext) {            
    super(master, (hooks.size() == 1)
            ? hooks.iterator().next().getDisplayName()
            : getMessage("LBL_Advanced"), //NOI18N
            DEFAULT_DISPLAY_HOOKS);
    this.hooks = hooks;
    this.hookContext = hookContext;
    
    // need this to happen in addNotify() - depends on how 
    // repositoryComboSupport in hook.createComponents works for bugzilla|jira
    if (hooks.size() == 1) {                
        JPanel p = hooks.iterator().next().createComponent(hookContext);
        if (Boolean.TRUE.equals(p.getClientProperty("prop.requestOpened"))) { //NOI18N - some hook panels may want to be opened (hg queue hook with previously configured setts)
            super.displaySection();
        }
        sectionPanel.add(p);
    } else {
        JTabbedPane hooksTabbedPane = new JTabbedPane();
        for (VCSHook hook : hooks) {
            hooksTabbedPane.add(hook.createComponent(hookContext), hook.getDisplayName().replaceAll("\\&", ""));
        }
        sectionPanel.add(hooksTabbedPane);
    }
}
 
Example 8
Source Project: jdk8u-jdk   Source File: Test7024235.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void run() {
    if (this.pane == null) {
        this.pane = new JTabbedPane();
        this.pane.addTab("1", new Container());
        this.pane.addTab("2", new JButton());
        this.pane.addTab("3", new JCheckBox());

        JFrame frame = new JFrame();
        frame.add(BorderLayout.WEST, this.pane);
        frame.pack();
        frame.setVisible(true);

        test("first");
    }
    else {
        test("second");
        if (this.passed || AUTO) { // do not close a frame for manual review
            SwingUtilities.getWindowAncestor(this.pane).dispose();
        }
        this.pane = null;
    }
}
 
Example 9
Source Project: ramus   Source File: Tab.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * This is the default constructor
 */
public Tab(final Function function, final JTabbedPane pane) {
    super();
    this.pane = pane;
    panel = new JPanel(new BorderLayout());
    // this.setLayout(new BorderLayout());
    setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    setOpaque(false);

    label = new JLabel();
    setFunction(function);
    this.add(label);
    this.add(getJButton());
    // this.add(getJLabel(), BorderLayout.CENTER);
    // this.add(getJButton(), BorderLayout.EAST);
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    // setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
Example 10
Source Project: pega-tracerviewer   Source File: TracerSimpleReportFrame.java    License: Apache License 2.0 6 votes vote down vote up
private void addTab(String tabText, JPanel panel, int tabIndex) {

        JTabbedPane tracerReportTabbedPane = getTracerReportTabbedPane();

        JLabel tabLabel = new JLabel(tabText);
        Font labelFont = tabLabel.getFont();
        Font tabFont = labelFont.deriveFont(Font.BOLD, 12);
        Dimension dim = new Dimension(140, 26);
        tabLabel.setFont(tabFont);
        tabLabel.setSize(dim);
        tabLabel.setPreferredSize(dim);
        tabLabel.setHorizontalAlignment(SwingConstants.CENTER);

        tracerReportTabbedPane.addTab(tabText, panel);
        tracerReportTabbedPane.setTabComponentAt(tabIndex, tabLabel);
    }
 
Example 11
Source Project: egdownloader   Source File: TaskTagsPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setViewportView(Component view) {
	if(view == textPane){
		if(this.getParent() instanceof JTabbedPane){
			if(showMyFav){
				mainWindow.infoTabbedPane.setTitleAt(mainWindow.infoTabbedPane.indexOfComponent(this), "<html><font color='red'>我收藏的标签</a></html>");
			}else{
				mainWindow.infoTabbedPane.setTitleAt(mainWindow.infoTabbedPane.indexOfComponent(this), "标签组");
			}
		}
	}else if(view == confirmPanel){
		if(this.getParent() instanceof JTabbedPane){
			mainWindow.infoTabbedPane.setTitleAt(mainWindow.infoTabbedPane.indexOfComponent(this), "标签操作");
		}
	}
	super.setViewportView(view);
}
 
Example 12
Source Project: Bytecoder   Source File: MultiTabbedPaneUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int tabForCoordinate(JTabbedPane a, int b, int c) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c);
    }
    return returnValue;
}
 
Example 13
Source Project: marathonv5   Source File: JTabbedPaneJavaElement.java    License: Apache License 2.0 5 votes vote down vote up
private int findTabIndex(JTabbedPane tp, String tab) {
    int tabCount = tp.getTabCount();
    int tabIndex = -1;
    for (int index = 0; index < tabCount; index++) {
        String current = JTabbedPaneTabJavaElement.getText(tp, index);
        if (tab.equals(current)) {
            tabIndex = index;
            break;
        }
    }
    return tabIndex;
}
 
Example 14
/**
 * Maps {@code JTabbedPane.getForegroundAt(int)} through queue
 */
public Color getForegroundAt(final int i) {
    return (runMapping(new MapAction<Color>("getForegroundAt") {
        @Override
        public Color map() {
            return ((JTabbedPane) getSource()).getForegroundAt(i);
        }
    }));
}
 
Example 15
Source Project: CQL   Source File: AqlViewer.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static JComponent view(String k, Semantics s, int maxrows, Exp<?> exp, AqlEnv env, boolean showAtts) {
	JTabbedPane ret = new JTabbedPane();
	new AqlViewer(maxrows, env, showAtts).visit(k, ret, s);
	String l = "Compute time: " + env.performance.get(k) + " s.\n\nSize: " + s.size();
	if (s.size() < 1024) {
		ret.addTab("Text", new CodeTextPanel("", s.toString()));
	} else {
		ret.addTab("Text", new CodeTextPanel("", "Suppressed, size " + s.size() + "."));
	}
	
	ret.addTab("Expression", new CodeTextPanel("", l + "\n\n" + exp.toString()));
	// System.out.println(exp.getClass() + " " + env.performance.get(k));
	return ret;
}
 
Example 16
Source Project: CQL   Source File: AqlViewer.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("hiding")
@Override
public <Ty, En, Sym, Fk, Att> Unit visit(String k, JTabbedPane ret, Schema<Ty, En, Sym, Fk, Att> S) {
	ret.addTab("Graph", viewSchema(S));
	// ret.add("Graph2", viewSchemaAlt(S));
	ret.addTab("DP", viewDP(S.dp(), x->S.collage(), S.typeSide.js));
	// ret.add(new CodeTextPanel("", schema.collage().toString()), "Temp");
	ret.add("Acyclic?", acyclicPanel(S));
	return Unit.unit;
}
 
Example 17
Source Project: EchoSim   Source File: MainPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void initLayout()
{
    JTabbedPane tabs = new JTabbedPane();
    tabs.add("App", mApp);
    tabs.add("Tester", mTester);
    tabs.add("Script", mAutoScript);
    tabs.add("Suite", mTestSuite);
    tabs.add("Manual", mManScript);
    tabs.add("Natural", mNatural);
    setLayout(new BorderLayout());
    add("Center", tabs);
}
 
Example 18
Source Project: netbeans   Source File: DiffViewModeSwitcher.java    License: Apache License 2.0 5 votes vote down vote up
public void setupMode (DiffController view) {
    JTabbedPane tabPane = findTabbedPane(view.getJComponent());
    if (tabPane != null) {
        if (!handledViews.containsKey(tabPane)) {
            ChangeListener list = WeakListeners.change(this, tabPane);
            handledViews.put(tabPane, list);
            tabPane.addChangeListener(list);
        }
        if (tabPane.getTabCount() > diffViewMode) {
            tabPane.setSelectedIndex(diffViewMode);
        }
    }
}
 
Example 19
Source Project: TencentKona-8   Source File: Test4234761.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
Example 20
Source Project: attic-polygene-java   Source File: GraphPane.java    License: Apache License 2.0 5 votes vote down vote up
public GraphPane()
{
    treeDisplay = new TreeGraphDisplay();
    stackedDisplay = new StackedGraphDisplay();

    List<GraphDisplay> tmpList = new ArrayList<>( 2 );
    tmpList.add( treeDisplay );
    tmpList.add( stackedDisplay );
    displays = Collections.unmodifiableList( tmpList );

    scrollPane = new JScrollPane();
    scrollPane.setViewportView( stackedDisplay );
    int unitInc = 50;
    scrollPane.getVerticalScrollBar().setUnitIncrement( unitInc );
    scrollPane.getHorizontalScrollBar().setUnitIncrement( unitInc );

    tabPane = new JTabbedPane();
    tabPane.add( "Tree", treeDisplay );
    tabPane.add( "Stacked", scrollPane );

    this.setLayout( new BorderLayout() );
    add( tabPane, BorderLayout.CENTER );

    treeDisplay.addLinkListener( this::graphItemLinkActivated );

    stackedDisplay.addLinkListener( this::graphItemLinkActivated );

    this.addComponentListener( new ComponentAdapter()
    {
        @Override
        public void componentResized( ComponentEvent evt )
        {
            Dimension size = GraphPane.this.getSize();
            treeDisplay.setSize( size.width, size.height );
            tabPane.revalidate();
            tabPane.repaint();
        }
    } );
}
 
Example 21
/**
 * Maps {@code JTabbedPane.setDisabledIconAt(int, Icon)} through queue
 */
public void setDisabledIconAt(final int i, final Icon icon) {
    runMapping(new MapVoidAction("setDisabledIconAt") {
        @Override
        public void map() {
            ((JTabbedPane) getSource()).setDisabledIconAt(i, icon);
        }
    });
}
 
Example 22
Source Project: tn5250j   Source File: ButtonTabComponent.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ButtonTabComponent(final JTabbedPane pane) {
	super(new BorderLayout(0, 0));
	if (pane == null) {
		throw new NullPointerException("TabbedPane is null");
	}
	this.pane = pane;
	setOpaque(false);

	this.label = new TabLabel(); // {
	label.setHorizontalAlignment(SwingConstants.CENTER);
	label.setVerticalAlignment(SwingConstants.CENTER);
	add(label, BorderLayout.CENTER);
	// add more space between the label and the button
	label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
	// tab button
	JButton button = new TabButton();
	button.setHorizontalAlignment(SwingConstants.TRAILING);
	add(button, BorderLayout.EAST);
	// add more space to the top of the component
	setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));

	pane.addPropertyChangeListener(new PropertyChangeListener() {
		// triggers repaint, so size is recalculated, when title text changes
		@Override
		public void propertyChange(PropertyChangeEvent evt) {
			if ("indexForTitle".equals(evt.getPropertyName())) {
				label.revalidate();
				label.repaint();
			}
		}
	});
}
 
Example 23
Source Project: marathonv5   Source File: RTabbedPaneTest.java    License: Apache License 2.0 5 votes vote down vote up
protected Point getTabClickPoint(final JTabbedPane tp, final int tabIndex) {
    final Point[] ps = new Point[] { null };
    siw(new Runnable() {
        @Override
        public void run() {
            Rectangle boundsAt = tp.getBoundsAt(tabIndex);
            ps[0] = new Point(boundsAt.x + boundsAt.width / 2, boundsAt.y + boundsAt.height / 2);
        }
    });
    Point p = ps[0];
    return p;
}
 
Example 24
Source Project: swift-k   Source File: MSynthPainter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void paintTabbedPaneTabBorder(SynthContext context, Graphics g, int x, int y, int w, int h, int tabIndex) {
    JTabbedPane t = (JTabbedPane) context.getComponent();
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (t.getSelectedIndex() == tabIndex) {
        g.setColor(ACCENT);
        g.fillRoundRect(x, y, w - 2, 5, 5, 5);
        g.setColor(BG);
        g.fillRect(x, y + 2, w - 2, 4);
    }
}
 
Example 25
private JPanel createQueryDetailsPanel() {
  final JPanel queryNamePanel = new JPanel( new BorderLayout() );
  queryNamePanel.setBorder( BorderFactory.createEmptyBorder( 8, 8, 0, 8 ) );
  queryNamePanel.add( new JLabel( Messages.getString( "JdbcDataSourceDialog.QueryStringLabel" ) ), BorderLayout.NORTH );
  queryNamePanel.add( queryNameTextField, BorderLayout.SOUTH );

  final InvokeQueryDesignerAction queryDesignerAction = new InvokeQueryDesignerAction();
  dialogModel.addPropertyChangeListener( queryDesignerAction );

  final JPanel queryButtonsPanel = new JPanel( new FlowLayout( FlowLayout.RIGHT, 5, 5 ) );
  queryButtonsPanel.add( new BorderlessButton( queryDesignerAction ) );

  final JPanel queryControlsPanel = new JPanel( new BorderLayout() );
  queryControlsPanel.add( new JLabel( Messages.getString( "JdbcDataSourceDialog.QueryDetailsLabel" ) ), BorderLayout.WEST );
  queryControlsPanel.add( queryButtonsPanel, BorderLayout.EAST );

  final JPanel queryPanel = new JPanel( new BorderLayout() );
  queryPanel.add( queryControlsPanel, BorderLayout.NORTH );
  queryPanel.add( new RTextScrollPane( 500, 300, queryTextArea, true ), BorderLayout.CENTER );
  queryPanel.setBorder( BorderFactory.createEmptyBorder( 8, 8, 0, 8 ) );

  final JTabbedPane queryScriptTabPane = new JTabbedPane();
  queryScriptTabPane.addTab( Messages.getString( "JdbcDataSourceDialog.StaticQuery" ), queryPanel );
  queryScriptTabPane.addTab( Messages.getString( "JdbcDataSourceDialog.QueryScripting" ), createQueryScriptTab() );

  // Create the query details panel
  final JPanel queryDetailsPanel = new JPanel( new BorderLayout() );
  queryDetailsPanel.add( BorderLayout.NORTH, queryNamePanel );
  queryDetailsPanel.add( BorderLayout.CENTER, queryScriptTabPane );
  return queryDetailsPanel;
}
 
Example 26
Source Project: marathonv5   Source File: TabbedPaneDemo.java    License: Apache License 2.0 5 votes vote down vote up
public TabbedPaneDemo() {
    super(new GridLayout(1, 1));

    JTabbedPane tabbedPane = new JTabbedPane();
    ImageIcon icon = createImageIcon("images/middle.gif");

    JComponent panel1 = makeTextPanel("Panel #1");
    tabbedPane.addTab("Tab 1", icon, panel1, "Does nothing");
    tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

    JComponent panel2 = makeTextPanel("Panel #2");
    tabbedPane.addTab("Tab 2", icon, panel2, "Does twice as much nothing");
    tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

    JComponent panel3 = makeTextPanel("Panel #2");
    tabbedPane.addTab("Tab 3", icon, panel3, "Still does nothing");
    tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);

    JComponent panel4 = makeTextPanel("Panel #4 (has a preferred size of 410 x 50).");
    panel4.setPreferredSize(new Dimension(410, 50));
    tabbedPane.addTab("Tab 4", icon, panel4, "Does nothing at all");
    tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);

    // Add the tabbed pane to this panel.
    add(tabbedPane);

    // The following line enables to use scrolling tabs.
    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
 
Example 27
Source Project: netbeans   Source File: TabDisplayerFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TabDisplayer createTabDisplayer( TabDataModel tabModel, int orientation ) {
    Settings settings = Settings.getDefault();
    boolean multiRow = settings.getRowCount() > 1 || settings.isTabRowPerProject();
    if( multiRow && (orientation == JTabbedPane.TOP || orientation == JTabbedPane.BOTTOM) ) {
        if( settings.isTabRowPerProject() ) {
            return new RowPerProjectTabDisplayer( tabModel, orientation );
        }
        return new MultiRowTabDisplayer( tabModel, orientation );
    }
    return new SimpleTabDisplayer( tabModel, orientation );
}
 
Example 28
Source Project: jdk8u60   Source File: Test4234761.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
Example 29
Source Project: pumpernickel   Source File: BoxTabbedPaneUI.java    License: MIT License 5 votes vote down vote up
protected Data getData(JTabbedPane tabs) {
	Data d = (Data) tabs.getClientProperty(PROPERTY_DATA);
	if (d == null) {
		d = new Data(tabs);
		tabs.putClientProperty(PROPERTY_DATA, d);
	}
	return d;
}
 
Example 30
Source Project: jdk8u60   Source File: bug7170310.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowUI() {
    frame = new JFrame("bug7170310");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 100);

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Main Tab", new JPanel());

    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    frame.getContentPane().add(tabbedPane);
    frame.setVisible(true);
}