java 自定义外观(整理)
2006-03-14 21:07
435 查看
1。JAVA程序默认的外观(LOOKANDFEEL)可以改变为JAVA外观、MOTIF外观、WINDOWS外观、MAC外观;而JAVA外观又有五种风格分别是海蓝宝石风格、祖母绿风格、红宝石风格、木炭风格、高对比风格。
改变默认外观可以使用:
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel") ;
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") ;
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel") ;
2。采用菜单选择外观的示例程序(转):
import javax.swing.*;
JMenuBar mb = new JMenuBar();
JMenu file = new JMenu("Look & Feel", true);
ButtonGroup buttonGroup = new ButtonGroup();
final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
for (int i = 0; i < info.length; i++) {
JRadioButtonMenuItem item = new
JRadioButtonMenuItem(info[i].getName(), i == 0);
final String className = info[i].getClassName();
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try { UIManager.setLookAndFeel(className); }
catch (Exception e) { System.out.println(e); }
SwingUtilities.updateComponentTreeUI(TouchyFeely.this); }
});
buttonGroup.add(item);
file.add(item);
}
mb.add(file);
setJMenuBar(mb);
}
3。一个有关已完成的外观介绍下载的地址:http://www.javaresearch.org/article/showarticle.jsp?column=31&thread=46967
4。Eclipse + VE 时应用自定义外观的方法(from Eclipse Help ):
To add a new Swing look and feel:
Add the JAR file with your look and feel to the Java Build Path.
Download or create a new look and feel and save to a local directory.
Unzip to the Project directory where you want to include the new Look and Feel.
In the Project Explorer, right-click the project name.
Click Properties > Java Build Path > Libraries.
Click Add External Jars and browse to the JAR file that contains the look and feel, then click OK. Now, you are ready to apply the new Look and Feel to your application.
Add the look and feel to the visual editor preferences:
Open the Preferences window by clicking Window > Preferences, and select Java > Visual Editor.
Next to the Swing Look and Feel table on the Appearance tab, click New.
Provide a Name and the Class for the new look and feel. The LookAndFeel class name should be in the documentation for the look and feel. If you cannot locate the look and feel class name, you can find the class name by right-clicking the JAR file that you added to your project, and pressing F4 to open its hierarchy.
Click OK to close the Look and Feel dialog.
Select the check box next to the new look and feel.
Click OK to save your preferences.
Close your application, then open it again to see the new Look and Feel.
5。一个定制UI的文章(JDK1.5 Synth 外观):http://java.chinaitlab.com/Swing/38394.html
改变默认外观可以使用:
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel") ;
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") ;
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel") ;
2。采用菜单选择外观的示例程序(转):
import javax.swing.*;
JMenuBar mb = new JMenuBar();
JMenu file = new JMenu("Look & Feel", true);
ButtonGroup buttonGroup = new ButtonGroup();
final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
for (int i = 0; i < info.length; i++) {
JRadioButtonMenuItem item = new
JRadioButtonMenuItem(info[i].getName(), i == 0);
final String className = info[i].getClassName();
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try { UIManager.setLookAndFeel(className); }
catch (Exception e) { System.out.println(e); }
SwingUtilities.updateComponentTreeUI(TouchyFeely.this); }
});
buttonGroup.add(item);
file.add(item);
}
mb.add(file);
setJMenuBar(mb);
}
3。一个有关已完成的外观介绍下载的地址:http://www.javaresearch.org/article/showarticle.jsp?column=31&thread=46967
4。Eclipse + VE 时应用自定义外观的方法(from Eclipse Help ):
To add a new Swing look and feel:
Add the JAR file with your look and feel to the Java Build Path.
Download or create a new look and feel and save to a local directory.
Unzip to the Project directory where you want to include the new Look and Feel.
In the Project Explorer, right-click the project name.
Click Properties > Java Build Path > Libraries.
Click Add External Jars and browse to the JAR file that contains the look and feel, then click OK. Now, you are ready to apply the new Look and Feel to your application.
Add the look and feel to the visual editor preferences:
Open the Preferences window by clicking Window > Preferences, and select Java > Visual Editor.
Next to the Swing Look and Feel table on the Appearance tab, click New.
Provide a Name and the Class for the new look and feel. The LookAndFeel class name should be in the documentation for the look and feel. If you cannot locate the look and feel class name, you can find the class name by right-clicking the JAR file that you added to your project, and pressing F4 to open its hierarchy.
Click OK to close the Look and Feel dialog.
Select the check box next to the new look and feel.
Click OK to save your preferences.
Close your application, then open it again to see the new Look and Feel.
5。一个定制UI的文章(JDK1.5 Synth 外观):http://java.chinaitlab.com/Swing/38394.html
相关文章推荐
- Java中Synth外观学习(一)--建立工程加载自定义外观的XML文件
- java自定义按钮外观
- Java自定义异常_动力节点Java学院整理
- Java中Synth外观学习(四)--定制JPanel的背景,自定义绘制
- java自定义按钮外观
- java自定义按钮外观
- 自定义JButton外观(Java)
- java自定义按钮外观
- java自定义按钮外观
- java自定义按钮外观
- java,python,php 数组基础整理
- Java进阶资料整理集
- Java使用图片自定义登录窗体
- 自学Java系列 笔记5 整理note
- java设计模式之外观模式
- JAVA程序员面试总结,高手整整理加强版 出自“CSDN(www.csdn.net)”
- 自定义注解、Java启动spring
- 开发整理-Javaweb应用的系统升级功能
- Java中RTTI(Java编程思想第14章--类型信息)整理
- 深入理解Java:注解(Annotation)自定义注解入门