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

The following examples show how to use javax.swing.JTabbedPane#getSelectedComponent() . 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: RefactoringPanelContainer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void closeAllButCurrent() {
    Component comp = getComponent(0);
    if (comp instanceof JTabbedPane) {
        JTabbedPane tabs = (JTabbedPane) comp;
        Component current = tabs.getSelectedComponent();
        int tabCount = tabs.getTabCount();
        // #172039: do not use tabs.getComponents()
        Component[] c = new Component[tabCount - 1];
        for (int i = 0, j = 0; i < tabCount; i++) {
            Component tab = tabs.getComponentAt(i);
            if (tab != current) {
                c[j++] = tab;
            }
        }
        for (int i = 0; i < c.length; i++) {
            ((RefactoringPanel) c[i]).close();
        }
    }
}
 
Example 2
Source File: NetworkConnectionManager.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * create a GUI to give the user transport layer options.
 * @param parent the root gui component
 * @return a new connection or null.
 */
static public NetworkConnection requestNewConnection(Component parent) {
	JTabbedPane tabs = new JTabbedPane();
	tabs.addTab(Translator.get("Local"), serial.getTransportLayerPanel());
	tabs.addTab(Translator.get("Remote"), tcp.getTransportLayerPanel());
	tabs.setSelectedIndex(selectedLayer);
	
	JPanel top = new JPanel(new BorderLayout());
	top.add(tabs,BorderLayout.CENTER);

	int result = JOptionPane.showConfirmDialog(parent, top, Translator.get("MenuConnect"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
	if (result == JOptionPane.OK_OPTION) {
		Component c = tabs.getSelectedComponent();
		selectedLayer = tabs.getSelectedIndex();
		if(c instanceof TransportLayerPanel) {
			return ((TransportLayerPanel)c).openConnection();
		}
	}
	// cancelled connect
	return null;
}
 
Example 3
Source File: RefactoringPanelContainer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Component getRefactoringPanelComp() {
    RefactoringPanel.checkEventThread();
    Component comp = getComponentCount() > 0 ? getComponent(0) : null;
    if (comp instanceof JTabbedPane) {
        JTabbedPane tabs = (JTabbedPane) comp;
        return tabs.getSelectedComponent();
    } else {
        return comp;
    }
}
 
Example 4
Source File: RefactoringPanelContainer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public RefactoringPanel getCurrentPanel() {
    if (getComponentCount() > 0) {
        Component comp = getComponent(0);
        if (comp instanceof JTabbedPane) {
            JTabbedPane tabs = (JTabbedPane) comp;
            return (RefactoringPanel) tabs.getSelectedComponent();
        } else {
            if (comp instanceof RefactoringPanel)
                return (RefactoringPanel) comp;
        }
    }
    return null;
}
 
Example 5
Source File: TestDataComponent.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private TestDataTablePanel getSelectedData() {
    if (envTab.getSelectedComponent() instanceof JTabbedPane) {
        JTabbedPane tab = (JTabbedPane) envTab.getSelectedComponent();
        if (tab.getTabCount() > 0 && tab.getSelectedComponent() != null
                && tab.getSelectedComponent() instanceof TestDataTablePanel) {
            return (TestDataTablePanel) tab.getSelectedComponent();
        }
    }
    return null;
}
 
Example 6
Source File: ScreenshotBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
	if (e.getSource() instanceof JTabbedPane) {
		JTabbedPane src = (JTabbedPane) e.getSource();
		JScrollPane scroll = (JScrollPane) src.getSelectedComponent();
		if (scroll.getViewport().getComponent(0) == container) {
			visible = true;
			schedule();
		}
		else {
			loaderService.cancelPending();
			visible = false;
		}
	}
}
 
Example 7
Source File: IntervalManagerDialog.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
    BaseIntervalPanel previous = null;

    if (absolute.isEnabled()) {
        previous = absolute;
    }
    else if (relative.isEnabled()) {
        previous = relative;
    }
    else if (bulk.isEnabled()) {
        previous = bulk;
    }
    else {
        return;
    }

    JTabbedPane tabs = (JTabbedPane) e.getSource();
    BaseIntervalPanel current = (BaseIntervalPanel) tabs.getSelectedComponent();

    if (current != null) {
        current.setIntervalName(previous.getIntervalName());

        current.setTimes(previous.getStartTime(), previous.getEndTime());

        current.setEnabled(true);
    }

    // remove listeners
    previous.setEnabled(false);

    current.propertyChange(new PropertyChangeEvent(this, "timeZone", null, previous.getTimeZone()));
}