Browse Source
Merge in DESIGN/design from ~RICHARD.FANG/design:fbp/release to fbp/release * commit '530cfdd9375f52c5a6d14238245ed1f191e566a0': REPORT-134347 & REPORT-134726 fix:fbp回归问题修复&图标清理fbp/merge
Richard.Fang-方超
3 months ago
7 changed files with 21 additions and 132 deletions
@ -1 +1 @@
|
||||
package com.fr.design.gui.ibutton;
import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Author : daisy
* Date: 13-8-1
* Time: 下午3:41
*/
public class UIPreviewButton extends JPanel {
private static final int START_X = -7;
protected UIButton upButton;
protected UIButton downButton;
protected void upButtonClickEvent() {
// do nothing
}
protected void downButtonClickEvent() {
// do nothing
}
public UIPreviewButton() {
this(new UIButton(), new UIButton());
}
public UIPreviewButton(UIButton up, UIButton down) {
upButton = up;
downButton = down;
upButton.setRoundBorder(true, Constants.CENTER);
downButton.setRoundBorder(true, Constants.CENTER);
upButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
downButton.getModel().setPressed(true);
downButton.getModel().setSelected(true);
downButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
downButton.getModel().setPressed(false);
downButton.getModel().setSelected(false);
downButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
upButtonClickEvent();
}
});
downButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
upButton.getModel().setPressed(true);
upButton.getModel().setSelected(true);
upButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
upButton.getModel().setPressed(false);
upButton.getModel().setSelected(false);
upButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
downButtonClickEvent();
}
});
this.setLayout(new FlowLayout(FlowLayout.CENTER,5,0));
this.add(upButton);
this.add(downButton);
}
public UIPreviewButton(Icon left, Icon right) {
this();
upButton.setIcon(left);
downButton.setIcon(right);
}
public UIButton getUpButton() {
return upButton;
}
public void setExtraPainted(boolean isExtraPainted) {
if (!isExtraPainted) {
upButton.setBackground(null);
downButton.setBackground(null);
upButton.setOpaque(false);
downButton.setOpaque(false);
}
}
public UIButton getDownButton() {
return downButton;
}
public void set4Toolbar() {
upButton.setNormalPainted(false);
downButton.setNormalPainted(false);
upButton.setBorderPaintedOnlyWhenPressed(true);
downButton.setBorderPaintedOnlyWhenPressed(true);
}
protected void showPopWindow(JPopupMenu menu) {
GUICoreUtils.showPopupMenu(menu, this, START_X, getY() + getHeight() - 3);
}
public static void main(String... args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(null);
UIPreviewButton bb = new UIPreviewButton(UIConstants.PAGE_BIG_ICON, UIConstants.PREVIEW_DOWN);
bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height);
content.add(bb);
GUICoreUtils.centerWindow(jf);
jf.setSize(100, 100);
jf.setVisible(true);
}
} |
||||
package com.fr.design.gui.ibutton;
import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Author : daisy
* Date: 13-8-1
* Time: 下午3:41
*/
public class UIPreviewButton extends JPanel {
private static final int START_X = -7;
protected UIButton upButton;
protected UIButton downButton;
protected void upButtonClickEvent() {
// do nothing
}
protected void downButtonClickEvent() {
// do nothing
}
public UIPreviewButton() {
this(new UIButton(), new UIButton());
}
public UIPreviewButton(UIButton up, UIButton down) {
upButton = up;
downButton = down;
upButton.setRoundBorder(true, Constants.CENTER);
downButton.setRoundBorder(true, Constants.CENTER);
upButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
downButton.getModel().setPressed(true);
downButton.getModel().setSelected(true);
downButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
downButton.getModel().setPressed(false);
downButton.getModel().setSelected(false);
downButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
upButtonClickEvent();
}
});
downButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
upButton.getModel().setPressed(true);
upButton.getModel().setSelected(true);
upButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
upButton.getModel().setPressed(false);
upButton.getModel().setSelected(false);
upButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
downButtonClickEvent();
}
});
this.setLayout(new FlowLayout(FlowLayout.CENTER,5,0));
this.add(upButton);
this.add(downButton);
}
public UIPreviewButton(Icon left, Icon right) {
this();
upButton.setIcon(left);
downButton.setIcon(right);
}
public UIButton getUpButton() {
return upButton;
}
public void setExtraPainted(boolean isExtraPainted) {
if (!isExtraPainted) {
upButton.setBackground(null);
downButton.setBackground(null);
upButton.setOpaque(false);
downButton.setOpaque(false);
}
}
public UIButton getDownButton() {
return downButton;
}
public void set4Toolbar() {
upButton.setNormalPainted(false);
downButton.setNormalPainted(false);
upButton.setBorderPaintedOnlyWhenPressed(true);
downButton.setBorderPaintedOnlyWhenPressed(true);
}
protected void showPopWindow(JPopupMenu menu) {
GUICoreUtils.showPopupMenu(menu, this, START_X, getY() + getHeight() - 3);
}
} |
Loading…
Reference in new issue