Browse Source

无JIRA任务,代码规范

master
plough 7 years ago
parent
commit
017941a4ab
  1. 9
      designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java
  2. 8
      designer_base/src/com/fr/design/web/CustomIconPane.java

9
designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java

@ -13,12 +13,13 @@ import java.awt.*;
public class UIScrollPane extends JScrollPane {
private static final long serialVersionUID = 1L;
private static final int INCREAMENT = 30;
public UIScrollPane(Component c) {
super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.setHorizontalScrollBar(createHorizontalScrollBar());
this.getVerticalScrollBar().setUnitIncrement(30);
this.getVerticalScrollBar().setBlockIncrement(30);
this.getVerticalScrollBar().setUnitIncrement(INCREAMENT);
this.getVerticalScrollBar().setBlockIncrement(INCREAMENT);
this.getHorizontalScrollBar().setOpaque(true);
this.getHorizontalScrollBar().setBackground(Color.WHITE);
this.getVerticalScrollBar().setOpaque(true);
@ -29,7 +30,7 @@ public class UIScrollPane extends JScrollPane {
/**
* 生成水平滚动条
*/
public JScrollBar createHorizontalScrollBar() {
public UIScrollBar createHorizontalScrollBar() {
UIScrollBar sbr = new UIScrollBar(JScrollBar.HORIZONTAL);
sbr.setBackground(UIConstants.NORMAL_BACKGROUND);
return sbr;
@ -39,7 +40,7 @@ public class UIScrollPane extends JScrollPane {
/**
* 生成垂直滚动条
*/
public JScrollBar createVerticalScrollBar() {
public UIScrollBar createVerticalScrollBar() {
UIScrollBar sbr = new UIScrollBar(JScrollBar.VERTICAL);
sbr.setBackground(UIConstants.NORMAL_BACKGROUND);
return sbr;

8
designer_base/src/com/fr/design/web/CustomIconPane.java

@ -9,6 +9,7 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextarea.DescriptionTextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
@ -270,7 +271,7 @@ public class CustomIconPane extends BasicPane {
// 不知道怎么动态布局,就这么傻傻的调一下大小
private void refreshIconPane(boolean down) {
iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP));
JScrollBar jsBar = jsPane.createVerticalScrollBar();
UIScrollBar jsBar = jsPane.createVerticalScrollBar();
try {
if (down) {
// 将滚动条滚到最后
@ -287,6 +288,8 @@ public class CustomIconPane extends BasicPane {
private String iconName;
private Image iconImage = null;
private static final int ICON_BUTTON_SIZE = 24;
private static final int ICON_X = 4;
private static final int ICON_Y = 4;
public IconButton(String name) {
this.iconName = name;
this.addActionListener(this);
@ -311,7 +314,7 @@ public class CustomIconPane extends BasicPane {
Graphics2D g2d = (Graphics2D) g;
// carl:这里缩放显示 16 × 16
if (iconImage != null) {
g2d.drawImage(iconImage, 4, 4, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
}
if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) {
g2d.setPaint(Color.RED);
@ -378,6 +381,7 @@ public class CustomIconPane extends BasicPane {
// 焦点丢失时看看名称是否已经存在
nameTextField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
// do nothing
}
public void focusLost(FocusEvent e) {
if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) {

Loading…
Cancel
Save