Java Code Examples for javax.swing.plaf.TabbedPaneUI#tabForCoordinate()
The following examples show how to use
javax.swing.plaf.TabbedPaneUI#tabForCoordinate() .
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: ReportDesignerFrame.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private void handlePopup( final MouseEvent e ) { final JTabbedPane reportEditorPane = getReportEditorPane(); final TabbedPaneUI ui = reportEditorPane.getUI(); final int tabIndex = ui.tabForCoordinate( reportEditorPane, e.getX(), e.getY() ); final JPopupMenu popupMenu = new JPopupMenu(); final CloseReportAction closeThisAction = new CloseReportAction( tabIndex ); closeThisAction.setReportDesignerContext( getContext() ); final CloseChildReportsAction closeChildsAction = new CloseChildReportsAction( tabIndex ); closeChildsAction.setReportDesignerContext( getContext() ); final CloseOtherReportsAction closeOthersAction = new CloseOtherReportsAction( tabIndex ); closeOthersAction.setReportDesignerContext( getContext() ); final CloseAllReportsAction closeAllAction = new CloseAllReportsAction(); closeAllAction.setReportDesignerContext( getContext() ); final CloseUnmodifiedReportsAction closeUnmodifiedReportsAction = new CloseUnmodifiedReportsAction(); closeUnmodifiedReportsAction.setReportDesignerContext( getContext() ); popupMenu.add( new JMenuItem( closeThisAction ) ); popupMenu.addSeparator(); popupMenu.add( new JMenuItem( closeChildsAction ) ); popupMenu.add( new JMenuItem( closeUnmodifiedReportsAction ) ); popupMenu.add( new JMenuItem( closeOthersAction ) ); popupMenu.add( new JMenuItem( closeAllAction ) ); popupMenu.show( reportEditorPane, e.getX(), e.getY() ); }
Example 2
Source File: MergeDialogComponent.java From netbeans with Apache License 2.0 | 5 votes |
/** Called when the seqeunce of mouse events should lead to actual * showing of the popup menu. */ @Override protected void showPopup(java.awt.event.MouseEvent mouseEvent) { TabbedPaneUI tabUI = mergeTabbedPane.getUI(); int clickTab = tabUI.tabForCoordinate(mergeTabbedPane, mouseEvent.getX(), mouseEvent.getY()); MergePanel panel = getSelectedMergePanel(); if (panel == null) { return; } if (clickTab != -1) { //Click is on valid tab, not on empty area in tab showPopupMenu(createPopupMenu(panel), mouseEvent.getPoint(), mergeTabbedPane); } }
Example 3
Source File: DockableWindow.java From workcraft with MIT License | 5 votes |
@Override public void mouseClicked(MouseEvent e) { if ((e.getButton() == MouseEvent.BUTTON2) && (e.getSource() instanceof JTabbedPane)) { JTabbedPane tabbedPane = (JTabbedPane) e.getSource(); TabbedPaneUI ui = tabbedPane.getUI(); int tabIndex = ui.tabForCoordinate(tabbedPane, e.getX(), e.getY()); DockingUtils.closeTab(tabbedPane, tabIndex); } }
Example 4
Source File: TabbedPaneContentUI.java From consulo with Apache License 2.0 | 5 votes |
private void closeTabAt(int x, int y) { TabbedPaneUI ui = getUI(); int index = ui.tabForCoordinate(this, x, y); if (index < 0 || !myManager.canCloseContents()) { return; } final Content content = myManager.getContent(index); if (content != null && content.isCloseable()) { myManager.removeContent(content, true); } }
Example 5
Source File: TabbedPaneContentUI.java From consulo with Apache License 2.0 | 5 votes |
protected void processMouseEvent(MouseEvent e) { if (e.isPopupTrigger()) { // Popup doesn't activate clicked tab. showPopup(e.getX(), e.getY()); return; } if (!e.isShiftDown() && (MouseEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // RightClick without Shift modifiers just select tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { TabbedPaneUI ui = getUI(); int index = ui.tabForCoordinate(this, e.getX(), e.getY()); if (index != -1) { setSelectedIndex(index); } hideMenu(); } } else if (e.isShiftDown() && (MouseEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // Shift+LeftClick closes the tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { closeTabAt(e.getX(), e.getY()); hideMenu(); } } else if ((MouseEvent.BUTTON2_MASK & e.getModifiers()) > 0) { // MouseWheelClick closes the tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { closeTabAt(e.getX(), e.getY()); hideMenu(); } } else if ((MouseEvent.BUTTON3_MASK & e.getModifiers()) > 0 && SystemInfo.isWindows) { // Right mouse button doesn't activate tab } else { super.processMouseEvent(e); } }
Example 6
Source File: TabbedPaneContentUI.java From consulo with Apache License 2.0 | 5 votes |
/** * @return content at the specified location. <code>x</code> and <code>y</code> are in * tabbed pane coordinate system. The method returns <code>null</code> if there is no contnt at the * specified location. */ private Content getContentAt(int x, int y) { TabbedPaneUI ui = getUI(); int index = ui.tabForCoordinate(this, x, y); if (index < 0) { return null; } return myManager.getContent(index); }