第一步:如何开始?
首先把 beautyeye_lnf.jar
文件作为lib放入你的项目并引用之.
目前,beautyeye_lnf.jar
文件位于all_in_one.zip包中的位置是:all_in_one/dist/
第二步:如何使用BeautyEye L&F?
加入以下代码,即可将你的Java程序界面更换成Beauty Eye的外观:
public static void main(String[] args)
{
try
{
org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
}
catch(Exception e)
{
//TODO exception
}
..................... 你的程序代码 .........................
..................... 你的程序代码 .........................
}
[附录1]:如何定义窗口边框类型?
public static void main(String[] args)
{
try
{
//设置本属性将改变窗口边框样式定义
BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.osLookAndFeelDecorated;
org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
}
catch(Exception e)
{
//TODO exception
}
..................... 你的程序代码 .........................
..................... 你的程序代码 .........................
}
[附录2]:有几种窗口边框类型?
序号 窗口边框尖型 代码 BeautyEye中默认使用 效果图 1 系统默认边框FrameBorderStyle.osLookAndFeelDecorated
2 强立体感半透明边框 FrameBorderStyle.translucencyAppleLike
java1.6.0_u10及更高版本时
3 弱立体感半透明边框 FrameBorderStyle.translucencySmallShadow
4 普通不透明边框 FrameBorderStyle.generalNoTranslucencyShadow
java1.5版本时
[附录3]:如何使用不同颜色的按钮?
序号 代码 BeautyEye中默认 效果图 1btnInstance.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.normal));
YES
2 btnInstance.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
3 btnInstance.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
4 btnInstance.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.blue));
5 btnInstance.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.red));
[附录4]:如何隐藏“设置”按钮?
http://beautyeye.googlecode.com/svn/trunk/beautyeye_lnf/screenshots/y1.png' />
说明: 该按钮目前仅作为演示窗口标题按钮的自定义能力之用,未来将开放自定义功能,目前你可选择隐藏之。
UIManager.put("RootPane.setupButtonVisible", false);
[附录5]:如何开启/关闭窗口在不活动时的半透明效果?
@since v3.2
//设置此开关量为false即表示关闭之,BeautyEye LNF中默认是true
BeautyEyeLNFHelper.translucencyAtFrameInactive = false;
[附录6]:怎样让JToolBar的ui不使用渐变图片而使用传统的纯色来填充背景?
@since v3.4
http://beautyeye.googlecode.com/svn/trunk/beautyeye_lnf/screenshots/toolbar_bg_paint_contrast.png' />
方法1:
//设置属性即可:true表示使用ToolBar.background颜色实现纯
//色填充背景,BeautyEye中此属性默认是false
UIManager.put("ToolBar.isPaintPlainBackground", Boolean.TRUE);
方法2:
//使用ClientProperty单独设置控制每个toolbar:true表示使用ToolBar.background
//颜色实现纯色填充背景,BeautyEye中此属性默认是false
toolbarInstance.putClientProperty("ToolBar.isPaintPlainBackground", Boolean.TRUE);
说明: 方法2可以单独控制每一个JToolBar组件,而方法1是全局属性,方法2的优先级高于方法1。
[附录7]:如何自定义JToolBar ui的border?
@since v3.4
加入以下代码,使用你自已的border:
//自定义JToolBar ui的border
Border bd = new org.jb2011.lnf.beautyeye.ch8_toolbar.BEToolBarUI.ToolBarBorder(
UIManager.getColor("ToolBar.shadow") //Floatable时触点的颜色
, UIManager.getColor("ToolBar.highlight")//Floatable时触点的阴影颜色
, new Insets(6, 0, 11, 0)); //border的默认insets
UIManager.put("ToolBar.border",new BorderUIResource(bd));
说明: 以上代码必须在 “BeautyEyeLNFHelper.launchBeautyEyeLNF();
” 之后执行方能起效哦。
[附录8]:如何设置BeantuEye外观下JTabbedPane的左缩进?
http://beautyeye.googlecode.com/svn/trunk/beautyeye_lnf/screenshots/tab_indent_desc_pic.png' />
参见以下代码实现:
//改变InsetsUIResource参数的值即可实现
UIManager.put("TabbedPane.tabAreaInsets"
, new javax.swing.plaf.InsetsUIResource(3,20,2,20));
说明: 以上代码必须在 “BeautyEyeLNFHelper.launchBeautyEyeLNF();
” 之后执行方能起效哦。
[附录9]:如何调置窗体背景全透明并完全隐藏一个窗体的标题栏?
http://beautyeye.googlecode.com/svn/trunk/beautyeye_lnf/screenshots/help_about_trasparent.png' />
在你的窗体被setVisible(true)前调用以下代码即可:
// set frame full transparent
frame.setUndecorated(true);
AWTUtilities.setWindowOpaque(frame, false);
frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
说明: 以上代码适用于所有处于非系统窗体标题栏的情况,包括官方MetalLookAndFeel外观等。
[附录10]:如何解决切换输入法导致白屏的问题?
说明: 切换输入法导致白屏问题是由于官方的透明API的bug引起,与BeautyEye本身无关。
解决方法参见:
http://hi.baidu.com/shenaodong/item/423419d57354feea55347fe5'>http://hi.baidu.com/shenaodong/item/423419d57354feea55347fe5
或者
http://stackoverflow.com/questions/14374111/input-method-removes-transparent-effect-from-jframe-in-swing'>http://stackoverflow.com/questions/14374111/input-method-removes-transparent-effect-from-jframe-in-swing
附录11:API文档
http://beautyeye.googlecode.com/svn/trunk/beautyeye_lnf/doc/api_doc/index.html'>在线阅读 or http://code.google.com/p/beautyeye/downloads/list'>下载all_in_one包
附录12:为何java1.6.0_10或update 11版不能启用BeautyEye L&F的窗口透明?
因为该版本存在一个Bug,具体https://code.google.com/p/beautyeye/wiki/java_1_6_0_u10_BUG_6750920'>请看这里.
附录13:关于win7平台下某些java版本上的文本字体发虚的问题说明
该问题具体请参见 https://code.google.com/p/beautyeye/issues/detail?id=25'>issue 25
解决方案:
把默认的字体换成win7平台下默认的微软雅黑,则字体效果会大有改善。
/** UIManager中UI字体相关的key */
public static String[] DEFAULT_FONT = new String[]{
"Table.font"
,"TableHeader.font"
,"CheckBox.font"
,"Tree.font"
,"Viewport.font"
,"ProgressBar.font"
,"RadioButtonMenuItem.font"
,"ToolBar.font"
,"ColorChooser.font"
,"ToggleButton.font"
,"Panel.font"
,"TextArea.font"
,"Menu.font"
,"TableHeader.font"
// ,"TextField.font"
,"OptionPane.font"
,"MenuBar.font"
,"Button.font"
,"Label.font"
,"PasswordField.font"
,"ScrollPane.font"
,"MenuItem.font"
,"ToolTip.font"
,"List.font"
,"EditorPane.font"
,"Table.font"
,"TabbedPane.font"
,"RadioButton.font"
,"CheckBoxMenuItem.font"
,"TextPane.font"
,"PopupMenu.font"
,"TitledBorder.font"
,"ComboBox.font"
};
// 调整默认字体
for (int i = 0; i < DEFAULT_FONT.length; i++)
UIManager.put(DEFAULT_FONT[i],new Font("微软雅黑", Font.PLAIN,14));
附录14:关于使用了BeautyEye后窗口的contentPane变成全透明的说明
首先申明这不是BeautyEye的bug,这其实是官方窗口透明API的实现,JFrame(包括JDialog)的contentPane实质就是JPanel,它被认为是窗口的一部分,官方窗口透明API在透明窗口其它部件的同时也把它透明了(我没看过源码,目前还不能确切的说),但这是合理的,因为它将能实现你还没想到的全透明场景。
解决办法: 在contentPane上再加一层JPanel即可。