javax.swing.JTabbedPane#setSelectedIndex ( )源码实例Demo

下面列出了javax.swing.JTabbedPane#setSelectedIndex ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private MouseAdapter onAddNewTDTab() {
    return new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            JTabbedPane tabbedPane = (JTabbedPane) me.getSource();
            if (tabbedPane.getSelectedIndex() != -1 && getSelectedData() == null) {
                Rectangle rect = tabbedPane.getUI().
                        getTabBounds(tabbedPane, tabbedPane.getSelectedIndex());
                if (rect.contains(me.getPoint())) {
                    tabbedPane.setSelectedIndex(tabbedPane.getSelectedIndex() - 1);
                    addNewTestData(tabbedPane);
                }
            }
        }
    };
}
 
源代码2 项目: zap-extensions   文件: CloseActionHandler.java
@Override
public void actionPerformed(ActionEvent evt) {

    JTabbedPane ntp = getNumberedTabbedPane();

    int index = ntp.indexOfTab(getTabName());
    if (index >= 0) {
        if (ntp.getTabCount() > 2 && index == ntp.getTabCount() - 2) {
            ntp.setSelectedIndex(index - 1);
        }
        ManualHttpRequestEditorPanel currentEditor =
                (ManualHttpRequestEditorPanel) ntp.getComponentAt(index);
        currentEditor.beforeClose();
        currentEditor.saveConfig();
        ntp.removeTabAt(index);
    }
}
 
public Boolean navigateToTestData(String sheetName, String columnName) {
    if (envTab.getSelectedComponent() instanceof JTabbedPane) {
        JTabbedPane tab = (JTabbedPane) envTab.getSelectedComponent();
        for (int i = 0; i < tab.getTabCount(); i++) {
            if (tab.getComponentAt(i) instanceof TestDataTablePanel) {
                TestDataTablePanel tdPanel = (TestDataTablePanel) tab.getComponentAt(i);
                if (tdPanel.std.getName().equals(sheetName)) {
                    int colIndex = tdPanel.std.getColumnIndex(columnName);
                    if (colIndex != -1) {
                        tab.setSelectedIndex(i);
                        tdPanel.table.selectColumn(colIndex);
                        return true;
                    }
                    break;
                }
            }
        }
    }
    return false;
}
 
源代码4 项目: ECG-Viewer   文件: DefaultPolarPlotEditor.java
/**
 * Creates a tabbed pane for editing the plot attributes.
 * 
 * @param plot  the plot.
 * 
 * @return A tabbed pane. 
 */
@Override
protected JTabbedPane createPlotTabs(Plot plot) {
    JTabbedPane tabs = super.createPlotTabs(plot);
    // TODO find a better localization key
    tabs.insertTab(localizationResources.getString("General1"), null, 
            createPlotPanel(), null, 0);
    tabs.setSelectedIndex(0);
    return tabs;
}
 
源代码5 项目: hottub   文件: Test4234761.java
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();
}
 
源代码6 项目: dragonwell8_jdk   文件: Test4234761.java
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();
}
 
源代码7 项目: rapidminer-studio   文件: ConnectionEditDialog.java
/**
 * Show a specific tab, to be found via the title. The title is already present resolved from I18N so the result
 * from {@link ConnectionI18N#getConnectionGUILabel(String, Object...)} is required here. Fails quietly.
 *
 * @param name
 * 		value of the I18N key for connection GUI label
 */
public void showTab(String name) {
	if (name == null || !(mainGUI instanceof JTabbedPane)) {
		return;
	}

	JTabbedPane tabPane = (JTabbedPane) mainGUI;
	for (int i = 0; i < tabPane.getTabCount(); i++) {
		if (name.equals(tabPane.getTitleAt(i))) {
			tabPane.setSelectedIndex(i);
			break;
		}
	}
}
 
源代码8 项目: openjdk-8   文件: Test4234761.java
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();
}
 
源代码9 项目: netbeans   文件: DiffViewModeSwitcher.java
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);
        }
    }
}
 
public void testDifferenceCount () throws Exception {
    int dc = simple.getDifferenceCount();
    assertEquals(3, dc);

    // as default, the graphical view is displayed and the diff count is the same as in the old-style diff view
    dc = enhanced.getDifferenceCount();
    assertEquals(3, dc);
    JTabbedPane c = findTabbedPane(enhanced.getJComponent());

    // switching to the textual view
    final boolean[] finished = new boolean[1];
    enhanced.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (DiffController.PROP_DIFFERENCES.equals(evt.getPropertyName())) {
                finished[0] = true;
            }
        }
    });
    c.setSelectedIndex(1);
    dc = enhanced.getDifferenceCount();
    // zero differences for the textual diff view
    // it shows no differences, displays the diff as a whole
    assertEquals(0, dc);
    // and it should fire an event about differences being changed so clients can refresh navigation button etc.
    for (int i = 0; i < 5 && !finished[0]; ++i) {
        Thread.sleep(1000);
    }
    assertTrue(finished[0]);
}
 
源代码11 项目: jdk8u-jdk   文件: Test4234761.java
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();
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: Test4234761.java
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();
}
 
源代码13 项目: binnavi   文件: DialogEditCodeNodeComment.java
/**
 * Creates the GUI of the dialog.
 *
 * @param initialTab
 */
private void createGui(final InitialTab initialTab) {
  final JTabbedPane tab = new JTabbedPane();

  tab.add("Global Line Comments", m_globalLineCommentsPanel);
  tab.add("Local Line Comments", m_localLineCommentsPanel);
  tab.add("Node Comments", m_commentsPanel);
  tab.add("Function Comments", m_functionCommentsPanel);

  add(tab, BorderLayout.CENTER);
  add(new OKButtonPanel(this), BorderLayout.SOUTH);
  pack();

  switch (initialTab) {
    case GlobalLineComments:
      tab.setSelectedIndex(0);
      break;
    case LocalLineComments:
      tab.setSelectedIndex(1);
      break;
    case LocalNodeComments:
      tab.setSelectedIndex(2);
      m_commentsPanel.focusLocalField();
      break;
    case GlobalNodeComments:
      tab.setSelectedIndex(2);
      m_commentsPanel.focusGlobalField();
      break;
    case FunctionComments:
      tab.setSelectedIndex(3);
      m_functionCommentsPanel.focusGlobalField();
      break;
    default:
      throw new IllegalStateException("IE00681: Unknown initial tab");
  }
}
 
源代码14 项目: jdk8u-dev-jdk   文件: Test4234761.java
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();
}
 
源代码15 项目: ccu-historian   文件: DefaultPolarPlotEditor.java
/**
 * Creates a tabbed pane for editing the plot attributes.
 * 
 * @param plot  the plot.
 * 
 * @return A tabbed pane. 
 */
@Override
protected JTabbedPane createPlotTabs(Plot plot) {
    JTabbedPane tabs = super.createPlotTabs(plot);
    // TODO find a better localization key
    tabs.insertTab(localizationResources.getString("General1"), null, 
            createPlotPanel(), null, 0);
    tabs.setSelectedIndex(0);
    return tabs;
}
 
private void closeTestData(Object source) {
    JTabbedPane tab = (JTabbedPane) source;
    TestDataTablePanel panel = getSelectedData();
    if (!panel.isGlobalData) {
        int index = tab.getSelectedIndex();
        tab.setSelectedIndex(index - 1);
        tab.removeTabAt(index);
    }
}
 
源代码17 项目: GiantTrees   文件: ExportDialog.java
void createGUI() {
	tabbedPane = new JTabbedPane();

	JComponent exportPanel = createExportPanel();
	tabbedPane.addTab("Export", null, exportPanel,
	                  "Export options");
	tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

	JComponent renderPanel = createRenderPanel();
	tabbedPane.addTab("Render", null, renderPanel,
       "Render options");
	tabbedPane.setMnemonicAt(0, KeyEvent.VK_2);

	if (render) {
		tabbedPane.setSelectedIndex(1);
	}
	formatSettings(formatBox.getSelectedIndex());
	
	// buttons
	startButton = new JButton("Start");
	startButton.addActionListener(new StartButtonListener());
	
	cancelButton = new JButton("Close");
	cancelButton.addActionListener(new CancelButtonListener());
	
	JPanel buttons = new JPanel();
	buttons.add(startButton);
	buttons.add(cancelButton);
	
	JPanel panel = new JPanel();
	//panel.setLayout(new BoxLayout(panel,BoxLayout.PAGE_AXIS));
	panel.setLayout(new BorderLayout());
	panel.add(tabbedPane,BorderLayout.CENTER);
	panel.add(buttons,BorderLayout.SOUTH);
	
	// add panel to content pane
	Container contentPane = frame.getContentPane(); 
	contentPane.add(panel,BorderLayout.CENTER);
	
	// add status line
	progressbar = new Progressbar();
	progressbar.setVisible(false);
	contentPane.add(progressbar,BorderLayout.PAGE_END);
	
	frame.pack();
}
 
源代码18 项目: pcgen   文件: InfoTabbedPane.java
/**
 * Switch the current tab to be the one named, possibly including a sub tab
 * and then advise the user of the item to be done. generally the tab will
 * handle this but a fallback of a dialog will be used if the tab can't do
 * the advising.
 *
 * @param dest An arry of the tab name, the field name and optionally the
 * sub tab name.
 */
private void switchTabsAndAdviseTodo(String[] dest)
{
	Tab tab = Tab.valueOf(dest[0]);
	String tabName = currentCharacter.getDataSet().getGameMode().getTabName(tab);

	Component selTab = null;
	for (int i = 0; i < getTabCount(); i++)
	{
		if (tabName.equals(getTitleAt(i)))
		{
			setSelectedIndex(i);
			selTab = getComponent(i);
			break;
		}
	}
	if (selTab == null)
	{
		Logging.errorPrint("Failed to find tab " + tabName); //$NON-NLS-1$
		return;
	}

	if (selTab instanceof JTabbedPane && dest.length > 2)
	{
		JTabbedPane tabPane = (JTabbedPane) selTab;
		for (int i = 0; i < tabPane.getTabCount(); i++)
		{
			if (dest[2].equals(tabPane.getTitleAt(i)))
			{
				tabPane.setSelectedIndex(i);
				break;
			}
		}
	}

	if (selTab instanceof TodoHandler)
	{
		((TodoHandler) selTab).adviseTodo(dest[1]);
	}
	else
	{
		String message = LanguageBundle.getFormattedString("in_todoUseField", dest[1]); //$NON-NLS-1$
		JOptionPane.showMessageDialog(selTab, message, LanguageBundle.getString("in_tipsString"), //$NON-NLS-1$
			JOptionPane.INFORMATION_MESSAGE);
	}
}
 
源代码19 项目: gepard   文件: ControlPanel.java
public ControlPanel(Controller ictrl) {

		// store controller
		ctrl = ictrl;

		// load substitution matrices from XML file
		try {
			substMatrices = SubstMatrixList.getInstance().getMatrixFiles();
		} catch (Exception e) {
			ClientGlobals.errMessage("Could not open substitution matrix list. " + "The 'matrices/' subfolder seems to be corrupted");
			System.exit(1);
		}

		// sequences panel
		JPanel localTab = generateLocalTab();

		seqTabs = new JTabbedPane();
		// add sequence panes
		seqTabs.addTab("Sequences", localTab);
		seqTabs.addChangeListener(this);

		// function panel
		JPanel functPanel = generateFunctionPanel();

		// options panel
		JPanel plotOptTab = generatePlotOptTab();
		JPanel miscTab = generateMiscTab();
		dispTab = generateDispTab();

		optTabs = new JTabbedPane();
		optTabs.setFont(MAIN_FONT);
		// optTabs.setBorder(BorderFactory.createEmptyBorder());
		optTabs.addTab("Plot", plotOptTab);
		optTabs.addTab("Misc", miscTab);
		optTabs.addTab("Display", dispTab);
		optTabs.setSelectedIndex(0);

		// create layout
		seqTabs.setAlignmentX(Component.LEFT_ALIGNMENT);
		optTabs.setAlignmentX(Component.LEFT_ALIGNMENT);
		btnGo.setAlignmentX(Component.LEFT_ALIGNMENT);
		functPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
		JPanel fixedBox = new JPanel();
		fixedBox.setLayout(new BoxLayout(fixedBox, BoxLayout.Y_AXIS));
		// fixedBox.setLayout(new GridBagLayout());
		fixedBox.add(Box.createRigidArea(new Dimension(0, 3)));
		fixedBox.add(seqTabs);
		fixedBox.add(Box.createRigidArea(new Dimension(0, 10)));
		fixedBox.add(functPanel);
		// fixedBox.add(Box.createRigidArea(new Dimension(0,10)));

		fixedBox.add(Box.createRigidArea(new Dimension(0, 10)));
		fixedBox.add(optTabs);

		seqTabs.setPreferredSize(new Dimension(1, SEQ_HEIGHT));
		functPanel.setPreferredSize(new Dimension(1, FUNCT_HEIGHT));
		optTabs.setPreferredSize(new Dimension(1, OPT_HEIGHT));

		// dummy panel which pushes the go button to the bottom of the window
		JPanel panelQuit = new JPanel(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridx = 0;
		c.gridy = 0;
		c.weightx = 1;
		c.weighty = 1000;
		panelQuit.add(new JLabel(""), c);
		c.gridy++;
		c.weighty = 1;
		c.insets = new Insets(0, HOR_MARGIN + QUIT_BTN_HOR_MARGIN, BELOW_QUIT_BTN, HOR_MARGIN + QUIT_BTN_HOR_MARGIN);
		panelQuit.add(btnQuit = new JButton("Quit"), c);

		btnQuit.setPreferredSize(new Dimension(1, QUIT_BTN_HEIGHT));

		setLayout(new BorderLayout());
		add(fixedBox, BorderLayout.NORTH);
		add(panelQuit, BorderLayout.CENTER);

		btnQuit.addActionListener(this);

		// simple or advanced mode
		if (Config.getInstance().getIntVal("advanced", 0) == 1)
			switchMode(true);
		else
			switchMode(false);

		// help tooltips
		btnQuit.setToolTipText(HelpTexts.getInstance().getHelpText("quit"));

		// set initial parameters
		needreload = true;

		setDispTabEnabled(false);
		setNavigationEnabled(false);

	}
 
源代码20 项目: pcgen   文件: InfoTabbedPane.java
/**
 * Switch the current tab to be the one named, possibly including a sub tab
 * and then advise the user of the item to be done. generally the tab will
 * handle this but a fallback of a dialog will be used if the tab can't do
 * the advising.
 *
 * @param dest An arry of the tab name, the field name and optionally the
 * sub tab name.
 */
private void switchTabsAndAdviseTodo(String[] dest)
{
	Tab tab = Tab.valueOf(dest[0]);
	String tabName = currentCharacter.getDataSet().getGameMode().getTabName(tab);

	Component selTab = null;
	for (int i = 0; i < getTabCount(); i++)
	{
		if (tabName.equals(getTitleAt(i)))
		{
			setSelectedIndex(i);
			selTab = getComponent(i);
			break;
		}
	}
	if (selTab == null)
	{
		Logging.errorPrint("Failed to find tab " + tabName); //$NON-NLS-1$
		return;
	}

	if (selTab instanceof JTabbedPane && dest.length > 2)
	{
		JTabbedPane tabPane = (JTabbedPane) selTab;
		for (int i = 0; i < tabPane.getTabCount(); i++)
		{
			if (dest[2].equals(tabPane.getTitleAt(i)))
			{
				tabPane.setSelectedIndex(i);
				break;
			}
		}
	}

	if (selTab instanceof TodoHandler)
	{
		((TodoHandler) selTab).adviseTodo(dest[1]);
	}
	else
	{
		String message = LanguageBundle.getFormattedString("in_todoUseField", dest[1]); //$NON-NLS-1$
		JOptionPane.showMessageDialog(selTab, message, LanguageBundle.getString("in_tipsString"), //$NON-NLS-1$
			JOptionPane.INFORMATION_MESSAGE);
	}
}