javax.swing.plaf.TabbedPaneUI Java Examples

The following examples show how to use javax.swing.plaf.TabbedPaneUI. 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: KseFrame.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private void maybeShowKeyStoreTabPopup(MouseEvent evt) {
	if (evt.isPopupTrigger()) {
		int tabCount = jkstpKeyStores.getTabCount();
		TabbedPaneUI tpu = jkstpKeyStores.getUI();

		for (int i = 0; i < tabCount; i++) {
			Rectangle rect = tpu.getTabBounds(jkstpKeyStores, i);

			int x = evt.getX();
			int y = evt.getY();

			if (x < rect.x || x > rect.x + rect.width || y < rect.y || y > rect.y + rect.height) {
				continue;
			}

			jpmKeyStoreTab.show(evt.getComponent(), evt.getX(), evt.getY());
			break;
		}
	}
}
 
Example #2
Source File: WTabbedPaneInputListener.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Moves {@link JTabbedPane} scrollable tabs view according to scroll amount.
 *
 * @param tabbedPane   {@link JTabbedPane}
 * @param scrollAmount either positive or negative blocks scroll amount
 */
protected void scroll ( final T tabbedPane, final int scrollAmount )
{
    final TabbedPaneUI ui = tabbedPane.getUI ();
    if ( ui instanceof WTabbedPaneUI )
    {
        final TabContainer tabContainer = ( ( WTabbedPaneUI ) ui ).getTabContainer ();
        if ( tabContainer != null )
        {
            final boolean horizontal = tabbedPane.getTabPlacement () == JTabbedPane.TOP ||
                    tabbedPane.getTabPlacement () == JTabbedPane.BOTTOM;
            final Rectangle vr = tabContainer.getVisibleRect ();
            final Rectangle bounds = new Rectangle ( tabContainer.getSize () );
            if ( horizontal )
            {
                vr.x += scrollAmount * vr.width;
            }
            else
            {
                vr.y += scrollAmount * vr.height;
            }
            tabContainer.scrollRectToVisible ( bounds.intersection ( vr ) );
        }
    }
}
 
Example #3
Source File: ReportDesignerFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #4
Source File: MultiTabbedPaneUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}
 
Example #5
Source File: MultiTabbedPaneUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabBounds</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle getTabBounds(JTabbedPane a, int b) {
    Rectangle returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabBounds(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabBounds(a,b);
    }
    return returnValue;
}
 
Example #6
Source File: MultiTabbedPaneUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}
 
Example #7
Source File: DockableWindow.java    From workcraft with MIT License 5 votes vote down vote up
@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 #8
Source File: MultiTabbedPaneUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int tabForCoordinate(JTabbedPane a, int b, int c) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c);
    }
    return returnValue;
}
 
Example #9
Source File: TabbedPaneContentUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #10
Source File: MultiTabbedPaneUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int tabForCoordinate(JTabbedPane a, int b, int c) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c);
    }
    return returnValue;
}
 
Example #11
Source File: MultiTabbedPaneUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabBounds</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle getTabBounds(JTabbedPane a, int b) {
    Rectangle returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabBounds(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabBounds(a,b);
    }
    return returnValue;
}
 
Example #12
Source File: TabbedPaneContentUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #13
Source File: TabbedPaneContentUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #14
Source File: TabbedPaneImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setUI(final TabbedPaneUI ui){
  super.setUI(ui);
  if(ui instanceof BasicTabbedPaneUI){
    myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui);
  }else{
    myScrollableTabSupport=null;
  }
}
 
Example #15
Source File: TabbedPaneImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected final int getTabIndexAt(final int x,final int y){
  final TabbedPaneUI ui=getUI();
  for (int i = 0; i < getTabCount(); i++) {
    final Rectangle bounds = ui.getTabBounds(this, i);
    if (bounds.contains(x, y)) {
      return i;
    }
  }
  return -1;
}
 
Example #16
Source File: MultiTabbedPaneUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}
 
Example #17
Source File: MultiTabbedPaneUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}
 
Example #18
Source File: MultiTabbedPaneUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int tabForCoordinate(JTabbedPane a, int b, int c) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c);
    }
    return returnValue;
}
 
Example #19
Source File: MultiTabbedPaneUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}
 
Example #20
Source File: MultiTabbedPaneUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabBounds</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle getTabBounds(JTabbedPane a, int b) {
    Rectangle returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabBounds(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabBounds(a,b);
    }
    return returnValue;
}
 
Example #21
Source File: MultiTabbedPaneUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int tabForCoordinate(JTabbedPane a, int b, int c) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c);
    }
    return returnValue;
}
 
Example #22
Source File: MultiTabbedPaneUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}
 
Example #23
Source File: MultiTabbedPaneUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabBounds</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle getTabBounds(JTabbedPane a, int b) {
    Rectangle returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabBounds(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabBounds(a,b);
    }
    return returnValue;
}
 
Example #24
Source File: MultiTabbedPaneUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int tabForCoordinate(JTabbedPane a, int b, int c) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c);
    }
    return returnValue;
}
 
Example #25
Source File: MultiTabbedPaneUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}
 
Example #26
Source File: MultiTabbedPaneUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabBounds</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle getTabBounds(JTabbedPane a, int b) {
    Rectangle returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabBounds(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabBounds(a,b);
    }
    return returnValue;
}
 
Example #27
Source File: MultiTabbedPaneUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int tabForCoordinate(JTabbedPane a, int b, int c) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c);
    }
    return returnValue;
}
 
Example #28
Source File: JTabbedPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTabbedPane.setUI(TabbedPaneUI)} through queue
 */
public void setUI(final TabbedPaneUI tabbedPaneUI) {
    runMapping(new MapVoidAction("setUI") {
        @Override
        public void map() {
            ((JTabbedPane) getSource()).setUI(tabbedPaneUI);
        }
    });
}
 
Example #29
Source File: TabbedPaneTransferHandler.java    From darklaf with MIT License 5 votes vote down vote up
private DarkTabbedPaneUI supportsIndicator(final Component c) {
    if (c instanceof JTabbedPane) {
        TabbedPaneUI ui = ((JTabbedPane) c).getUI();
        if (ui instanceof DarkTabbedPaneUI) {
            return ((DarkTabbedPaneUI) ui);
        }
    }
    return null;
}
 
Example #30
Source File: MultiTabbedPaneUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getTabRunCount</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getTabRunCount(JTabbedPane a) {
    int returnValue =
        ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a);
    }
    return returnValue;
}