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

The following examples show how to use javax.swing.JTabbedPane#getTitleAt() . 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: Config.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
private static Object getValue(String key) {
	JComponent component = components.get(key);
	if (component == null)
		return inits.get(key);

	if (component instanceof JTextField)
		return ((JTextField) component).getText();
	else if (component instanceof JComboBox)
		return (String) ((JComboBox) component).getSelectedItem();
	else if (component instanceof JCheckBox)
		return ((JCheckBox) component).isSelected() ? "true" : "false";
	else if (component instanceof JLabel)
		return ((JLabel) component).getText();
	else if (component instanceof SpinnerRangeDouble)
		return new Double(((SpinnerRangeDouble) component).get());
	else if (component instanceof SpinnerRangeInteger)
		return new Integer(((SpinnerRangeInteger) component).get());
	else if (component instanceof JTabbedPane) {
		JTabbedPane tab = (JTabbedPane) component;
		return tab.getTitleAt(tab.getSelectedIndex());
	}
	return inits.get(key);
}
 
Example 2
Source File: TestDataComponent.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private void deleteTestData(Object source) {
    JTabbedPane tab = (JTabbedPane) source;
    TestDataTablePanel panel = getSelectedData();
    if (!panel.isGlobalData) {
        int index = tab.getSelectedIndex();
        String name = tab.getTitleAt(index);
        int option = JOptionPane.showConfirmDialog(null, "Are you sure want to delete the TestData [" + name + "]", "Delete TestData", JOptionPane.YES_NO_OPTION);
        if (option == JOptionPane.YES_OPTION) {
            Boolean flag = testDesign.getProject().getTestData()
                    .getTestDataFor(envTab.getTitleAt(envTab.getSelectedIndex()))
                    .deleteTestData(name);
            if (flag) {
                tab.setSelectedIndex(index - 1);
                tab.removeTabAt(index);
            } else {
                Notification.show("Couldn't Delete Testdata - '" + name + "'");
            }
        }
    }
}
 
Example 3
Source File: CloseTabPaneUI.java    From iBioSim with 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 4
Source File: TabsMenu.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void menuSelected(MenuEvent e) {
    TabsMenu.this.removeAll();
    ExploreNodeAction exploreAction = new ExploreNodeAction(cliGuiCtx);
    JMenuItem exploreSelectedNode = new JMenuItem(exploreAction);
    exploreSelectedNode.setMnemonic(KeyEvent.VK_E);

    if ((exploreAction.getSelectedNode() == null) || exploreAction.getSelectedNode().isLeaf()) {
        exploreSelectedNode.setEnabled(false);
    }

    add(exploreSelectedNode);
    addSeparator();

    JTabbedPane tabs = cliGuiCtx.getTabs();
    for (int i=0; i < tabs.getTabCount(); i++) {
        GoToTabAction action = new GoToTabAction(i, tabs.getTitleAt(i));
        JMenuItem item = new JMenuItem(action);
        item.setToolTipText(tabs.getToolTipTextAt(i));
        add(item);
    }
}
 
Example 5
Source File: ButtonTabComponent.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
public ButtonTabComponent(JTabbedPane pane, Function<CodeEditor<?, ?, ?>, Unit> callback) {
	// unset default FlowLayout' gaps
	super(new FlowLayout(FlowLayout.LEFT, 0, 0));
	if (pane == null) {
		throw new NullPointerException("TabbedPane is null");
	}
	this.pane = pane;
	this.callback = callback;
	setOpaque(false);

	// make JLabel read titles from JTabbedPane
	JLabel label = new JLabel() {
		@Override
		public String getText() {
			int i = pane.indexOfTabComponent(ButtonTabComponent.this);
			if (i != -1) {
				return pane.getTitleAt(i);
			}
			return null;
		}
	};

	add(label);
	// add more space between the label and the button
	label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
	// tab button
	JButton button = new TabButton();
	add(button);
	// add more space to the top of the component
	setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
Example 6
Source File: ButtonTabComponent.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ButtonTabComponent(final JTabbedPane pane) {
    //unset default FlowLayout' gaps
    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    if (pane == null) {
        throw new NullPointerException("TabbedPane is null");
    }
    this.pane = pane;
    setOpaque(false);
    
    //make JLabel read titles from JTabbedPane
    JLabel label = new JLabel() {
        @Override
        public String getText() {
            int i = pane.indexOfTabComponent(ButtonTabComponent.this);
            if (i != -1) {
                return pane.getTitleAt(i);
            }
            return null;
        }
    };
    
    add(label);
    //add more space between the label and the button
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    //tab button
    button = new TabButton();
    add(button);
    //add more space to the top of the component
    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
Example 7
Source File: JTabbedPaneTabJavaElement.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected static String getItemText(JTabbedPane tabbedPane, int index) {
    String titleAt = tabbedPane.getTitleAt(index);
    if (titleAt == null || "".equals(titleAt)) {
        return getTabNameFromIcon(tabbedPane, index);
    }
    return titleAt;
}
 
Example 8
Source File: ButtonTabComponent.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new button tab component.
 * 
 * @param pane pane the button tab component belongs to.
 */
public ButtonTabComponent(final JTabbedPane pane) {
  // unset default FlowLayout' gaps
  super(new FlowLayout(FlowLayout.LEFT, 0, 0));

  m_pane = Preconditions.checkNotNull(pane, "IE01213: TabbedPane is null");
  setOpaque(false);

  // make JLabel read titles from JTabbedPane
  final JLabel label = new JLabel() {
    private static final long serialVersionUID = 8139543899934835869L;

    @Override
    public String getText() {
      final int index = pane.indexOfTabComponent(ButtonTabComponent.this);
      if (index != -1) {
        return pane.getTitleAt(index);
      }
      return null;
    }
  };

  add(label);
  // add more space between the label and the button
  label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
  // tab button
  final JButton button = new TabButton();
  add(button);
  // add more space to the top of the component
  setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
Example 9
Source File: MPrinter.java    From javamelody with Apache License 2.0 5 votes vote down vote up
private String getTitleIfKnownComponent(Component current) {
	if (current instanceof JTabbedPane) {
		final JTabbedPane tabbedPane = (JTabbedPane) current;
		return tabbedPane.getTitleAt(tabbedPane.getSelectedIndex());
	} else if (current instanceof JFrame) {
		return ((JFrame) current).getTitle();
	} else if (current instanceof JDialog) {
		return ((JDialog) current).getTitle();
	}
	return null;
}
 
Example 10
Source File: MButtonTabComponent.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 * @param pane JTabbedPane
 */
public MButtonTabComponent(final JTabbedPane pane) {
	//unset default FlowLayout' gaps
	super(new FlowLayout(FlowLayout.LEFT, 0, 0));
	if (pane == null) {
		throw new IllegalArgumentException("TabbedPane is null");
	}
	this.pane = pane;
	setOpaque(false);

	//make JLabel read titles from JTabbedPane
	final JLabel label = new JLabel() {
		private static final long serialVersionUID = 1L;

		@Override
		public String getText() {
			final int i = pane.indexOfTabComponent(MButtonTabComponent.this);
			if (i != -1) {
				return pane.getTitleAt(i);
			}
			return null;
		}
	};

	add(label);
	//add more space between the label and the button
	label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
	//tab button
	final JButton button = new TabButton();
	add(button);
	//add more space to the top of the component
	setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
Example 11
Source File: ButtonTabComponent.java    From JCEditor with GNU General Public License v2.0 5 votes vote down vote up
public ButtonTabComponent(final JTabbedPane pane, ArrayList<AreaDeTexto> adts, ArrayList<String> arqsAbertos) {
    //unset default FlowLayout' gaps
    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    if (pane == null) {
        throw new NullPointerException("");
    }
    this.pane = pane;
    this.adts = adts;
    this.arquivosAbertos = arqsAbertos;
    setOpaque(false);
    
    //make JLabel read titles from JTabbedPane
    JLabel label = new JLabel() {
        public String getText() {
            int i = pane.indexOfTabComponent(ButtonTabComponent.this);
            if (i != -1) {
                return pane.getTitleAt(i);
            }
            return null;
        }
    };
    
    add(label);
    //add more space between the label and the button
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    //tab button
    JButton button = new TabButton();
    add(button);
    //add more space to the top of the component
    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
Example 12
Source File: ButtonTabComponent.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ButtonTabComponent(final JTabbedPane pane) {
    //unset default FlowLayout' gaps
    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    if (pane == null) {
        throw new NullPointerException("TabbedPane is null");
    }
    this.pane = pane;
    setOpaque(false);

    //make JLabel read titles from JTabbedPane
    JLabel label = new JLabel() {
        public String getText() {
            int i = pane.indexOfTabComponent(ButtonTabComponent.this);
            if (i != -1) {
                return pane.getTitleAt(i);
            }
            return null;
        }
    };

    add(label);
    //add more space between the label and the button
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    //tab button
    JButton button = new TabButton();
    add(button);
    //add more space to the top of the component
    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}