Browse Source

REPORT-1096 将取色按钮封装为一个类

master
plough 8 years ago
parent
commit
d0cd522b79
  1. 18
      designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
  2. 37
      designer_base/src/com/fr/design/style/color/PickColorButton.java

18
designer_base/src/com/fr/design/style/color/NewColorSelectPane.java

@ -87,15 +87,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
centerPane.add(row1Pane);
// 取色按钮
UIButton pickColorButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/gui/colorSelectPane/colorPicker.png"));
pickColorButton.setPreferredSize(new Dimension(16, 16));
pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
pickColorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doPickColor();
}
});
PickColorButton pickColorButton = new PickColorButton(this);
row1Pane.add(pickColorButton, BorderLayout.WEST);
// 最近使用
@ -224,12 +216,4 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
usedColorPane.updateUsedColor();
}
/**
* 打开取色框开始取色
*/
public void doPickColor() {
ColorPicker colorPicker = new ColorPicker(this);
colorPicker.start();
}
}

37
designer_base/src/com/fr/design/style/color/PickColorButton.java

@ -0,0 +1,37 @@
package com.fr.design.style.color;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by plough on 2016/12/22.
*/
public class PickColorButton extends UIButton {
private ColorSelectable colorSelectable;
public PickColorButton(ColorSelectable colorSelectable) {
super(BaseUtils.readIcon("/com/fr/design/images/gui/colorSelectPane/colorPicker.png"));
this.colorSelectable = colorSelectable;
this.setPreferredSize(new Dimension(16, 16));
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doPickColor();
}
});
}
/**
* 打开取色框开始取色
*/
public void doPickColor() {
ColorPicker colorPicker = new ColorPicker(colorSelectable);
colorPicker.start();
}
}
Loading…
Cancel
Save