Java Code Examples for javax.swing.JTabbedPane#getSelectedIndex()
The following examples show how to use
javax.swing.JTabbedPane#getSelectedIndex() .
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: TestDataComponent.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
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); } } } }; }
Example 2
Source File: TestDataComponent.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
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: FramePrincipal.java From brModelo with GNU General Public License v3.0 | 6 votes |
private void TabInspectorStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TabInspectorStateChanged JTabbedPane sourceTabbedPane = (JTabbedPane) evt.getSource(); int index = sourceTabbedPane.getSelectedIndex(); if (index == 1) { DoComandoExterno(Controler.menuComandos.cmdTreeNavegador); Manager.setTextoDica(null, ""); } else { if (Manager != null) { if (index == 0) { inspector1.PerformDica(); } else { inspector2.PerformDica(); } } } }
Example 4
Source File: NetworkConnectionManager.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
/** * 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 5
Source File: JTabbedPaneJavaElement.java From marathonv5 with Apache License 2.0 | 5 votes |
public static String getSelectedItemText(JTabbedPane component) { int selectedIndex = component.getSelectedIndex(); if (selectedIndex != -1) { return JTabbedPaneTabJavaElement.getText(component, selectedIndex); } return ""; }
Example 6
Source File: RTabbedPane.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void stateChanged(ChangeEvent e) { JTabbedPane tp = (JTabbedPane) component; int selectedIndex = tp.getSelectedIndex(); if (selectedIndex != -1) { recorder.recordSelect(this, JTabbedPaneTabJavaElement.getText(tp, selectedIndex)); } }
Example 7
Source File: TransactionView.java From netbeans with Apache License 2.0 | 5 votes |
/** * Listens to events from the tab pane, displays different * categories of data accordingly. */ public void stateChanged(ChangeEvent e) { setName(NbBundle.getBundle(TransactionView.class).getString("MON_Title")); JTabbedPane p = (JTabbedPane)e.getSource(); displayType = p.getSelectedIndex(); showData(); }
Example 8
Source File: DiffViewModeSwitcher.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void stateChanged (ChangeEvent e) { Object source = e.getSource(); if (source instanceof JTabbedPane) { JTabbedPane tabPane = (JTabbedPane) source; if (handledViews.containsKey(tabPane)) { diffViewMode = tabPane.getSelectedIndex(); } } }
Example 9
Source File: TestDataComponent.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
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); } }
Example 10
Source File: CloseTabPaneUI.java From iBioSim with Apache License 2.0 | 5 votes |
@Override public void stateChanged(ChangeEvent e) { JTabbedPane tabPane = (JTabbedPane) e.getSource(); tabPane.revalidate(); tabPane.repaint(); if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { int index = tabPane.getSelectedIndex(); if (index < rects.length && index != -1) { tabScroller.tabPanel.scrollRectToVisible(rects[index]); } } }
Example 11
Source File: SQLPanel.java From bigtable-sql with Apache License 2.0 | 5 votes |
public void stateChanged(ChangeEvent e) { JTabbedPane pane = (JTabbedPane)e.getSource(); int index = pane.getSelectedIndex(); if (index != -1) { fireExecuterTabActivated(_executors.get(index)); } }
Example 12
Source File: MSynthPainter.java From swift-k with Apache License 2.0 | 5 votes |
@Override public void paintTabbedPaneTabBackground(SynthContext context, Graphics g, int x, int y, int w, int h, int tabIndex, int orientation) { JTabbedPane t = (JTabbedPane) context.getComponent(); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (t.getSelectedIndex() == tabIndex) { g.setColor(BG); } else { g.setColor(INACTIVE); } g.fillRoundRect(x, y, w - 2, h, 5, 5); g.fillRect(x, y + 5, w - 2, h - 3); }
Example 13
Source File: MSynthPainter.java From swift-k with Apache License 2.0 | 5 votes |
@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 14
Source File: ExploreNodeAction.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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 15
Source File: AlignmentGui.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
private void calcDBSearch() { JTabbedPane tabPane = dbsearch.getTabPane(); System.out.println("run DB search " + tabPane.getSelectedIndex()); Structure s = null; boolean domainSplit = dbsearch.isDomainSplit(); StructurePairSelector tab = null; int pos = tabPane.getSelectedIndex(); if (pos == 0 ){ tab = dbsearch.getSelectPDBPanel(); } else if (pos == 1){ tab = dbsearch.getScopSelectPanel(); } else if (pos == 2){ tab = dbsearch.getPDBUploadPanel(); } try { s = tab.getStructure1(); if ( s == null) { JOptionPane.showMessageDialog(null,"please select structure 1"); return ; } } catch (Exception e){ e.printStackTrace(); } String name1 = s.getName(); if ( name1 == null || name1.equals("")) name1 = s.getPDBCode(); System.out.println("name1 in alig gui:" + name1); String file = dbsearch.getOutFileLocation(); if ( file == null || file.equals("") ){ JOptionPane.showMessageDialog(null,"Please select a directory to contain the DB search results."); return; } File outFile = new File(file); if( !outFile.exists() ) { outFile.mkdirs(); } if( !outFile.isDirectory() || !outFile.canWrite()) { JOptionPane.showMessageDialog(null,"Unable to write to "+outFile.getAbsolutePath()); return; } UserConfiguration config = WebStartMain.getWebStartConfig(); int totalNrCPUs = Runtime.getRuntime().availableProcessors(); int useNrCPUs = 1; if ( totalNrCPUs > 1){ Object[] options = new Integer[totalNrCPUs]; int posX = 0; for ( int i = totalNrCPUs; i> 0 ; i--){ options[posX] = i; posX++; } int n = JOptionPane.showOptionDialog(null, "How many would you like to use for the calculations?", "We detected " + totalNrCPUs + " processors on your system.", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if ( n < 0) return; useNrCPUs = (Integer) options[n]; System.out.println("will use " + useNrCPUs + " CPUs." ); } System.out.println("using domainSplit data"); alicalc = new AlignmentCalcDB(this, s, name1,config,file, domainSplit); alicalc.setNrCPUs(useNrCPUs); abortB.setEnabled(true); progress.setIndeterminate(true); ProgressThreadDrawer drawer = new ProgressThreadDrawer(progress); drawer.start(); Thread t = new Thread(alicalc); t.start(); }