Scroll Bar
@ -126,21 +126,10 @@ public class Icon9Factory extends RawCache<NinePatch> {
|
||||
|
||||
put("toggle_button", "selected", "toggle_button_selected");
|
||||
put("toggle_button", "rollover", "toggle_button_rover");
|
||||
|
||||
put("scroll_bar", "vertical", "scroll_bar_v");
|
||||
put("scroll_bar", "vertical_rollover", "scroll_bar_rover_v");
|
||||
put("scroll_bar", "vertical_pressed", "scroll_bar_pressed_v");
|
||||
put("scroll_bar", "horizontal", "scroll_bar_h");
|
||||
put("scroll_bar", "horizontal_rollover", "scroll_bar_rover_h");
|
||||
put("scroll_bar", "horizontal_pressed", "scroll_bar_rover_h");
|
||||
put("scroll_bar", "arrow_bottom", "arrow_toBottom");
|
||||
put("scroll_bar", "arrow_top", "arrow_toTop");
|
||||
put("scroll_bar", "arrow_left", "arrow_toLeft");
|
||||
put("scroll_bar", "arrow_right", "arrow_toRight");
|
||||
put("scroll_bar", "arrow_bottom_rollover", "arrow_toBottom_rover");
|
||||
put("scroll_bar", "arrow_top_rollover", "arrow_toTop_rover");
|
||||
put("scroll_bar", "arrow_left_rollover", "arrow_toLeft_rover");
|
||||
put("scroll_bar", "arrow_right_rollover", "arrow_toRight_rover");
|
||||
|
||||
put("scroll_bar", "arrow", "arrow");
|
||||
put("scroll_bar", "arrow_rollover", "arrow_rover");
|
||||
put("scroll_bar", "arrow_pressed", "arrow_pressed");
|
||||
put("scroll_bar", "scroll_pane_border", "scroll_pane_bg1");
|
||||
|
||||
put("popup", "popup", "shadow_bg_popup");
|
||||
@ -150,11 +139,6 @@ public class Icon9Factory extends RawCache<NinePatch> {
|
||||
put("table", "header_cell", "table_header_bg1");
|
||||
put("table", "header_cell_separator", "table_header_separator1");
|
||||
|
||||
put("text", "normal", "bg_login_text_normal");
|
||||
put("text", "pressed", "bg_login_text_pressed");
|
||||
put("text", "disabled", "bg_login_text_disable");
|
||||
put("text", "white", "null_white_bg");
|
||||
|
||||
put("toolbar", "north", "toolbar_bg1");
|
||||
put("toolbar", "south", "toolbar_bg1_SOUTH");
|
||||
put("toolbar", "west", "toolbar_bg1_WEST");
|
||||
|
@ -15,7 +15,6 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.JButton;
|
||||
@ -26,9 +25,8 @@ import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||
|
||||
import org.jackhuang.hmcl.laf.BEUtils;
|
||||
import org.jackhuang.hmcl.laf.utils.Icon9Factory;
|
||||
import org.jb2011.ninepatch4j.NinePatch;
|
||||
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
|
||||
|
||||
/**
|
||||
* 本类是滚动条的UI实现.
|
||||
@ -93,28 +91,30 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
String id = "arrow_";
|
||||
String id = "arrow";
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
id += "top";
|
||||
break;
|
||||
case SOUTH:
|
||||
id += "bottom";
|
||||
g2.translate(getWidth(), getHeight());
|
||||
g2.rotate(Math.PI);
|
||||
break;
|
||||
case WEST:
|
||||
id += "left";
|
||||
g2.translate(0, getHeight());
|
||||
g2.rotate(-Math.PI / 2);
|
||||
break;
|
||||
case EAST:
|
||||
id += "right";
|
||||
g2.translate(getWidth(), 0);
|
||||
g2.rotate(Math.PI / 2);
|
||||
break;
|
||||
}
|
||||
ICON_9.get(id, getModel().isRollover() ? "rollover" : "")
|
||||
ICON_9.getWithScrollState(id, getModel().isPressed(), getModel().isRollover())
|
||||
.draw(g2, 0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
int size = 16;
|
||||
int size = 12;
|
||||
if (scrollbar != null) {
|
||||
switch (scrollbar.getOrientation()) {
|
||||
case JScrollBar.VERTICAL:
|
||||
@ -136,75 +136,9 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
|
||||
if (c == null || g == null)
|
||||
return;
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
|
||||
Paint oldp = g2.getPaint();
|
||||
int w = trackBounds.width;
|
||||
int h = trackBounds.height;
|
||||
int x = trackBounds.x;
|
||||
int y = trackBounds.y;
|
||||
|
||||
if (this.scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
// //1/2处渐变
|
||||
// GradientPaint gp = new GradientPaint(x, y
|
||||
// , GraphicHandler.getColor(trackColor,-15,-15,-15), w/2, y,trackColor);
|
||||
// g2.setPaint(gp);
|
||||
// g2.fillRect(x, y, w/2, h);
|
||||
//
|
||||
// g2.setPaint(oldp);
|
||||
// g2.setColor(trackColor);
|
||||
// g2.fillRect(w/2, y, w/2, h);
|
||||
|
||||
//** 简洁版轨迹实现
|
||||
int hhhWidth = 5;
|
||||
int px = (w - hhhWidth) / 2;
|
||||
int delta = 50;
|
||||
//第1条
|
||||
g2.setColor(new Color(150 + delta, 151 + delta, 146 + delta));
|
||||
g2.drawLine(px + 0, y + 10, px + 0, y + h - 10);
|
||||
//第2条
|
||||
g2.setColor(new Color(160 + delta, 160 + delta, 162 + delta));
|
||||
g2.drawLine(px + 1, y + 10, px + 1, y + h - 10);
|
||||
//第3条
|
||||
g2.setColor(new Color(163 + delta, 162 + delta, 167 + delta));
|
||||
g2.drawLine(px + 2, y + 10, px + 2, y + h - 10);
|
||||
//第4条
|
||||
g2.setColor(new Color(162 + delta, 162 + delta, 162 + delta));
|
||||
g2.drawLine(px + 3, y + 10, px + 3, y + h - 10);
|
||||
//第5条
|
||||
g2.setColor(new Color(150 + delta, 150 + delta, 150 + delta));
|
||||
g2.drawLine(px + 4, y + 10, px + 4, y + h - 10);
|
||||
} else {
|
||||
//1/2处渐变
|
||||
// GradientPaint gp = new GradientPaint(x, y
|
||||
// , GraphicHandler.getColor(trackColor,-15,-15,-15), x, h/2,trackColor);
|
||||
// g2.setPaint(gp);
|
||||
// g2.fillRect(x, y, w, h/2);
|
||||
//
|
||||
// g2.setPaint(oldp);
|
||||
// g2.setColor(trackColor);
|
||||
// g2.fillRect(x, h/2, w, h);
|
||||
|
||||
//** 简洁版轨迹实现
|
||||
int hhhWidth = 5;
|
||||
int py = (h - hhhWidth) / 2;
|
||||
int delta = 50;
|
||||
//第1条
|
||||
g2.setColor(new Color(150 + delta, 151 + delta, 146 + delta));
|
||||
g2.drawLine(x + 10, py + 0, x + w - 10, py + 0);
|
||||
//第2条
|
||||
g2.setColor(new Color(160 + delta, 160 + delta, 162 + delta));
|
||||
g2.drawLine(x + 10, py + 1, x + w - 10, py + 1);
|
||||
//第3条
|
||||
g2.setColor(new Color(163 + delta, 162 + delta, 167 + delta));
|
||||
g2.drawLine(x + 10, py + 2, x + w - 10, py + 2);
|
||||
//第4条
|
||||
g2.setColor(new Color(162 + delta, 162 + delta, 162 + delta));
|
||||
g2.drawLine(x + 10, py + 3, x + w - 10, py + 3);
|
||||
//第5条
|
||||
g2.setColor(new Color(150 + delta, 150 + delta, 150 + delta));
|
||||
g2.drawLine(x + 10, py + 4, x + w - 10, py + 4);
|
||||
}
|
||||
Color color = GraphicsUtils.getWebColor("#F2F2F2");
|
||||
g.setColor(color);
|
||||
g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,51 +148,10 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
if (thumbBounds.isEmpty() || !scrollbar.isEnabled())
|
||||
return;
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
int w = thumbBounds.width - 4;
|
||||
int h = thumbBounds.height - 4;
|
||||
g2.translate(thumbBounds.x + 2, thumbBounds.y + 2);
|
||||
|
||||
// g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
BEUtils.setAntiAliasing(g2, true);
|
||||
|
||||
//防止thunmb的最小高度比图片的最小高度还要小,这样在绘制时就会出问题
|
||||
//起实,目前没还没有办法很好解决,因为即使在这里作处理,但是thumb本身
|
||||
//还是那么小,所以绘图还是会有问题,但起码在不拖动时看起来是正常的,以后再解决吧!
|
||||
if (this.scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
NinePatch np = ICON_9.getWithScrollState("vertical", isDragging, isThumbRollover());
|
||||
if (h < np.getHeight())
|
||||
paintThumbIfSoSmall(g2, 0, 0, w, h);
|
||||
else
|
||||
np.draw(g2, 0, 0, w, h);
|
||||
} else {
|
||||
NinePatch np = ICON_9.getWithScrollState("horizontal", isDragging, isThumbRollover());
|
||||
|
||||
if (w < np.getWidth())
|
||||
paintThumbIfSoSmall(g2, 0, 0, w, h);
|
||||
else
|
||||
np.draw(g2, 0, 0, w, h);
|
||||
}
|
||||
//如果滚动行宽度小于NP图的最小宽度时则交给此方法绘制(否则NP图的填充将出现虚绘,而影响滚动条的体验哦)
|
||||
|
||||
g2.translate(-thumbBounds.x, -thumbBounds.y);
|
||||
// g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
BEUtils.setAntiAliasing(g2, false);
|
||||
Color color = GraphicsUtils.getWebColor(isDragging ? "#616161" : isThumbRollover() ? "#919191" : "#C2C2C2");
|
||||
g.setColor(color);
|
||||
g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height);
|
||||
}
|
||||
//----------------------------------------------------------------------------------- END
|
||||
|
||||
/**
|
||||
* 如果滚动条非常小(小到小于NP图的最小大小)时调用此方法实现滚动条的精确绘制.
|
||||
*
|
||||
* @see javax.swing.plaf.basic.BasicScrollBarUI#paintThumb(java.awt.Graphics, javax.swing.JComponent, java.awt.Rectangle)
|
||||
*/
|
||||
protected void paintThumbIfSoSmall(Graphics2D g2, int x, int y, int w, int h) {
|
||||
final int NORMAL_ARC = 6;//定义圆角直径
|
||||
//如果w或h太小时,则就不绘制圆角了(直角即可),要不然就没法绘全圆角而很难看
|
||||
int arc = ((w <= NORMAL_ARC || h <= NORMAL_ARC) ? 0 : NORMAL_ARC);
|
||||
g2.setColor(thumbDarkShadowColor);
|
||||
g2.drawRoundRect(x, y, w - 1, h - 1, arc, arc);//画滚动条的外层
|
||||
g2.setColor(thumbColor);
|
||||
g2.fillRoundRect(x + 1, y + 1, w - 2, h - 2, arc, arc);//填充滚动条的内层
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public class __UI__ extends UI {
|
||||
putColor("ScrollBar.background", 250, 250, 250);
|
||||
putColor("ScrollBar.trackForeground", 250, 250, 250);
|
||||
putColor("scrollbar", 250, 250, 250);
|
||||
put("ScrollBar.width", 12);
|
||||
put("ScrollBarUI", BEScrollBarUI.class);
|
||||
|
||||
// /* ~~注:这个属性是jb2011自已加的,目的是控制滚动面板及其Viewport的透明性 */
|
||||
|
@ -11,17 +11,12 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.laf.textcoms;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.plaf.basic.BasicEditorPaneUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import org.jackhuang.hmcl.laf.textcoms.__UI__.BgSwitchable;
|
||||
import org.jb2011.ninepatch4j.NinePatch;
|
||||
|
||||
/**
|
||||
* 文本组件JEditorPane的UI实现类.
|
||||
@ -34,11 +29,8 @@ public class BEEditorPaneUI extends BasicEditorPaneUI implements BgSwitchable,
|
||||
//默认是纯白色背景,因为JEditorPane肯定是要放在JScrollPane中的,而ScrollPane也是有边框的
|
||||
//如果JEditorPane再有边框就很难看了,所以JEditorPane在没有获得焦点时就已无边框效果出现会好看很多
|
||||
|
||||
private NinePatch bg = __UI__.ICON_9.get("white");
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
BETextFieldUI.addOtherListener(c);
|
||||
// c.addMouseListener(new NLLookAndFeel.EditMenu());
|
||||
return new BEEditorPaneUI();
|
||||
}
|
||||
|
||||
@ -60,55 +52,16 @@ public class BEEditorPaneUI extends BasicEditorPaneUI implements BgSwitchable,
|
||||
|| !(getComponent().getBackground() instanceof UIResource));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a background for the view. This will only be called if isOpaque()
|
||||
* on the associated component is true. The default is to paint the
|
||||
* background color of the component.
|
||||
*
|
||||
* @param g the graphics context
|
||||
*/
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
//先调用父类方法把背景刷新下(比如本UI里使用的大圆角NP图如不先刷新背景则会因上下拉动滚动条
|
||||
//而致4个圆角位置得不到刷新,从而影响视觉效果(边角有前面的遗留),置于透明边角不被透明像素填
|
||||
//充的问题,它有可能是Android的NinePatch技术为了性能做作出的优化——一切全透明像素即意味着不需绘制)
|
||||
super.paintBackground(g); // TODO 出于节约计算资源考生虑,本行代码换成父类中默认填充背景的代码即可
|
||||
|
||||
//* 如果用户作了自定义颜色设置则使用父类方法来实现绘制,否则BE LNF中没法支持这些设置哦
|
||||
if (!isUseParentPaint()) {
|
||||
//用新的NP图实现真正的背景填充
|
||||
JTextComponent editor = this.getComponent();
|
||||
BETextFieldUI.paintBg(g, 0, 0, editor.getWidth(), editor.getHeight(),
|
||||
editor.isEnabled(), border);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToNormal() {
|
||||
border = __UI__.BORDER_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToFocused() {
|
||||
border = __UI__.border_focused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToOver() {
|
||||
border = __UI__.BORDER_OVER;
|
||||
}
|
||||
|
||||
Color border = __UI__.BORDER_NORMAL;
|
||||
|
||||
// /**
|
||||
// * Creates the object to use for a caret. By default an
|
||||
// * instance of WindowsCaret is created. This method
|
||||
// * can be redefined to provide something else that implements
|
||||
// * the InputPosition interface or a subclass of DefaultCaret.
|
||||
// *
|
||||
// * @return the caret object
|
||||
// */
|
||||
// protected Caret createCaret() {
|
||||
// return new WindowsTextUI.WindowsCaret();
|
||||
// }
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import javax.swing.plaf.basic.BasicFormattedTextFieldUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import org.jackhuang.hmcl.laf.textcoms.__UI__.BgSwitchable;
|
||||
import org.jb2011.ninepatch4j.NinePatch;
|
||||
|
||||
/**
|
||||
* 文本组件JFormattedTextField的UI实现类.
|
||||
@ -32,8 +31,6 @@ import org.jb2011.ninepatch4j.NinePatch;
|
||||
public class BEFormattedTextFieldUI extends BasicFormattedTextFieldUI implements BgSwitchable,
|
||||
org.jackhuang.hmcl.laf.BeautyEyeLNFHelper.__UseParentPaintSurported {
|
||||
|
||||
private NinePatch bg = __UI__.ICON_9.get("normal");
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
c.addFocusListener(FocusListenerImpl.getInstance());
|
||||
return new BEFormattedTextFieldUI();
|
||||
|
@ -21,7 +21,6 @@ import javax.swing.plaf.basic.BasicPasswordFieldUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import org.jackhuang.hmcl.laf.textcoms.__UI__.BgSwitchable;
|
||||
import org.jb2011.ninepatch4j.NinePatch;
|
||||
|
||||
/**
|
||||
* 文本组件JPasswordField的UI实现类.
|
||||
@ -31,11 +30,8 @@ import org.jb2011.ninepatch4j.NinePatch;
|
||||
public class BEPasswordFieldUI extends BasicPasswordFieldUI implements BgSwitchable,
|
||||
org.jackhuang.hmcl.laf.BeautyEyeLNFHelper.__UseParentPaintSurported {
|
||||
|
||||
private NinePatch bg = __UI__.ICON_9.get("normal");
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
c.addFocusListener(FocusListenerImpl.getInstance());
|
||||
// c.addMouseListener(new NLLookAndFeel.EditMenu());
|
||||
BETextFieldUI.addOtherListener(c);
|
||||
return new BEPasswordFieldUI();
|
||||
}
|
||||
|
||||
|
@ -11,17 +11,12 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.laf.textcoms;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.plaf.basic.BasicTextAreaUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import org.jackhuang.hmcl.laf.textcoms.__UI__.BgSwitchable;
|
||||
import org.jb2011.ninepatch4j.NinePatch;
|
||||
|
||||
/**
|
||||
* 文本组件JTextArea的UI实现类.
|
||||
@ -29,16 +24,12 @@ import org.jb2011.ninepatch4j.NinePatch;
|
||||
* @author Jack Jiang(jb2011@163.com)
|
||||
*/
|
||||
public class BETextAreaUI extends BasicTextAreaUI implements BgSwitchable,
|
||||
org.jackhuang.hmcl.laf.BeautyEyeLNFHelper.__UseParentPaintSurported//WindowsTextAreaUI
|
||||
{
|
||||
org.jackhuang.hmcl.laf.BeautyEyeLNFHelper.__UseParentPaintSurported {
|
||||
//默认是纯白色背景,因为JTextArea肯定是要放在JScrollPane中的,而ScrollPane也是有边框的
|
||||
//如果JTextArea再有边框就很难看了,所以JTextArea在没有获得焦点时就已无边框效果出现会好看很多
|
||||
|
||||
private NinePatch bg = __UI__.ICON_9.get("white");
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
BETextFieldUI.addOtherListener(c);
|
||||
// c.addMouseListener(new NLLookAndFeel.EditMenu());
|
||||
return new BETextAreaUI();
|
||||
}
|
||||
|
||||
@ -60,43 +51,15 @@ public class BETextAreaUI extends BasicTextAreaUI implements BgSwitchable,
|
||||
|| !(getComponent().getBackground() instanceof UIResource));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a background for the view. This will only be called if isOpaque()
|
||||
* on the associated component is true. The default is to paint the
|
||||
* background color of the component.
|
||||
*
|
||||
* @param g the graphics context
|
||||
*/
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
//先调用父类方法把背景刷新下(比如本UI里使用的大圆角NP图如不先刷新背景则会因上下拉动滚动条
|
||||
//而致4个圆角位置得不到刷新,从而影响视觉效果(边角有前面的遗留),置于透明边角不被透明像素填
|
||||
//充的问题,它有可能是Android的NinePatch技术为了性能做作出的优化——一切全透明像素即意味着不需绘制)
|
||||
super.paintBackground(g);// TODO 出于节约计算资源考生虑,本行代码换成父类中默认填充背景的代码即可
|
||||
|
||||
//* 如果用户作了自定义颜色设置则使用父类方法来实现绘制,否则BE LNF中没法支持这些设置哦
|
||||
if (!isUseParentPaint()) {
|
||||
//用新的NP图实现真正的背景填充
|
||||
JTextComponent editor = this.getComponent();
|
||||
BETextFieldUI.paintBg(g, 0, 0, editor.getWidth(), editor.getHeight(),
|
||||
editor.isEnabled(), border);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToNormal() {
|
||||
border = __UI__.BORDER_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToFocused() {
|
||||
border = __UI__.border_focused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToOver() {
|
||||
border = __UI__.BORDER_OVER;
|
||||
}
|
||||
|
||||
Color border = __UI__.BORDER_NORMAL;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ package org.jackhuang.hmcl.laf.textcoms;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.UIResource;
|
||||
@ -21,7 +20,6 @@ import javax.swing.plaf.basic.BasicTextFieldUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import org.jackhuang.hmcl.laf.textcoms.__UI__.BgSwitchable;
|
||||
import org.jb2011.ninepatch4j.NinePatch;
|
||||
|
||||
/**
|
||||
* 文本组件JTextField的UI实现类.
|
||||
@ -31,8 +29,6 @@ import org.jb2011.ninepatch4j.NinePatch;
|
||||
public class BETextFieldUI extends BasicTextFieldUI implements BgSwitchable,
|
||||
org.jackhuang.hmcl.laf.BeautyEyeLNFHelper.__UseParentPaintSurported {
|
||||
|
||||
private NinePatch bg = __UI__.ICON_9.get("normal");
|
||||
|
||||
public static BETextFieldUI createUI(JComponent c) {
|
||||
addOtherListener(c);
|
||||
return new BETextFieldUI();
|
||||
@ -165,7 +161,7 @@ public class BETextFieldUI extends BasicTextFieldUI implements BgSwitchable,
|
||||
public void switchBgToOver() {
|
||||
border = __UI__.BORDER_OVER;
|
||||
}
|
||||
|
||||
|
||||
Color border = __UI__.BORDER_NORMAL;
|
||||
|
||||
/**
|
||||
@ -181,15 +177,10 @@ public class BETextFieldUI extends BasicTextFieldUI implements BgSwitchable,
|
||||
*/
|
||||
public static void paintBg(Graphics g, int x, int y, int w, int h,
|
||||
boolean enabled, Color border) {
|
||||
if (enabled) {
|
||||
g.setColor(border);
|
||||
g.fillRect(x, y, w, h);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(x + 2, y + 2, w - 4, h - 4);
|
||||
}
|
||||
else
|
||||
__UI__.ICON_9.get("disabled")
|
||||
.draw((Graphics2D) g, x, y, w, h);
|
||||
g.setColor(enabled ? border : __UI__.BORDER_DISABLED);
|
||||
g.fillRect(x, y, w, h);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(x + 2, y + 2, w - 4, h - 4);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,7 +190,7 @@ public class BETextFieldUI extends BasicTextFieldUI implements BgSwitchable,
|
||||
*/
|
||||
public static void addOtherListener(JComponent c) {
|
||||
c.addFocusListener(FocusListenerImpl.getInstance());
|
||||
c.addMouseListener(FocusListenerImpl.getInstance());
|
||||
c.addMouseListener(FocusListenerImpl.getInstance());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import javax.swing.plaf.basic.BasicTextPaneUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import org.jackhuang.hmcl.laf.textcoms.__UI__.BgSwitchable;
|
||||
import org.jb2011.ninepatch4j.NinePatch;
|
||||
|
||||
/**
|
||||
* 文本组件JTextPane的UI实现类.
|
||||
@ -34,8 +33,6 @@ public class BETextPaneUI extends BasicTextPaneUI implements BgSwitchable,
|
||||
//默认是纯白色背景,因为JTextPane肯定是要放在JScrollPane中的,而ScrollPane也是有边框的
|
||||
//如果JTextPane再有边框就很难看了,所以JTextPane在没有获得焦点时就已无边框效果出现会好看很多
|
||||
|
||||
private NinePatch bg = __UI__.ICON_9.get("white");
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
BETextFieldUI.addOtherListener(c);
|
||||
// c.addMouseListener(new NLLookAndFeel.EditMenu());
|
||||
@ -59,55 +56,16 @@ public class BETextPaneUI extends BasicTextPaneUI implements BgSwitchable,
|
||||
|| !(getComponent().getBackground() instanceof UIResource));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a background for the view. This will only be called if isOpaque()
|
||||
* on the associated component is true. The default is to paint the
|
||||
* background color of the component.
|
||||
*
|
||||
* @param g the graphics context
|
||||
*/
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
//先调用父类方法把背景刷新下(比如本UI里使用的大圆角NP图如不先刷新背景则会因上下拉动滚动条
|
||||
//而致4个圆角位置得不到刷新,从而影响视觉效果(边角有前面的遗留),置于透明边角不被透明像素填
|
||||
//充的问题,它有可能是Android的NinePatch技术为了性能做作出的优化——一切全透明像素即意味着不需绘制)
|
||||
super.paintBackground(g);// TODO 出于节约计算资源考生虑,本行代码换成父类中默认填充背景的代码即可
|
||||
|
||||
//* 如果用户作了自定义颜色设置则使用父类方法来实现绘制,否则BE LNF中没法支持这些设置哦
|
||||
if (!isUseParentPaint()) {
|
||||
//用新的NP图实现真正的背景填充
|
||||
JTextComponent editor = this.getComponent();
|
||||
BETextFieldUI.paintBg(g, 0, 0, editor.getWidth(), editor.getHeight(),
|
||||
editor.isEnabled(), border);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToNormal() {
|
||||
border = __UI__.BORDER_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToFocused() {
|
||||
border = __UI__.border_focused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchBgToOver() {
|
||||
border = __UI__.BORDER_OVER;
|
||||
}
|
||||
|
||||
Color border = __UI__.BORDER_NORMAL;
|
||||
|
||||
// /**
|
||||
// * Creates the object to use for a caret. By default an
|
||||
// * instance of WindowsCaret is created. This method
|
||||
// * can be redefined to provide something else that implements
|
||||
// * the InputPosition interface or a subclass of DefaultCaret.
|
||||
// *
|
||||
// * @return the caret object
|
||||
// */
|
||||
// protected Caret createCaret() {
|
||||
// return new WindowsTextUI.WindowsCaret();
|
||||
// }
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.jackhuang.hmcl.laf.widget.border.BERoundBorder;
|
||||
|
||||
public class __UI__ extends UI {
|
||||
static final Color BORDER_NORMAL = GraphicsUtils.getWebColor("#999999");
|
||||
static final Color BORDER_DISABLED = GraphicsUtils.getWebColor("#E3E3E3");
|
||||
static final Color BORDER_OVER = GraphicsUtils.getWebColor("#666666");
|
||||
|
||||
static Color border_focused() {
|
||||
|
Before Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 334 B |
Before Width: | Height: | Size: 322 B |
Before Width: | Height: | Size: 322 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 386 B |
Before Width: | Height: | Size: 431 B |
Before Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 323 B |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 466 B |
Before Width: | Height: | Size: 476 B |
Before Width: | Height: | Size: 495 B |
Before Width: | Height: | Size: 416 B |
Before Width: | Height: | Size: 439 B |
Before Width: | Height: | Size: 505 B |