private void moveMousePointerOnButton(final JButton button) { Application application = ApplicationManager.getApplication(); if (application != null && application.hasComponent(UISettings.class)) { if (button != null && UISettings.getInstance().MOVE_MOUSE_ON_DEFAULT_BUTTON) { Point p = button.getLocationOnScreen(); Rectangle r = button.getBounds(); try { Robot robot = new Robot(); robot.mouseMove(p.x + r.width / 2, p.y + r.height / 2); } catch (AWTException e) { LOG.warn(e); } } } }
public void paintComponent(Graphics g) { if (getFrame() != null) { setState(getFrame().getExtendedState()); } JRootPane rootPane = getRootPane(); Window window = getWindow(); boolean leftToRight = (window == null) ? rootPane.getComponentOrientation().isLeftToRight() : window.getComponentOrientation().isLeftToRight(); boolean isSelected = (window == null) ? true : window.isActive(); int width = getWidth(); int height = getHeight(); Color background; Color foreground; Color darkShadow; if (isSelected) { background = UIUtil.getPanelBackground(); // myActiveBackground; foreground = myActiveForeground; darkShadow = Gray._73; // myActiveShadow; } else { background = UIUtil.getPanelBackground(); // myInactiveBackground; foreground = myInactiveForeground; darkShadow = myInactiveShadow; } g.setColor(background); g.fillRect(0, 0, width, height); // g.setColor(darkShadow); // g.drawLine(0, height - 1, width, height - 1); // g.drawLine(0, 0, 0, 0); // g.drawLine(width - 1, 0, width - 1, 0); int xOffset = leftToRight ? 5 : width - 5; if (getWindowDecorationStyle() == JRootPane.FRAME) { xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5; } String theTitle = getTitle(); if (theTitle != null) { FontMetrics fm = SwingUtilities2.getFontMetrics(rootPane, g); g.setColor(foreground); int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent(); Rectangle rect = new Rectangle(0, 0, 0, 0); if (myIconifyButton != null && myIconifyButton.getParent() != null) { rect = myIconifyButton.getBounds(); } int titleW; if (leftToRight) { if (rect.x == 0) { rect.x = window.getWidth() - window.getInsets().right - 2; } titleW = rect.x - xOffset - 4; theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW); } else { titleW = xOffset - rect.x - rect.width - 4; theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW); xOffset -= SwingUtilities2.stringWidth(rootPane, fm, theTitle); } int titleLength = SwingUtilities2.stringWidth(rootPane, fm, theTitle); if (myIdeMenu == null) { SwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset); xOffset += leftToRight ? titleLength + 5 : -5; } } int w = width; int h = height; h--; g.setColor(UIManager.getColor("MenuBar.darcula.borderColor")); g.drawLine(0, h, w, h); h--; g.setColor(UIManager.getColor("MenuBar.darcula.borderShadowColor")); g.drawLine(0, h, w, h); }