javax.swing.JTabbedPane.indexAtLocation()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中javax.swing.JTabbedPane.indexAtLocation()方法的一些代码示例,展示了JTabbedPane.indexAtLocation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTabbedPane.indexAtLocation()方法的具体详情如下:
包路径:javax.swing.JTabbedPane
类名称:JTabbedPane
方法名:indexAtLocation

JTabbedPane.indexAtLocation介绍

暂无

代码示例

代码示例来源:origin: ron190/jsql-injection

@Override
  public void mouseClicked(MouseEvent e) {
    Point tabPt = e.getPoint();
    JTabbedPane src = (JTabbedPane) e.getSource();
    
    int i = src.indexAtLocation(tabPt.x, tabPt.y);
    
    if (-1 < i && e.getButton() == MouseEvent.BUTTON2) {
      ActionCloseTabResult.perform(i);
    }
  }
}

代码示例来源:origin: tulskiy/musique

@Override
public void mousePressed(MouseEvent e) {
  dragFrom = tabbedPane.indexAtLocation(e.getX(), e.getY());
}

代码示例来源:origin: tulskiy/musique

public void show(MouseEvent e) {
    if (e.isPopupTrigger()) {
      int index = tabbedPane.indexAtLocation(e.getX(), e.getY());
      if (index != -1)
        tabbedPane.setSelectedIndex(index);
      buildPopupMenu().show(e.getComponent(), e.getX(), e.getY());
    }
  }
});

代码示例来源:origin: tulskiy/musique

@Override
public void mouseDragged(MouseEvent e) {
  dragTo = tabbedPane.indexAtLocation(e.getX(), e.getY());
  repaint();
}

代码示例来源:origin: chatty/chatty

/**
 * Open context menu manually instead of relying on the JTabbedPane, so we
 * can check if it's the currently selected tab (since the context menu will
 * trigger actions based on the currently selected tab).
 * 
 * @param e 
 */
private void openPopupMenu(MouseEvent e) {
  if (!e.isPopupTrigger()) {
    return;
  }
  if (popupMenu == null) {
    return;
  }
  final int index = tabs.indexAtLocation(e.getX(), e.getY());
  if (tabs.getSelectedIndex() == index) {
    popupMenu.show(tabs, e.getX(), e.getY());
  }
}

代码示例来源:origin: tulskiy/musique

@Override
  public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 &&
        e.getClickCount() == 2) {
      tabbedPane.getActionMap().get("newPlaylist").actionPerformed(
          new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null));
    } else if (e.getButton() == MouseEvent.BUTTON2) {
      int index = tabbedPane.indexAtLocation(e.getX(), e.getY());
      if (index != -1) {
        Playlist playlist = getTableAt(index).getPlaylist();
        playlistManager.removePlaylist(playlist);
      }
    }
  }
});

代码示例来源:origin: de.richtercloud/flexdock-core

@Override
public void mousePressed(MouseEvent me) {
  if(!(me.getSource() instanceof JTabbedPane)) {
    dragListener = null;
    return;
  }
  JTabbedPane pane = (JTabbedPane)me.getSource();
  Point p = me.getPoint();
  int tabIndex = pane.indexAtLocation(p.x, p.y);
  if(tabIndex==-1) {
    dragListener = null;
    return;
  }
  Dockable dockable = DockingManager.getDockable(pane.getComponentAt(tabIndex));
  dragListener = DockingManager.getDragListener(dockable);
  if(dragListener!=null) {
    dragListener.mousePressed(me);
  }
}

代码示例来源:origin: stackoverflow.com

public void mouseClicked(MouseEvent e) {
  JTabbedPane jp=(JTabbedPane)(e.getComponent().getParent().getParent());
  jp.setSelectedIndex(jp.indexAtLocation(e.getComponent().getX(),e.getComponent().getY()));

代码示例来源:origin: chatty/chatty

@Override
  public void mouseWheelMoved(MouseWheelEvent e) {
    if (mouseWheelScrolling) {
      // Only scroll if actually on tabs area
      int index = tabs.indexAtLocation(e.getX(), e.getY());
      if (mouseWheelScrollingAnywhere || index != -1
          || isNearLastTab(e.getPoint())) {
        if (e.getWheelRotation() < 0) {
          setSelectedPrevious();
        } else if (e.getWheelRotation() > 0) {
          setSelectedNext();
        }
      }
    }
  }
});

代码示例来源:origin: cmu-phil/tetrad

public void mouseClicked(MouseEvent e) {
    super.mouseClicked(e);
    if (SwingUtilities.isRightMouseButton(e)) {
      Point point = e.getPoint();
      final int index = tabbedPane().indexAtLocation(point.x, point.y);
      if (index == -1) {
        return;
      }
      JPopupMenu menu = new JPopupMenu();
      JMenuItem close = new JMenuItem("Close Tab");
      menu.add(close);
      menu.show(DataEditor.this, point.x, point.y);
      close.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          closeTab();
          DataEditor.this.grabFocus();
          firePropertyChange("modelChanged", null, null);
        }
      });
    } else if (SwingUtilities.isLeftMouseButton(e)) {
      DataModel selectedModel = getSelectedDataModel();
      getDataWrapper().getDataModelList().setSelectedModel(selectedModel);
      firePropertyChange("modelChanged", null, null);
    }
  }
});

代码示例来源:origin: com.fifesoft.rtext/fife.common

int tab = tabbedPane.indexAtLocation(
        mouseLocation.x,mouseLocation.y);

代码示例来源:origin: stackoverflow.com

pt.setLocation(e.getPoint());
 JTabbedPane tabbedPane = (JTabbedPane) l.getView();
 int index = tabbedPane.indexAtLocation(pt.x, pt.y);
 if (index >= 0) {
  Rectangle rect = tabbedPane.getBoundsAt(index);
pt.setLocation(e.getPoint());
JTabbedPane t = (JTabbedPane) l.getView();
if (t.indexAtLocation(pt.x, pt.y) >= 0) {
 Point loc = e.getPoint();
 loc.translate(-16, -16);

代码示例来源:origin: stackoverflow.com

pt.setLocation(e.getPoint());
 JTabbedPane tabbedPane = (JTabbedPane) l.getView();
 int index = tabbedPane.indexAtLocation(pt.x, pt.y);
 if (index >= 0) {
  Rectangle rect = tabbedPane.getBoundsAt(index);
pt.setLocation(e.getPoint());
JTabbedPane tabbedPane = (JTabbedPane) l.getView();
int index = tabbedPane.indexAtLocation(pt.x, pt.y);
if (index >= 0) {
 tabbedPane.repaint(tabbedPane.getBoundsAt(index));

代码示例来源:origin: stackoverflow.com

@Override public void mouseClicked(MouseEvent e) {
 pt.setLocation(e.getPoint());
 int index = tabbedPane.indexAtLocation(pt.x, pt.y);
 if (index >= 0) {
  Rectangle tabRect = tabbedPane.getBoundsAt(index);
 int index = tabbedPane.indexAtLocation(pt.x, pt.y);
 if (index >= 0) {
  tabbedPane.repaint(tabbedPane.getBoundsAt(index));

代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql

@Override
  public void dragGestureRecognized(DragGestureEvent e)
  {
//      if (_dnDTabbedPaneData.getTabbedPane().getTabCount() <= 1)
//      {
//         return;
//      }

   Point tabPt = e.getDragOrigin();
   _dnDTabbedPaneData.setDragTabIndex(_dnDTabbedPaneData.getTabbedPane().indexAtLocation(tabPt.x, tabPt.y));
   //"disabled tab problem".
   if (_dnDTabbedPaneData.getDragTabIndex() < 0 || !_dnDTabbedPaneData.getTabbedPane().isEnabledAt(_dnDTabbedPaneData.getDragTabIndex())) return;
   DndTabUtils.initGlassPaneLocal(e.getDragOrigin(), _dnDTabbedPaneData, _glassPane);
   try
   {
     e.startDrag(DragSource.DefaultMoveDrop, _t, _dsl);
   }
   catch (InvalidDnDOperationException idoe)
   {
     idoe.printStackTrace();
   }
  }

代码示例来源:origin: igniterealtime/Spark

dragTabIndex = pane.indexAtLocation(event.getDragOrigin().x, event.getDragOrigin().y);
try {
event.startDrag(DragSource.DefaultMoveDrop, t, dsl);

代码示例来源:origin: realXuJiang/bigtable-sql

@Override
  public void dragGestureRecognized(DragGestureEvent e)
  {
//      if (_dnDTabbedPaneData.getTabbedPane().getTabCount() <= 1)
//      {
//         return;
//      }

   Point tabPt = e.getDragOrigin();
   _dnDTabbedPaneData.setDragTabIndex(_dnDTabbedPaneData.getTabbedPane().indexAtLocation(tabPt.x, tabPt.y));
   //"disabled tab problem".
   if (_dnDTabbedPaneData.getDragTabIndex() < 0 || !_dnDTabbedPaneData.getTabbedPane().isEnabledAt(_dnDTabbedPaneData.getDragTabIndex())) return;
   DndTabUtils.initGlassPaneLocal(e.getDragOrigin(), _dnDTabbedPaneData, _glassPane);
   try
   {
     e.startDrag(DragSource.DefaultMoveDrop, _t, _dsl);
   }
   catch (InvalidDnDOperationException idoe)
   {
     idoe.printStackTrace();
   }
  }

相关文章

JTabbedPane类方法