Eclipse中java皮肤包如何使用

Python010

Eclipse中java皮肤包如何使用,第1张

1.可以将下载的目录中的Swing.properties复制到/%JAVA_HOME%/lib下。这种方法不建议使用,因为不可能要求所有的客户都这样做。

2.在程序的入口写上如下代码

public static void main(String args[]) {

try {

UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel")

} catch (Exception ex) {

ex.printStackTrace()

}

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new TestFrame().setVisible(true)

}

})

}

import java.awt.BorderLayout

import javax.swing.JButton

import javax.swing.JFrame

import javax.swing.JPanel

import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper//这是我选择的皮肤

public class TestDemo extends JFrame {

public TestDemo() {

// 代码写在这里可能导致边框还是java默认的边框

// try {

//   BeautyEyeLNFHelper.launchBeautyEyeLNF()

// } catch (Exception e) {

//  e.printStackTrace()

// }

this.add(new JPanel())

this.add(new JButton("FDSAS"), BorderLayout.NORTH)

this.setBounds(0, 0, 500, 500)

this.setVisible(true)

this.setDefaultCloseOperation(EXIT_ON_CLOSE)

}

public static void main(String[] args) {

// 设置外观的代码写在这就可以保证边框也是你选用的皮肤包 

try {

BeautyEyeLNFHelper.launchBeautyEyeLNF()

//你的代码UIManager.setLookAndFeel(....)

} catch (Exception e) {

e.printStackTrace()

}

new TestDemo()

}

}