本文整理了Java中javax.swing.JTabbedPane.getBoundsAt()
方法的一些代码示例,展示了JTabbedPane.getBoundsAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTabbedPane.getBoundsAt()
方法的具体详情如下:
包路径:javax.swing.JTabbedPane
类名称:JTabbedPane
方法名:getBoundsAt
暂无
代码示例来源:origin: com.fifesoft.rtext/fife.common
public Rectangle getTabBounds() {
return transferData.sourceTabbedPane.
getBoundsAt(transferData.tabIndex);
}
代码示例来源:origin: chatty/chatty
private boolean isNearLastTab(Point p) {
Rectangle bounds = tabs.getBoundsAt(tabs.getTabCount() - 1);
bounds.width += 99999;
return bounds.contains(p);
}
代码示例来源:origin: stackoverflow.com
private static int findTabPaneIndex(Point p, JTabbedPane tabbedPane) {
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
if (tabbedPane.getBoundsAt(i).contains(p.x, p.y)) {
return i;
}
}
return -1;
}
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
private int findTabAt(Point p) {
int x = p.x;
int y = p.y;
for(int i = 0; i < tabbedPane.getTabCount(); i++) {
Rectangle bounds = tabbedPane.getBoundsAt(i);
if(bounds != null && bounds.contains(x, y)) {
return i;
}
}
return - 1;
}
代码示例来源:origin: net.java.abeille/abeille
private boolean isTabClicked(MouseEvent e) {
Point local_pt = SwingUtilities.convertPoint((Component) e.getSource(), e.getPoint(), m_tabpane);
for (int index = 0; index < m_tabpane.getTabCount(); index++) {
java.awt.Rectangle rect = m_tabpane.getBoundsAt(index);
if (rect.contains(local_pt)) {
m_tabpane.setSelectedIndex(index);
return true;
}
}
return false;
}
代码示例来源:origin: org.openspml/openspml
/**
* Determine which JTabbedPane tab is under a certain location.
* Useful if you want to tell the difference between a menu
* over a tab, and one over blank space.
* Can also be used to popup tab specific menus, but since right
* click selects the tab you can just use the current tab.
*/
public static int getTabIndex(JTabbedPane tabs, Point point) {
int index = -1;
for (int i = 0 ; i < tabs.getTabCount() ; i++) {
Rectangle rec = tabs.getBoundsAt(i);
if (rec.contains(point)) {
index = i;
break;
}
}
return index;
}
代码示例来源:origin: tulskiy/musique
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (dragTo != -1 && dragFrom != -1 && dragTo != dragFrom) {
Rectangle b = tabbedPane.getBoundsAt(dragTo);
g.setColor(Color.GRAY);
int x = (int) (b.getX());
if (dragTo > dragFrom)
x += b.getWidth();
int y = (int) b.getY();
g.fillRect(x - 1, y + 2, 3, (int) b.getHeight() - 2);
int[] xP = {x - 1, x - 5, x + 5, x + 1};
int[] yP = {y + 2, y - 5, y - 5, y + 2};
g.fillPolygon(xP, yP, xP.length);
}
}
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
/** MouseListener implementation, use to track mouse behaviour inside the tab selector bounds
* and forward them to the appropriate smart icon.
*/
public void mouseReleased(MouseEvent e) {
checkTabCount();
// forward the event to the pressed smart icon
if(pressedIcon != null) {
Point p = e.getPoint();
final Rectangle r = tabbedPane.getBoundsAt(pressedTab);
if (r == null) {
return;
}
Point iPoint = convertPointToIcon(r, p, pressedIcon);
final MouseEvent eSmart = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), iPoint.x, iPoint.y, e.getClickCount(), e.isPopupTrigger(), e.getButton());
try {
if(pressedIcon.onMouseReleased(eSmart)) {
tabbedPane.repaint(r.x, r.y, r.width, r.height); // no choice but trigger a repaint
}
} catch(Exception ignore) { // bug database : 5075526 this is to remove the stack trace
}
pressedIcon = null;
}
}
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
Rectangle r = tabbedPane.getBoundsAt(targetTab);
if (r == null) {
return;
代码示例来源:origin: igniterealtime/Spark
private int getTargetTabIndex(Point point) {
Point tabPt = SwingUtilities.convertPoint(pane, point, pane);
boolean isTB = pane.getTabPlacement()==JTabbedPane.TOP || pane.getTabPlacement()==JTabbedPane.BOTTOM;
for(int i=0;i < getTabCount();i++) {
Rectangle r = pane.getBoundsAt(i);
if(isTB) r.setRect(r.x-r.width/2, r.y, r.width, r.height);
else r.setRect(r.x, r.y-r.height/2, r.width, r.height);
if(r.contains(tabPt)) return i;
}
Rectangle r = pane.getBoundsAt(getTabCount()-1);
if(isTB) r.setRect(r.x+r.width/2, r.y, r.width, r.height);
else r.setRect(r.x, r.y+r.height/2, r.width, r.height);
return r.contains(tabPt)?getTabCount():-1;
}
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
/** MouseListener implementation, use to track mouse behaviour inside the tab selector bounds
* and forward them to the appropriate smart icon.
*/
public void mouseExited(MouseEvent e) {
checkTabCount();
if(movedIcon != null) {
Point p = e.getPoint();
// trigger a mouseExit from the movedIcon
Rectangle prevRect = tabbedPane.getBoundsAt(movedTab);
if (prevRect == null) {
return;
}
Point iPoint = convertPointToIcon(prevRect, p, movedIcon);
MouseEvent eSmart = new MouseEvent((Component) e.getSource(), MouseEvent.MOUSE_EXITED, e.getWhen(), e.getModifiers(), iPoint.x, iPoint.y, e.getClickCount(), e.isPopupTrigger(), e.getButton());
if(movedIcon.onMouseExited(eSmart)) {
String tip = movedIcon.getLocalTooltipText();
if(tip != null && ! tip.equals(tabbedPane.getToolTipTextAt(movedTab))) {
tabbedPane.setToolTipTextAt(movedTab, tip);
}
tabbedPane.repaint(prevRect.x, prevRect.y, prevRect.width, prevRect.height);
}
movedIcon = null;
movedTab = - 1;
}
}
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
static int getTargetTabIndex(Point glassPt, GhostGlassPane glassPane, JTabbedPane tabbedPane)
{
if(0 == tabbedPane.getTabCount())
{
return 0;
}
Point tabPt = SwingUtilities.convertPoint(glassPane, glassPt, tabbedPane);
boolean isTB = tabbedPane.getTabPlacement() == JTabbedPane.TOP || tabbedPane.getTabPlacement() == JTabbedPane.BOTTOM;
for (int i = 0; i < tabbedPane.getTabCount(); i++)
{
Rectangle r = tabbedPane.getBoundsAt(i);
if (isTB) r.setRect(r.x - r.width / 2, r.y, r.width, r.height);
else r.setRect(r.x, r.y - r.height / 2, r.width, r.height);
if (r.contains(tabPt)) return i;
}
Rectangle r = tabbedPane.getBoundsAt(tabbedPane.getTabCount() - 1);
if (isTB) r.setRect(r.x + r.width / 2, r.y, r.width, r.height);
else r.setRect(r.x, r.y + r.height / 2, r.width, r.height);
return r.contains(tabPt) ? tabbedPane.getTabCount() : -1;
}
代码示例来源:origin: realXuJiang/bigtable-sql
static int getTargetTabIndex(Point glassPt, GhostGlassPane glassPane, JTabbedPane tabbedPane)
{
if(0 == tabbedPane.getTabCount())
{
return 0;
}
Point tabPt = SwingUtilities.convertPoint(glassPane, glassPt, tabbedPane);
boolean isTB = tabbedPane.getTabPlacement() == JTabbedPane.TOP || tabbedPane.getTabPlacement() == JTabbedPane.BOTTOM;
for (int i = 0; i < tabbedPane.getTabCount(); i++)
{
Rectangle r = tabbedPane.getBoundsAt(i);
if (isTB) r.setRect(r.x - r.width / 2, r.y, r.width, r.height);
else r.setRect(r.x, r.y - r.height / 2, r.width, r.height);
if (r.contains(tabPt)) return i;
}
Rectangle r = tabbedPane.getBoundsAt(tabbedPane.getTabCount() - 1);
if (isTB) r.setRect(r.x + r.width / 2, r.y, r.width, r.height);
else r.setRect(r.x, r.y + r.height / 2, r.width, r.height);
return r.contains(tabPt) ? tabbedPane.getTabCount() : -1;
}
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
private void initTargetTopBottomLine(int next)
{
// if (next < 0 || _dnDTabbedPaneData.getDragTabIndex() == next || next - _dnDTabbedPaneData.getDragTabIndex() == 1)
if (next < 0 || _dnDTabbedPaneData.getTabbedPane().getTabCount() < next)
{
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(0, 0, 0, 0);
}
else if (next == 0)
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(0), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x, r.y - DndTabUtils.LINEWIDTH / 2, r.width, DndTabUtils.LINEWIDTH);
}
else
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(next - 1), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x, r.y + r.height - DndTabUtils.LINEWIDTH / 2, r.width, DndTabUtils.LINEWIDTH);
}
}
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
static void initGlassPane(Point tabPt, DnDTabbedPaneData localDnDTabbedPaneData, DnDTabbedPaneData outerDnDTabbedPaneData, GhostGlassPane localGlassPane)
{
localDnDTabbedPaneData.getTabbedPane().getRootPane().setGlassPane(localGlassPane);
if (localDnDTabbedPaneData.isHasGhost())
{
Rectangle rect = outerDnDTabbedPaneData.getTabbedPane().getBoundsAt(outerDnDTabbedPaneData.getDragTabIndex());
BufferedImage image = new BufferedImage(outerDnDTabbedPaneData.getTabbedPane().getWidth(), outerDnDTabbedPaneData.getTabbedPane().getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
outerDnDTabbedPaneData.getTabbedPane().paint(g);
rect.x = rect.x < 0 ? 0 : rect.x;
rect.y = rect.y < 0 ? 0 : rect.y;
// When scrollable tabbed panes are used tabs might be displayed in part.
rect.width = Math.min(rect.width, outerDnDTabbedPaneData.getTabbedPane().getWidth() - rect.x);
image = image.getSubimage(rect.x, rect.y, rect.width, rect.height);
localGlassPane.setImage(image);
}
Point glassPt = SwingUtilities.convertPoint(localDnDTabbedPaneData.getTabbedPane(), tabPt, localGlassPane);
localGlassPane.setPoint(glassPt);
localGlassPane.setVisible(true);
}
代码示例来源:origin: realXuJiang/bigtable-sql
private void initTargetTopBottomLine(int next)
{
// if (next < 0 || _dnDTabbedPaneData.getDragTabIndex() == next || next - _dnDTabbedPaneData.getDragTabIndex() == 1)
if (next < 0 || _dnDTabbedPaneData.getTabbedPane().getTabCount() < next)
{
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(0, 0, 0, 0);
}
else if (next == 0)
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(0), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x, r.y - DndTabUtils.LINEWIDTH / 2, r.width, DndTabUtils.LINEWIDTH);
}
else
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(next - 1), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x, r.y + r.height - DndTabUtils.LINEWIDTH / 2, r.width, DndTabUtils.LINEWIDTH);
}
}
代码示例来源:origin: realXuJiang/bigtable-sql
static void initGlassPane(Point tabPt, DnDTabbedPaneData localDnDTabbedPaneData, DnDTabbedPaneData outerDnDTabbedPaneData, GhostGlassPane localGlassPane)
{
localDnDTabbedPaneData.getTabbedPane().getRootPane().setGlassPane(localGlassPane);
if (localDnDTabbedPaneData.isHasGhost())
{
Rectangle rect = outerDnDTabbedPaneData.getTabbedPane().getBoundsAt(outerDnDTabbedPaneData.getDragTabIndex());
BufferedImage image = new BufferedImage(outerDnDTabbedPaneData.getTabbedPane().getWidth(), outerDnDTabbedPaneData.getTabbedPane().getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
outerDnDTabbedPaneData.getTabbedPane().paint(g);
rect.x = rect.x < 0 ? 0 : rect.x;
rect.y = rect.y < 0 ? 0 : rect.y;
// When scrollable tabbed panes are used tabs might be displayed in part.
rect.width = Math.min(rect.width, outerDnDTabbedPaneData.getTabbedPane().getWidth() - rect.x);
image = image.getSubimage(rect.x, rect.y, rect.width, rect.height);
localGlassPane.setImage(image);
}
Point glassPt = SwingUtilities.convertPoint(localDnDTabbedPaneData.getTabbedPane(), tabPt, localGlassPane);
localGlassPane.setPoint(glassPt);
localGlassPane.setVisible(true);
}
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
private void initTargetLeftRightLine(int next)
{
// if (next < 0 || _dnDTabbedPaneData.getDragTabIndex() == next || next - _dnDTabbedPaneData.getDragTabIndex() == 1)
if (next < 0 || _dnDTabbedPaneData.getTabbedPane().getTabCount() < next || 0 == _dnDTabbedPaneData.getTabbedPane().getTabCount())
{
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(0, 0, 0, 0);
}
else if (next == 0)
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(0), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x - DndTabUtils.LINEWIDTH / 2, r.y, DndTabUtils.LINEWIDTH, r.height);
}
else
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(next - 1), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x + r.width - DndTabUtils.LINEWIDTH / 2, r.y, DndTabUtils.LINEWIDTH, r.height);
}
}
代码示例来源:origin: realXuJiang/bigtable-sql
private void initTargetLeftRightLine(int next)
{
// if (next < 0 || _dnDTabbedPaneData.getDragTabIndex() == next || next - _dnDTabbedPaneData.getDragTabIndex() == 1)
if (next < 0 || _dnDTabbedPaneData.getTabbedPane().getTabCount() < next || 0 == _dnDTabbedPaneData.getTabbedPane().getTabCount())
{
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(0, 0, 0, 0);
}
else if (next == 0)
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(0), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x - DndTabUtils.LINEWIDTH / 2, r.y, DndTabUtils.LINEWIDTH, r.height);
}
else
{
Rectangle r = SwingUtilities.convertRectangle(_dnDTabbedPaneData.getTabbedPane(), _dnDTabbedPaneData.getTabbedPane().getBoundsAt(next - 1), _glassPane);
_dnDTabbedPaneData.getTargetLineRectBuffer().setRect(r.x + r.width - DndTabUtils.LINEWIDTH / 2, r.y, DndTabUtils.LINEWIDTH, r.height);
}
}
代码示例来源:origin: de.richtercloud/flexdock-core
Rectangle lastTab = tabs.getBoundsAt(tabs.getTabCount()-1);
tabRect.height = lastTab.height;
tabRect.y = lastTab.y;
内容来源于网络,如有侵权,请联系作者删除!