public void mouseMoved(MouseEvent ev) { JRootPane root = getRootPane(); if (root.getWindowDecorationStyle() == JRootPane.NONE) { return; } Window w = (Window) ev.getSource(); Frame f = null; Dialog d = null; if (w instanceof Frame) { f = (Frame) w; } else if (w instanceof Dialog) { d = (Dialog) w; } // Update the cursor int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY())); if (cursor != 0 && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0)) || (d != null && d.isResizable()))) { w.setCursor(Cursor.getPredefinedCursor(cursor)); } else { w.setCursor(lastCursor); } }
public void mouseClicked(MouseEvent ev) { Window w = (Window) ev.getSource(); Frame f = null; if (w instanceof Frame) { f = (Frame) w; } else { return; } Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane()); int state = f.getExtendedState(); if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) { if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) { if (f.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH); } else { f.setExtendedState(state | Frame.MAXIMIZED_BOTH); } return; } } } }
public boolean isResizable() { if (f != null) { return f.isResizable(); } else if (d != null) { return d.isResizable(); } else if (jif != null) { return jif.isResizable(); } else { throw new IllegalStateException(); } }
@Override void initialize() { super.initialize(); Frame target = (Frame) this.target; if (target.getTitle() != null) { setTitle(target.getTitle()); } setResizable(target.isResizable()); setState(target.getExtendedState()); }
public void mousePressed(MouseEvent ev) { JRootPane rootPane = getRootPane(); if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) { return; } Point dragWindowOffset = ev.getPoint(); Window w = (Window) ev.getSource(); if (w != null) { w.toFront(); } Point convertedDragWindowOffset = SwingUtilities.convertPoint(w, dragWindowOffset, getTitlePane()); Frame f = null; Dialog d = null; if (w instanceof Frame) { f = (Frame) w; } else if (w instanceof Dialog) { d = (Dialog) w; } int frameState = (f != null) ? f.getExtendedState() : 0; if (getTitlePane() != null && getTitlePane().contains(convertedDragWindowOffset)) { if ((f != null && ((frameState & Frame.MAXIMIZED_BOTH) == 0) || (d != null)) && dragWindowOffset.y >= BORDER_DRAG_THICKNESS && dragWindowOffset.x >= BORDER_DRAG_THICKNESS && dragWindowOffset.x < w.getWidth() - BORDER_DRAG_THICKNESS) { isMovingWindow = true; dragOffsetX = dragWindowOffset.x; dragOffsetY = dragWindowOffset.y; } } else if (f != null && f.isResizable() && ((frameState & Frame.MAXIMIZED_BOTH) == 0) || (d != null && d.isResizable())) { dragOffsetX = dragWindowOffset.x; dragOffsetY = dragWindowOffset.y; dragWidth = w.getWidth(); dragHeight = w.getHeight(); dragCursor = getCursor(calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y)); } }
private void setState(int state, boolean updateRegardless) { Window wnd = getWindow(); if (wnd != null && getWindowDecorationStyle() == JRootPane.FRAME) { if (myState == state && !updateRegardless) { return; } Frame frame = getFrame(); if (frame != null) { JRootPane rootPane = getRootPane(); if (((state & Frame.MAXIMIZED_BOTH) != 0) && (rootPane.getBorder() == null || (rootPane.getBorder() instanceof UIResource)) && frame.isShowing()) { rootPane.setBorder(null); } else if ((state & Frame.MAXIMIZED_BOTH) == 0) { // This is a croak, if state becomes bound, this can // be nuked. rootPaneUI.installBorder(rootPane); } if (frame.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { updateToggleButton(myRestoreAction, myMinimizeIcon); myMaximizeAction.setEnabled(false); myRestoreAction.setEnabled(true); } else { updateToggleButton(myMaximizeAction, myMaximizeIcon); myMaximizeAction.setEnabled(true); myRestoreAction.setEnabled(false); } if (myToggleButton.getParent() == null || myIconifyButton.getParent() == null) { add(myToggleButton); add(myIconifyButton); revalidate(); repaint(); } myToggleButton.setText(null); } else { myMaximizeAction.setEnabled(false); myRestoreAction.setEnabled(false); if (myToggleButton.getParent() != null) { remove(myToggleButton); revalidate(); repaint(); } } } else { // Not contained in a Frame myMaximizeAction.setEnabled(false); myRestoreAction.setEnabled(false); myIconifyAction.setEnabled(false); remove(myToggleButton); remove(myIconifyButton); revalidate(); repaint(); } myCloseAction.setEnabled(true); myState = state; } }
/* */ private void setState(int paramInt, boolean paramBoolean) /* */ { /* 567 */ Window localWindow = getWindow(); /* */ /* 569 */ if ((localWindow != null) && (getWindowDecorationStyle() == 1)) { /* 570 */ if ((this.state == paramInt) && (!paramBoolean)) { /* 571 */ return; /* */ } /* 573 */ Frame localFrame = getFrame(); /* */ /* 575 */ if (localFrame != null) { /* 576 */ JRootPane localJRootPane = getRootPane(); /* */ /* 578 */ if (((paramInt & 0x6) != 0) && ((localJRootPane.getBorder() == null) || ((localJRootPane.getBorder() instanceof UIResource))) && (localFrame.isShowing())) /* */ { /* 582 */ localJRootPane.setBorder(null); /* */ } /* 584 */ else if ((paramInt & 0x6) == 0) /* */ { /* 587 */ this.rootPaneUI.installBorder(localJRootPane); /* */ } /* 589 */ if (localFrame.isResizable()) { /* 590 */ if ((paramInt & 0x6) != 0) { /* 591 */ updateToggleButton(this.restoreAction, this.minimizeIcon); /* 592 */ this.maximizeAction.setEnabled(false); /* 593 */ this.restoreAction.setEnabled(true); /* */ } /* */ else { /* 596 */ updateToggleButton(this.maximizeAction, this.maximizeIcon); /* 597 */ this.maximizeAction.setEnabled(true); /* 598 */ this.restoreAction.setEnabled(false); /* */ } /* 600 */ if ((this.toggleButton.getParent() == null) || (this.iconifyButton.getParent() == null)) /* */ { /* 602 */ add(this.toggleButton); /* 603 */ add(this.iconifyButton); /* 604 */ revalidate(); /* 605 */ repaint(); /* */ } /* 607 */ this.toggleButton.setText(null); /* */ } /* */ else { /* 610 */ this.maximizeAction.setEnabled(false); /* 611 */ this.restoreAction.setEnabled(false); /* 612 */ if (this.toggleButton.getParent() != null) { /* 613 */ remove(this.toggleButton); /* 614 */ revalidate(); /* 615 */ repaint(); /* */ } /* */ } /* */ } /* */ else /* */ { /* 621 */ this.maximizeAction.setEnabled(false); /* 622 */ this.restoreAction.setEnabled(false); /* 623 */ this.iconifyAction.setEnabled(false); /* 624 */ remove(this.toggleButton); /* 625 */ remove(this.iconifyButton); /* 626 */ revalidate(); /* 627 */ repaint(); /* */ } /* 629 */ this.closeAction.setEnabled(true); /* 630 */ this.state = paramInt; /* */ } /* */ }