@Override public void mouseDragged(MouseEvent e) { if (!myDragging) return; MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this); final ToolWindowAnchor anchor = myInfo.getAnchor(); final Point point = event.getPoint(); final Container windowPane = InternalDecorator.this.getParent(); myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane); myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth()); myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight()); final Rectangle bounds = InternalDecorator.this.getBounds(); if (anchor == ToolWindowAnchor.TOP) { InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y); } else if (anchor == ToolWindowAnchor.LEFT) { InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height); } else if (anchor == ToolWindowAnchor.BOTTOM) { InternalDecorator.this.setBounds( 0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y); } else if (anchor == ToolWindowAnchor.RIGHT) { InternalDecorator.this.setBounds( myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height); } InternalDecorator.this.validate(); e.consume(); }
public int getWidth() { float fWidth; int width; fWidth = scale * nativeGetMaxWidth(); width = Math.round(fWidth); if (parentContainer == null) { return width; } else { return FTAUtilities.max(width, parentContainer.getWidth()); } }
public void btnChoose_actionPerformed() { // java.awt.Rectangle r = dateField.getBounds(); // Point pOnScreen = dateField.getLocationOnScreen(); java.awt.Rectangle r = Jtext.getBounds(); Point pOnScreen = Jtext.getLocationOnScreen(); Point result = new Point(pOnScreen.x, pOnScreen.y + r.height); Point powner = owner.getLocation(); int offsetX = (pOnScreen.x + width) - (powner.x + owner.getWidth()); int offsetY = (pOnScreen.y + r.height + height) - (powner.y + owner.getHeight()); if (offsetX > 0) { result.x -= offsetX; } if (offsetY > 0) { result.y -= height + r.height; } javax.swing.JDialog dateFrame = new javax.swing.JDialog(); dateFrame.setModal(false); dateFrame.setUndecorated(true); dateFrame.setLocation(result); dateFrame.setSize(width, height); dateFrame.addWindowListener( new WindowAdapter() { // 鍦ㄤ换鎰忕殑闈炴棩鏈熼�夋嫨鍖哄崟鍑伙紝鍒欐棩鏈熼�夋嫨缁勪欢灏嗗彉涓洪潪娲诲姩鐘舵�侊紝鑷姩閲婃斁璧勬簮銆� public void windowDeactivated(WindowEvent e) { javax.swing.JDialog f = (javax.swing.JDialog) e.getSource(); f.dispose(); } }); DatePanel datePanel = new DatePanel(dateFrame, parten); dateFrame.getContentPane().setLayout(new BorderLayout()); dateFrame.getContentPane().add(datePanel); dateFrame.setVisible(true); }
// ------------- maxX() --------------------- private int maxX() { return (int) (_parent.getX() + _parent.getWidth() - this.getWidth()); }
public void layoutContainer(Container container) { Component[] children = container.getComponents(); if (children != null && children.length > 0) { int numChildren = children.length; Insets insets = container.getInsets(); int maxWidth = 0; int maxHeight = 0; int totalButtonWidth = 0; int x = 0; int xOffset = 0; boolean ltr = container.getComponentOrientation().isLeftToRight(); boolean reverse = (ltr) ? reverseButtons : !reverseButtons; for (int counter = 0; counter < numChildren; counter++) { Dimension pref = children[counter].getPreferredSize(); maxWidth = Math.max(maxWidth, pref.width); maxHeight = Math.max(maxHeight, pref.height); totalButtonWidth += pref.width; } if (getSyncAllWidths()) { totalButtonWidth = maxWidth * numChildren; } totalButtonWidth += (numChildren - 1) * padding; switch (getOrientation(container)) { case SwingConstants.LEFT: x = insets.left; break; case SwingConstants.RIGHT: x = container.getWidth() - insets.right - totalButtonWidth; break; case SwingConstants.CENTER: if (getCentersChildren() || numChildren < 2) { x = (container.getWidth() - totalButtonWidth) / 2; } else { x = insets.left; if (getSyncAllWidths()) { xOffset = (container.getWidth() - insets.left - insets.right - totalButtonWidth) / (numChildren - 1) + maxWidth; } else { xOffset = (container.getWidth() - insets.left - insets.right - totalButtonWidth) / (numChildren - 1); } } break; } for (int counter = 0; counter < numChildren; counter++) { int index = (reverse) ? numChildren - counter - 1 : counter; Dimension pref = children[index].getPreferredSize(); if (getSyncAllWidths()) { children[index].setBounds(x, insets.top, maxWidth, maxHeight); } else { children[index].setBounds(x, insets.top, pref.width, pref.height); } if (xOffset != 0) { x += xOffset; } else { x += children[index].getWidth() + padding; } } } }