Java Code Examples for javax.swing.JTabbedPane#setTabComponentAt()

The following examples show how to use javax.swing.JTabbedPane#setTabComponentAt() . 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
Source File: GuiUtil.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static TextEditor addNewTextEditor(String title, JTabbedPane tabbedPanel) {
    final TextEditor tab = new TextEditor(tabbedPanel, title);
    tabbedPanel.add(tab, title);
    tabbedPanel.setSelectedComponent(tab);
    //tab.setTextFont(_font);
    tab.getTextArea().setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON);
    tab.getTextArea().discardAllEdits();
    tab.getTextArea().setDirty(false);
    tab.setTitle(title);
    ButtonTabComponent btc = new ButtonTabComponent(tabbedPanel);
    JButton button = btc.getTabButton();
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //FrmTextEditor.this.closeFile(tab);
        }
    });
    tabbedPanel.setTabComponentAt(tabbedPanel.indexOfComponent(tab), btc);

    return tab;
}
 
Example 2
Source File: TracerSimpleReportFrame.java    From pega-tracerviewer with 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 3
Source File: frmMain.java    From Course_Generator with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Add a tab to JTabbedPane. The icon is at the left of the text and there some
 * space between the icon and the label
 * 
 * @param tabbedPane JTabbedPane where we want to add the tab
 * @param tab        Tab to add
 * @param title      Title of the tab
 * @param icon       Icon of the tab
 */
private JLabel addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) {
	tabbedPane.add(tab);

	// Create bespoke component for rendering the tab.
	javax.swing.JLabel lbl = new javax.swing.JLabel(title);
	if (icon != null)
		lbl.setIcon(icon);

	// Add some spacing between text and icon, and position text to the RHS.
	lbl.setIconTextGap(5);
	lbl.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

	tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, lbl);

	return lbl;
}
 
Example 4
Source File: frmSettings.java    From Course_Generator with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add a tab to JTabbedPane. The icon is at the left of the text and there some
 * space between the icon and the label
 * 
 * @param tabbedPane JTabbedPane where we want to add the tab
 * @param tab        Tab to add
 * @param title      Title of the tab
 * @param icon       Icon of the tab
 */
private void addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) {
	tabbedPane.add(tab);

	// Create bespoke component for rendering the tab.
	javax.swing.JLabel lbl = new javax.swing.JLabel(title);
	if (icon != null)
		lbl.setIcon(icon);

	// Add some spacing between text and icon, and position text to the RHS.
	lbl.setIconTextGap(5);
	lbl.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

	tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, lbl);
}
 
Example 5
Source File: MainPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
private static void addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) {
    tabbedPane.add(tab);

    JLabel lbl = new JLabel(title);
    lbl.setIcon(icon);
    lbl.setIconTextGap(5);
    lbl.setHorizontalTextPosition(SwingConstants.RIGHT);

    tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, lbl);
}
 
Example 6
Source File: ExploreNodeAction.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void actionPerformed(ActionEvent ae) {
    JTabbedPane tabs = cliGuiCtx.getTabs();
    int newTabIndex = tabs.getSelectedIndex() + 1;
    ManagementModelNode newRoot = node.clone();
    tabs.insertTab(calcTabName(this.node), null, new ManagementModel(newRoot, cliGuiCtx), newRoot.addressPath(), newTabIndex);
    tabs.setTabComponentAt(newTabIndex, new ButtonTabComponent(tabs));
    tabs.setSelectedIndex(newTabIndex);
}
 
Example 7
Source File: ToolAdapterTabbedEditorDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void addTab(JTabbedPane tabControl, String title, JPanel content) {
    JLabel tabText = new JLabel(title, JLabel.LEFT);
    tabText.setPreferredSize(new Dimension(6 * controlHeight, controlHeight));
    TitledBorder titledBorder = BorderFactory.createTitledBorder(title);
    titledBorder.setTitleJustification(TitledBorder.CENTER);
    content.setBorder(titledBorder);
    tabControl.addTab(null, content);
    tabControl.setTabComponentAt(tabControl.getTabCount() - 1, tabText);
}
 
Example 8
Source File: ViewMapping.java    From AML-Project with Apache License 2.0 4 votes vote down vote up
private void refresh()
{
	a = aml.getAlignment();
	mapping = aml.getActiveMapping();
       m = a.get(mapping);
       sourceId = m.getSourceId();
       targetId = m.getTargetId();
       t = uris.getType(sourceId);
       
       //Set the title and modality
       this.setTitle(m.toGUI());
	this.setModalityType(ModalityType.APPLICATION_MODAL);

       //Setup the Tabbed Pane
       tabbedPane = new JTabbedPane();
       tabbedPane.setBackground(AMLColor.WHITE);

       //Add the graph
       buildGraph();
       if(mappingViewer != null)
       {
       	tabbedPane.addTab("Graph View", mappingViewer);
       	mappingViewer.mouseClicked();
       }
       else
       	tabbedPane.addTab("Graph View", new JPanel());
       JLabel lab1 = new JLabel("Graph View",SwingConstants.CENTER);
       lab1.setPreferredSize(new Dimension(120, 15));
       tabbedPane.setTabComponentAt(0, lab1);
       //Add the details
       buildDetailPanel();
       tabbedPane.addTab("Details", details);
       JLabel lab2 = new JLabel("Details",SwingConstants.CENTER);
       lab2.setPreferredSize(new Dimension(120, 15));
       tabbedPane.setTabComponentAt(1, lab2);
       //Add the issues
       buildConflictPanel();
       tabbedPane.addTab("Status & Conflicts", conflicts);
       JLabel lab3 = new JLabel("Status & Conflicts",SwingConstants.CENTER);
       lab3.setPreferredSize(new Dimension(120, 15));
       tabbedPane.setTabComponentAt(2, lab3);
       
       //Set the tabbed pane as the content pane
	setContentPane(tabbedPane);
	
	//Wrap up
	this.pack();
	GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
	int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2);
	this.setLocation(left, 0);
       this.setVisible(true);
}