From e5c2b0afd8ddef21ff76de08ad87c4fbd96e048b Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 17 Jul 2017 13:54:45 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=8F=AF=E8=B0=83=E6=95=B4=E9=AB=98?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/EastRegionContainerPane.java | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 97d6cc28b2..1db206f5df 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -547,26 +547,74 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private class PopupDialog extends JDialog { private Container container; + private static final int RESIZE_RANGE = 4; + private Cursor originCursor; + private Cursor southResizeCursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR); + private Point mouseDownCompCoords; + private int minHeight; // 对话框最小高度 public PopupDialog(PropertyItem propertyItem) { container = getContentPane(); setUndecorated(true); -// JPanel pane = new JPanel(); -// pane.setBackground(Color.yellow); -// pane.setPreferredSize(new Dimension(100, 100)); -// -// getContentPane().add(pane); -// setSize(CONTENT_WIDTH, pane.getPreferredSize().height); PopupToolPane popupToolPane = new PopupToolPane(propertyItem, PopupToolPane.DOWN_BUTTON); popupToolPane.setParentDialog(this); JComponent contentPane = propertyItem.getContentPane(); container.add(popupToolPane, BorderLayout.NORTH); container.add(contentPane, BorderLayout.CENTER); - setSize(CONTENT_WIDTH, container.getPreferredSize().height); - + minHeight = container.getPreferredSize().height; + setSize(CONTENT_WIDTH, minHeight); validate(); Point btnCoords = propertyItem.getButton().getLocationOnScreen(); this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y); + + initListener(); this.setVisible(true); } + private void initListener() { + addMouseMotionListener(new MouseMotionListener() { + @Override + public void mouseDragged(MouseEvent e) { + if (mouseDownCompCoords != null) { + Rectangle bounds = getBounds(); + Point currCoords = e.getLocationOnScreen(); + bounds.height = currCoords.y - mouseDownCompCoords.y + bounds.height; + // 校正位置 + if (bounds.height < minHeight) { + bounds.height = minHeight; + } + mouseDownCompCoords.y = currCoords.y; + setBounds(bounds); + } + } + + @Override + public void mouseMoved(MouseEvent e) { + if (originCursor == null) { // 记录最初的光标 + originCursor = getCursor(); + } + if (e.getY() > getHeight() - RESIZE_RANGE) { + setCursor(southResizeCursor); + } else { + // 还原 + if (mouseDownCompCoords == null && getCursor().equals(southResizeCursor)) { + setCursor(originCursor); + } + } + + repaint(); + } + }); + addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (getCursor().equals(southResizeCursor)) { + mouseDownCompCoords = e.getLocationOnScreen(); + } + } + @Override + public void mouseReleased(MouseEvent e) { + mouseDownCompCoords = null; + } + }); + } } } \ No newline at end of file