类javax.swing.plaf.metal.MetalTabbedPaneUI源码实例Demo

下面列出了怎么用javax.swing.plaf.metal.MetalTabbedPaneUI的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: java-swing-tips   文件: MainPanel.java
@Override public void mouseDragged(MouseEvent e) {
  Point tabPt = e.getPoint(); // e.getDragOrigin();
  if (Objects.nonNull(startPt) && startPt.distance(tabPt) > gestureMotionThreshold) {
    DnDTabbedPane src = (DnDTabbedPane) e.getComponent();
    TransferHandler th = src.getTransferHandler();
    // When a tab runs rotation occurs, a tab that is not the target is dragged.
    // pointed out by Arjen
    int idx = src.indexAtLocation(tabPt.x, tabPt.y);
    int selIdx = src.getSelectedIndex();
    boolean isRotateTabRuns = !(src.getUI() instanceof MetalTabbedPaneUI)
        && src.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT
        && idx != selIdx;
    dragTabIndex = isRotateTabRuns ? selIdx : idx;
    th.exportAsDrag(src, e, TransferHandler.MOVE);
    startPt = null;
  }
}
 
源代码2 项目: java-swing-tips   文件: MainPanel.java
@Override public void dragGestureRecognized(DragGestureEvent e) {
  Optional.ofNullable(e.getComponent())
      .filter(c -> c instanceof DnDTabbedPane).map(c -> (DnDTabbedPane) c)
      .filter(tabbedPane -> tabbedPane.getTabCount() > 1)
      .ifPresent(tabbedPane -> {
        Point tabPt = e.getDragOrigin();
        int idx = tabbedPane.indexAtLocation(tabPt.x, tabPt.y);
        int selIdx = tabbedPane.getSelectedIndex();
        // When a tab runs rotation occurs, a tab that is not the target is dragged.
        // pointed out by Arjen
        boolean isTabRunsRotated = !(tabbedPane.getUI() instanceof MetalTabbedPaneUI)
            && tabbedPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT
            && idx != selIdx;
        tabbedPane.dragTabIndex = isTabRunsRotated ? selIdx : idx;
        if (tabbedPane.dragTabIndex >= 0 && tabbedPane.isEnabledAt(tabbedPane.dragTabIndex)) {
          tabbedPane.initGlassPane(tabPt);
          try {
            e.startDrag(DragSource.DefaultMoveDrop, new TabTransferable(tabbedPane), new TabDragSourceListener());
          } catch (InvalidDnDOperationException ex) {
            throw new IllegalStateException(ex);
          }
        }
      });
}
 
源代码3 项目: java-swing-tips   文件: MainPanel.java
@Override public void mouseDragged(MouseEvent e) {
  Point tabPt = e.getPoint(); // e.getDragOrigin();
  if (Objects.nonNull(startPt) && startPt.distance(tabPt) > gestureMotionThreshold) {
    DnDTabbedPane src = (DnDTabbedPane) e.getComponent();
    TransferHandler th = src.getTransferHandler();
    // When a tab runs rotation occurs, a tab that is not the target is dragged.
    // pointed out by Arjen
    int idx = src.indexAtLocation(tabPt.x, tabPt.y);
    int selIdx = src.getSelectedIndex();
    boolean isRotateTabRuns = !(src.getUI() instanceof MetalTabbedPaneUI)
        && src.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT
        && idx != selIdx;
    dragTabIndex = isRotateTabRuns ? selIdx : idx;
    th.exportAsDrag(src, e, TransferHandler.MOVE);
    RECT_LINE.setBounds(0, 0, 0, 0);
    src.getRootPane().getGlassPane().setVisible(true);
    src.updateTabDropLocation(new DnDTabbedPane.DropLocation(tabPt, -1), null, true);
    startPt = null;
  }
}
 
源代码4 项目: SikuliX1   文件: CloseableTabbedPane.java
public CloseableTabbedPane() {
  super();
  listenerList = new EventListenerList();
  addMouseListener(this);
  addMouseMotionListener(this);
  if (getUI() instanceof MetalTabbedPaneUI) {
    setUI(new CloseableMetalTabbedPaneUI(SwingUtilities.LEFT));
  }
  popMenuTab = new SikuliIDEPopUpMenu("POP_TAB", this);
  if (!popMenuTab.isValidMenu()) {
    popMenuTab = null;
  }
}
 
源代码5 项目: ramus   文件: CloseableTabbedPane.java
/**
 * Initializes the <code>CloseableTabbedPane</code>
 *
 * @param horizontalTextPosition the horizontal position of the text (e.g.
 *                               SwingUtilities.TRAILING or SwingUtilities.LEFT)
 */
private void init(int horizontalTextPosition) {
    listenerList = new EventListenerList();
    addMouseListener(this);
    addMouseMotionListener(this);

    if (getUI() instanceof MetalTabbedPaneUI)
        setUI(new CloseableMetalTabbedPaneUI(horizontalTextPosition));
    else
        setUI(new CloseableTabbedPaneUI(horizontalTextPosition));
}
 
 类所在包
 同包方法