From 409eaaaa559207462a67bdeea4fa5817c197d4c8 Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 30 Dec 2016 16:11:06 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-1096=20=E5=8F=96=E8=89=B2=E6=9D=BF=3D?= =?UTF-8?q?=E3=80=8B=E8=A7=A3=E5=86=B3=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/style/color/ColorPicker.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/style/color/ColorPicker.java b/designer_base/src/com/fr/design/style/color/ColorPicker.java index 605474230b..74e5514e19 100644 --- a/designer_base/src/com/fr/design/style/color/ColorPicker.java +++ b/designer_base/src/com/fr/design/style/color/ColorPicker.java @@ -61,6 +61,18 @@ public class ColorPicker extends JDialog implements ActionListener timer = new Timer(timeCycle, this); timer.start(); hideCursor(); + + // 如果要求实时变化,确保先关闭弹窗,再截屏 + // 主要针对"图案"选项卡中的"前景"、"背景" + if (this.setColorRealTime) { + colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗 + try { + Thread.sleep(100); // 等待弹窗关闭 + } catch (InterruptedException e) { + e.printStackTrace(); + } + colorPickerPanel.captureScreen(); + } // System.out.println(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow()); } @@ -71,7 +83,7 @@ public class ColorPicker extends JDialog implements ActionListener public void actionPerformed(ActionEvent e) { updateLocation(); colorToSet = colorPickerPanel.getPixelColor(mousePos); - if (setColorRealTime && !colorSelectable.getColor().equals(colorToSet)) { + if (setColorRealTime && (colorSelectable.getColor() == null || !colorSelectable.getColor().equals(colorToSet))) { colorSelectable.setColor(colorToSet); } } @@ -147,6 +159,15 @@ class ColorPickerPanel extends JPanel */ public ColorPickerPanel(int scaleFactor) { + colorPickerFrame = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png"); + this.scaleFactor = scaleFactor; + captureScreen(); + } + + /** + * 截屏 + */ + public void captureScreen() { try { robot = new Robot(); @@ -158,8 +179,6 @@ class ColorPickerPanel extends JPanel screenImage = robot.createScreenCapture(new Rectangle(0, 0, Toolkit .getDefaultToolkit().getScreenSize().width, Toolkit .getDefaultToolkit().getScreenSize().height)); - colorPickerFrame = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png"); - this.scaleFactor = scaleFactor; } /**