Java Code Examples for javax.swing.JButton#getBounds()

The following examples show how to use javax.swing.JButton#getBounds() . 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: SeaGlassTabbedPaneUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Paint the background for a tab scroll button.
 *
 * @param ss           the tab subregion SynthContext.
 * @param g            the Graphics context.
 * @param scrollButton the button to paint.
 */
protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) {
    Rectangle tabRect = scrollButton.getBounds();
    int       x       = tabRect.x;
    int       y       = tabRect.y;
    int       height  = tabRect.height;
    int       width   = tabRect.width;

    boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight());

    SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect);

    tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition",
                              ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last");

    int         oldState    = tabContext.getComponentState();
    ButtonModel model       = scrollButton.getModel();
    int         isPressed   = model.isPressed() && model.isArmed() ? PRESSED : 0;
    int         buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed;

    tabContext.setComponentState(buttonState);
    tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement);
    tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement);
    tabContext.setComponentState(oldState);
}
 
Example 2
Source File: bug6219960.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean pressOK(Component comp) {

        JInternalFrame internalFrame
                = findModalInternalFrame(comp, QUESTION);

        if (internalFrame == null) {
            return false;
        }

        JButton button = (JButton) findButton(internalFrame);

        if (button == null) {
            return false;
        }

        try {
            Robot robot = new Robot();
            Point location = button.getLocationOnScreen();
            Rectangle bounds = button.getBounds();
            int centerX = (int) (location.getX() + bounds.getWidth() / 2);
            int centerY = (int) (location.getY() + bounds.getHeight() / 2);
            robot.mouseMove(centerX, centerY);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        } catch (IllegalComponentStateException ignore) {
            return false;
        } catch (AWTException e) {
            throw new RuntimeException(e);
        }
        return true;
    }
 
Example 3
Source File: SummaryCellRenderer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void computeBounds (JButton button) {
    bounds = button.getBounds();
}
 
Example 4
Source File: SummaryCellRenderer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void computeBounds (JButton button) {
    bounds = button.getBounds();
}