Browse Source

属性标题栏点击变色效果

master
hzzz 7 years ago
parent
commit
5f6ce89082
  1. 8
      designer_base/src/com/fr/design/foldablepane/HeaderPane.java
  2. 17
      designer_base/src/com/fr/design/foldablepane/UIExpandablePane.java

8
designer_base/src/com/fr/design/foldablepane/HeaderPane.java

@ -22,10 +22,15 @@ public class HeaderPane extends JPanel {
private int headHeight;
private Color bgColor;
private boolean isShow;
private boolean isPressed = false;
private String title;
private Image image;
private int fontSize;
public void setPressed(boolean pressed) {
this.isPressed = pressed;
}
public void setShow(boolean isShow) {
this.isShow = isShow;
}
@ -60,7 +65,8 @@ public class HeaderPane extends JPanel {
private BufferedImage createPanelImage() {
BufferedImage panelImage = new BufferedImage(getWidth(), headHeight, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = panelImage.createGraphics();
g2d.setColor(UIConstants.COMPONENT_BACKGROUND_COLOR);
g2d.setColor(isPressed ? UIConstants.POPUP_TITLE_BACKGROUND : UIConstants.COMPONENT_BACKGROUND_COLOR);
headWidth = this.getWidth();
g2d.fillRect(0, 0, headWidth, headHeight);
g2d.setFont(new Font("SimSun", 0, fontSize));

17
designer_base/src/com/fr/design/foldablepane/UIExpandablePane.java

@ -58,7 +58,8 @@ public class UIExpandablePane extends JPanel {
}
class PanelAction extends MouseAdapter {
public void mousePressed(MouseEvent e) {
@Override
public void mouseClicked(MouseEvent e) {
HeaderPane hp = (HeaderPane) e.getSource();
if (contentPanel.isShowing()) {
contentPanel.setVisible(false);
@ -67,9 +68,23 @@ public class UIExpandablePane extends JPanel {
contentPanel.setVisible(true);
hp.setShow(true);
}
hp.setPressed(false);
hp.getParent().validate();
hp.getParent().repaint();
}
public void mousePressed(MouseEvent e) {
HeaderPane hp = (HeaderPane) e.getSource();
hp.setPressed(true);
hp.getParent().repaint();
}
@Override
public void mouseExited(MouseEvent e) {
HeaderPane hp = (HeaderPane) e.getSource();
hp.setPressed(false);
hp.getParent().repaint();
}
}

Loading…
Cancel
Save