Java Code Examples for java.awt.Component#getBounds()
The following examples show how to use
java.awt.Component#getBounds() .
These examples are extracted from open source projects.
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 Project: visualvm File: ProfilerTableHovers.java License: GNU General Public License v2.0 | 6 votes |
private Rectangle getRendererRect(int column, Component renderer) { int _column = table.convertColumnIndexToModel(column); // Do not show value hovers for standard renderers shortening values using '...' if (!(renderer instanceof ProfilerRenderer) && !table.isScrollableColumn(_column)) return null; // Do not show value hovers when explicitely disabled if (renderer instanceof JComponent) if (((JComponent)renderer).getClientProperty(ProfilerTable.PROP_NO_HOVER) != null) return null; Rectangle bounds = renderer.getBounds(); bounds.x -= table.getColumnOffset(_column); return bounds; }
Example 2
Source Project: gcs File: DockHeader.java License: Mozilla Public License 2.0 | 6 votes |
private void updateForDragOver(Point where) { int count = getComponentCount(); int insertAt = count; for (int i = 0; i < count; i++) { Component child = getComponent(i); if (child instanceof DockTab) { Rectangle bounds = child.getBounds(); if (where.x < bounds.x + bounds.width / 2) { insertAt = i; break; } if (where.x < bounds.x + bounds.width) { insertAt = i + 1; break; } } else { insertAt = i; break; } } if (insertAt != mDragInsertIndex) { mDragInsertIndex = insertAt; repaint(); } }
Example 3
Source Project: netbeans File: TopComponentDraggable.java License: Apache License 2.0 | 6 votes |
Rectangle getBounds() { Rectangle bounds = null; TopComponent modeTC = getTopComponent(); if( null == modeTC ) { modeTC = mode.getSelectedTopComponent(); if( null == modeTC ) { TopComponent[] tcs = mode.getTopComponents(); if( null != tcs && tcs.length > 0 ) modeTC = tcs[0]; } } Component modeComp = ( Component ) SwingUtilities.getAncestorOfClass(ModeComponent.class, modeTC); if( modeComp != null ) { bounds = modeComp.getBounds(); } return bounds; }
Example 4
Source Project: Bytecoder File: DefaultDesktopManager.java License: Apache License 2.0 | 6 votes |
public void beginDraggingFrame(JComponent f) { setupDragMode(f); if (dragMode == FASTER_DRAG_MODE) { Component desktop = f.getParent(); floatingItems = findFloatingItems(f); currentBounds = f.getBounds(); if (desktop instanceof JComponent) { desktopBounds = ((JComponent)desktop).getVisibleRect(); } else { desktopBounds = desktop.getBounds(); desktopBounds.x = desktopBounds.y = 0; } desktopGraphics = JComponent.safelyGetGraphics(desktop); ((JInternalFrame)f).isDragging = true; didDrag = false; } }
Example 5
Source Project: openjdk-8 File: WPrinterJob.java License: GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example 6
Source Project: jdk8u-dev-jdk File: BasicScrollPaneUI.java License: GNU General Public License v2.0 | 5 votes |
private void scrollEnd(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(bounds.width - visRect.width, bounds.height - visRect.height)); } else { vp.setViewPosition(new Point(0, bounds.height - visRect.height)); } } }
Example 7
Source Project: jdk1.8-source-analysis File: BasicScrollPaneUI.java License: Apache License 2.0 | 5 votes |
private void scrollHome(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(0, 0)); } else { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); vp.setViewPosition(new Point(bounds.width - visRect.width, 0)); } } }
Example 8
Source Project: gcs File: DropPanel.java License: Mozilla Public License 2.0 | 5 votes |
private void paintVerticalBackgrounds(Graphics gc, Rectangle localBounds) { for (Entry<Component, Color> entry : mVerticalBackgrounds.entrySet()) { Component panel = entry.getKey(); Rectangle bounds = panel.getBounds(); Container parent = panel.getParent(); if (parent != null) { if (parent != this) { UIUtilities.convertRectangle(bounds, parent, this); } gc.setColor(entry.getValue()); gc.fillRect(bounds.x, localBounds.y, bounds.width, localBounds.height); } } }
Example 9
Source Project: jdk8u-jdk File: BasicScrollPaneUI.java License: GNU General Public License v2.0 | 5 votes |
private void scrollHome(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(0, 0)); } else { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); vp.setViewPosition(new Point(bounds.width - visRect.width, 0)); } } }
Example 10
Source Project: Bytecoder File: BasicScrollPaneUI.java License: Apache License 2.0 | 5 votes |
private void scrollHome(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(0, 0)); } else { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); vp.setViewPosition(new Point(bounds.width - visRect.width, 0)); } } }
Example 11
Source Project: visualvm File: OQLQueries.java License: GNU General Public License v2.0 | 5 votes |
public void doLayout() { super.doLayout(); Component c = getComponent(1); int h = c.getPreferredSize().height; Rectangle b = c.getBounds(); b.y = (b.height - h) / 2 + 1; b.height = h; c.setBounds(b); }
Example 12
Source Project: hottub File: BasicScrollPaneUI.java License: GNU General Public License v2.0 | 5 votes |
private void scrollEnd(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(bounds.width - visRect.width, bounds.height - visRect.height)); } else { vp.setViewPosition(new Point(0, bounds.height - visRect.height)); } } }
Example 13
Source Project: jdk8u_jdk File: BasicScrollPaneUI.java License: GNU General Public License v2.0 | 5 votes |
private void scrollHome(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(0, 0)); } else { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); vp.setViewPosition(new Point(bounds.width - visRect.width, 0)); } } }
Example 14
Source Project: jdk8u-jdk File: BasicScrollPaneUI.java License: GNU General Public License v2.0 | 5 votes |
private void scrollEnd(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(bounds.width - visRect.width, bounds.height - visRect.height)); } else { vp.setViewPosition(new Point(0, bounds.height - visRect.height)); } } }
Example 15
Source Project: visualvm File: RQueries.java License: GNU General Public License v2.0 | 5 votes |
public void doLayout() { super.doLayout(); Component c = getComponent(1); int h = c.getPreferredSize().height; Rectangle b = c.getBounds(); b.y = (b.height - h) / 2 + 1; b.height = h; c.setBounds(b); }
Example 16
Source Project: Bytecoder File: BasicScrollPaneUI.java License: Apache License 2.0 | 5 votes |
private void scrollEnd(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(bounds.width - visRect.width, bounds.height - visRect.height)); } else { vp.setViewPosition(new Point(0, bounds.height - visRect.height)); } } }
Example 17
Source Project: LGoodDatePicker File: InternalUtilities.java License: MIT License | 5 votes |
/** * isMouseWithinComponent, This returns true if the mouse is inside of the specified component, * otherwise returns false. */ static public boolean isMouseWithinComponent(Component component) { if (!component.isVisible()) { // component.getLocationOnScreen() will throw an // IllegalComponentStateException if the component // is currently not visible return false; } Point mousePos = MouseInfo.getPointerInfo().getLocation(); Rectangle bounds = component.getBounds(); bounds.setLocation(component.getLocationOnScreen()); return bounds.contains(mousePos); }
Example 18
Source Project: hottub File: BasicScrollPaneUI.java License: GNU General Public License v2.0 | 5 votes |
private void scrollHome(JScrollPane scrollpane) { JViewport vp = scrollpane.getViewport(); Component view; if (vp != null && (view = vp.getView()) != null) { if (scrollpane.getComponentOrientation().isLeftToRight()) { vp.setViewPosition(new Point(0, 0)); } else { Rectangle visRect = vp.getViewRect(); Rectangle bounds = view.getBounds(); vp.setViewPosition(new Point(bounds.width - visRect.width, 0)); } } }
Example 19
Source Project: netbeans File: SummaryCellRenderer.java License: Apache License 2.0 | 4 votes |
public void computeBounds (Component component) { bounds = component.getBounds(); }
Example 20
Source Project: magarena File: ImageHelper.java License: GNU General Public License v3.0 | 4 votes |
private static BufferedImage getScreenshotImage(final Component container) { final Rectangle rec = container.getBounds(); final BufferedImage capture = getCompatibleBufferedImage(rec.width, rec.height); container.paint(capture.getGraphics()); return capture; }