Levy.Xie-解安森
12 months ago
1 changed files with 59 additions and 0 deletions
@ -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; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue