Browse Source
Merge in DESIGN/design from ~LEVY.XIE/design:newui to newui * commit 'da6ad1d677a775eb81df8cd20c66e751c8f95a46': REPORT-107972 设计器样式翻新-UIComboBox翻新 REPORT-107972 设计器样式翻新-UIComboBox翻新newui
Levy.Xie-解安森
12 months ago
10 changed files with 172 additions and 109 deletions
@ -0,0 +1,41 @@
|
||||
package com.fine.theme.light.ui; |
||||
|
||||
import com.formdev.flatlaf.ui.FlatComboBoxUI; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.JButton; |
||||
import javax.swing.SwingConstants; |
||||
import javax.swing.plaf.ComponentUI; |
||||
import java.awt.Graphics2D; |
||||
|
||||
/** |
||||
* 提供 {@link javax.swing.JComboBox} 的UI类 |
||||
* |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2023/12/07 |
||||
*/ |
||||
public class FineComboBoxUI extends FlatComboBoxUI { |
||||
|
||||
public static ComponentUI createUI(JComponent c) { |
||||
return new FineComboBoxUI(); |
||||
} |
||||
|
||||
@Override |
||||
protected JButton createArrowButton() { |
||||
return new FineComboBoxButton(); |
||||
} |
||||
|
||||
protected class FineComboBoxButton extends FlatComboBoxButton { |
||||
|
||||
@Override |
||||
protected void paintArrow(Graphics2D g) { |
||||
if (isPopupVisible(comboBox)) { |
||||
setDirection(SwingConstants.NORTH); |
||||
} else { |
||||
setDirection(SwingConstants.SOUTH); |
||||
} |
||||
super.paintArrow(g); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.fine.theme.light.ui; |
||||
|
||||
import com.formdev.flatlaf.ui.FlatRoundBorder; |
||||
import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; |
||||
import com.fr.design.event.HoverAware; |
||||
|
||||
import javax.swing.UIManager; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Paint; |
||||
|
||||
|
||||
/** |
||||
* 通用的Border类,具备hover、click、禁用等多种状态 |
||||
* |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2023/12/06 |
||||
*/ |
||||
public class FineRoundBorder extends FlatRoundBorder { |
||||
|
||||
@Styleable(dot = true) |
||||
protected Color borderColor = UIManager.getColor("defaultBorderColor"); |
||||
@Styleable(dot = true) |
||||
protected Color disabledBorderColor = UIManager.getColor("defaultBorderColor"); |
||||
@Styleable(dot = true) |
||||
protected Color highlightBorderColor = UIManager.getColor("defaultHighlightBorderColor"); |
||||
@Styleable(dot = true) |
||||
protected Color focusColor = UIManager.getColor("defaultBorderFocusShadow"); |
||||
@Styleable(dot = true) |
||||
protected int focusWidth = UIManager.getInt("defaultBorderFocusWidth"); |
||||
|
||||
@Override |
||||
protected Paint getBorderColor(Component c) { |
||||
if (isEnabled(c)) { |
||||
if (c instanceof HoverAware && ((HoverAware) c).isHovered()) { |
||||
return getHoverBorderColor(); |
||||
} else { |
||||
return isFocused(c) ? focusedBorderColor : borderColor; |
||||
} |
||||
} |
||||
return disabledBorderColor; |
||||
} |
||||
|
||||
@Override |
||||
protected Color getFocusColor(Component c) { |
||||
return focusColor; |
||||
} |
||||
|
||||
@Override |
||||
protected int getFocusWidth(Component c) { |
||||
return focusWidth; |
||||
} |
||||
|
||||
protected Color getHoverBorderColor() { |
||||
return highlightBorderColor; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.design.event; |
||||
|
||||
/** |
||||
* 组件判断是否被hover的能力接口 |
||||
* |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2023/12/07 |
||||
*/ |
||||
public interface HoverAware { |
||||
|
||||
boolean isHovered(); |
||||
} |
After Width: | Height: | Size: 482 B |
After Width: | Height: | Size: 483 B |
Loading…
Reference in new issue