private boolean isTabInForeground(OpenFile open) { String title = open.name; int selectedIndex = house.getSelectedIndex(); return (selectedIndex >= 0 && selectedIndex == house.indexOfTab(title)); }
@Override public void actionPerformed(ActionEvent e) { closeOpenTab(house.getSelectedIndex()); }
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setBounds(0, 0, 300, 400); frame.setLayout(null); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("One", new JPanel()); tabbedPane.addTab("Two", new JPanel()); tabbedPane.addTab("Three", new JPanel()); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Tab: " + tabbedPane.getSelectedIndex()); } }); tabbedPane.setBounds(0, 0, 300, 400); frame.add(tabbedPane); frame.setVisible(true); }
@Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isMiddleMouseButton(e)) { closeOpenTab(house.getSelectedIndex()); } } });
@Override public void actionPerformed(ActionEvent e) { // Remove the selected tab pane if it's not the Smack info pane if (tabbedPane.getSelectedIndex() < tabbedPane.getComponentCount() - 1) { int index = tabbedPane.getSelectedIndex(); // Notify to the debugger to stop debugging EnhancedDebugger debugger = debuggers.get(index); debugger.cancel(); // Remove the debugger from the root window tabbedPane.remove(debugger.tabbedPane); debuggers.remove(debugger); // Update the root window title frame.setTitle( "Smack Debug Window -- Total connections: " + (tabbedPane.getComponentCount() - 1)); } } });
public String getCurrentTabTitle() { String tabTitle = null; try { int pos = house.getSelectedIndex(); if (pos >= 0) { tabTitle = house.getTitleAt(pos); } } catch (Exception e1) { Luyten.showExceptionDialog("Exception!", e1); } if (tabTitle == null) { getLabel().setText("No open tab"); } return tabTitle; }
@Override public void stateChanged(ChangeEvent e) { int selectedIndex = house.getSelectedIndex(); if (selectedIndex < 0) { return; } for (OpenFile open : hmap) { if (house.indexOfTab(open.name) == selectedIndex) { if (open.getType() != null && !open.isContentValid()) { updateOpenClass(open); break; } } } } }
public RSyntaxTextArea getCurrentTextArea() { RSyntaxTextArea currentTextArea = null; try { int pos = house.getSelectedIndex(); System.out.println(pos); if (pos >= 0) { RTextScrollPane co = (RTextScrollPane) house.getComponentAt(pos); currentTextArea = (RSyntaxTextArea) co.getViewport().getView(); } } catch (Exception e1) { Luyten.showExceptionDialog("Exception!", e1); } if (currentTextArea == null) { getLabel().setText("No open tab"); } return currentTextArea; }
@Override public void actionPerformed(ActionEvent e) { JTabbedPane house = mainWindow.getModel().house; if (e.getModifiers() != 2 || house.getTabCount() == 0) mainWindow.onCloseFileMenu(); else { mainWindow.getModel().closeOpenTab(house.getSelectedIndex()); } } });
@Override public void actionPerformed(ActionEvent e) { if (valuesTabbedPane.getTabCount() > 0) { int selectedIndex = valuesTabbedPane.getSelectedIndex(); if (selectedIndex + 1 < valuesTabbedPane.getTabCount()) { valuesTabbedPane.setSelectedIndex(selectedIndex + 1); } else { valuesTabbedPane.setSelectedIndex(0); } } } };
@Override public void actionPerformed(ActionEvent e) { if (valuesTabbedPane.getTabCount() > 0) { int selectedIndex = valuesTabbedPane.getSelectedIndex(); if (selectedIndex - 1 > -1) { valuesTabbedPane.setSelectedIndex(selectedIndex - 1); } else { valuesTabbedPane.setSelectedIndex(valuesTabbedPane.getTabCount() - 1); } } } };
@Override public void mouseWheelMoved(MouseWheelEvent e) { JTabbedPane tabPane = (JTabbedPane) e.getSource(); int dir = -e.getWheelRotation(); int selIndex = tabPane.getSelectedIndex(); int maxIndex = tabPane.getTabCount() - 1; if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) { selIndex = maxIndex - selIndex; } else { selIndex += dir; } if (0 <= selIndex && selIndex < tabPane.getTabCount()) { // Fix #54575: NullPointerException on setSelectedIndex() try { tabPane.setSelectedIndex(selIndex); } catch (NullPointerException err) { LOGGER.error(err, err); } } }
protected DnDTabbedPane() { super(); Handler h = new Handler(); this.addMouseListener(h); this.addMouseMotionListener(h); this.addPropertyChangeListener(h); this.addMouseWheelListener(mouseWheelEvent -> { JTabbedPane tabPane = (JTabbedPane) mouseWheelEvent.getSource(); int dir = -mouseWheelEvent.getWheelRotation(); int selIndex = tabPane.getSelectedIndex(); int maxIndex = tabPane.getTabCount() - 1; if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) { selIndex = maxIndex - selIndex; } else { selIndex += dir; } if (0 <= selIndex && selIndex < tabPane.getTabCount()) { tabPane.setSelectedIndex(selIndex); } }); // UIManager.put() is not enough this.setUI(new CustomMetalTabbedPaneUI()); this.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, HelperUi.COLOR_COMPONENT_BORDER)); }
if (tabs.getSelectedIndex() > -1) { Component currentTabHeader = tabs.getTabComponentAt(tabs.getSelectedIndex()); if (currentTabHeader != null) { currentTabHeader.setFont(currentTabHeader.getFont().deriveFont(Font.PLAIN));
@Override public void actionPerformed (ActionEvent e) { int tabIndex = stubsPane.getSelectedIndex(); if (tabIndex > 0) { stubsPane.setSelectedIndex(tabIndex - 1); } }
public void setSelectedPrevious() { int index = tabs.getSelectedIndex(); int count = tabs.getTabCount(); if (count > 0) { if (index-1 >= 0) { tabs.setSelectedIndex(index-1); } else { tabs.setSelectedIndex(count -1); } } }
private void updateStatsPanelIfVisible() { int index = inputTabbedPane.getSelectedIndex(); if (index < 0) return; if (inputTabbedPane.getComponent(index) == statsPanel) { statsPanel.refresh(); } }
@Override public byte[] getRequest() { switch (tabs.getSelectedIndex()) { case 0: return currentOriginalRequestResponse.getRequest(); case 1: return currentModifiedRequestResponse.getRequest(); default: return new byte[0]; } }
@Override public void actionPerformed(ActionEvent e) { int tab = tp.getSelectedIndex(); if (tab < 0) tab = 0; JFileChooser fileChooser = new MyFileChooser(); fileChooser.setFileFilter(new FileNameExtensionFilter("Comma Separated Values", "csv")); new SaveAsHelper(ValueTableDialog.this, fileChooser, "csv") .checkOverwrite(resultTableData.get(tab)::saveCSV); } }.setToolTip(Lang.get("menu_saveData_tt")).createJMenuItem());
@Override public void actionPerformed(ActionEvent actionEvent) { int tab = tp.getSelectedIndex(); if (tab < 0) tab = 0; new GraphDialog(ValueTableDialog.this, Lang.get("win_testdata_N", tp.getTitleAt(tab)), resultTableData.get(tab)) .disableTable() .setVisible(true); } }.setToolTip(Lang.get("menu_showDataAsGraph_tt"));