public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
加上
}
catch(Exception e) {
e.printStackTrace();
}
new Application1();
}
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
加上
}
catch(Exception e) {
e.printStackTrace();
}
new Application1();
}
解决方案 »
- 在线等!菜单栏setEnabled无效【期末大作业,明早要交】
- Socket为什么会出现java.net.NoRouteToHostException: No route to host错?
- 困惑
- 大家来帮忙!!!小弟跪求!!!!!
- 用javac命令编译时,如果有很多的.jar要import,那么有什么好方法包括进来吗????
- 两个基础问题:1:java.sql.Date 2:ResultSet
- JBuilder的问题:如何用JDatastror explorer连接sql server?如何编程连接Sql server
- 线程有几种状态?
- 高手们!帮帮忙呀!!!
- java用循环输入一组数据,异常后如果继续输入
- 看看我對class method 和 instance method 的理解,及implicit argument&explicit argument.
- java中怎样实现修改本机IP?
/**
@version 1.30 2000-05-07
@author Cay Horstmann
*/import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class PlafTest
{
public static void main(String[] args)
{
PlafFrame frame = new PlafFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}/**
A frame with a button panel for changing look and feel
*/
class PlafFrame extends JFrame
{
public PlafFrame()
{
setTitle("PlafTest");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // add panel to frame PlafPanel panel = new PlafPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
} public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 200;
}/**
A panel with buttons to change the pluggable look and feel
*/
class PlafPanel extends JPanel
{
public PlafPanel()
{
makeButton("Metal",
"javax.swing.plaf.metal.MetalLookAndFeel");
makeButton("Motif",
"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
makeButton("Windows",
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} /**
Makes a button to change the pluggable look and feel.
@param name the button name
@param plafName the name of the look and feel class
*/
void makeButton(String name, final String plafName)
{
// add button to panel JButton button = new JButton(name);
add(button);
// set button action button.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
// button action: switch to the new look and feel
try
{
UIManager.setLookAndFeel(plafName);
SwingUtilities.updateComponentTreeUI
(PlafPanel.this);
}
catch(Exception e) { e.printStackTrace(); }
}
});
}
}
public void loadLookAndFeel( String name ) {
Properties dbProps = new Properties();
try
{
InputStream is = new FileInputStream( "lookandfeel.properties" );
dbProps.load( is );
}
catch ( Exception e )
{
System.out.println( "Can't read the properties file..." );
return;
}
String lookandfeel = props.getProperty( "LookAndFeel" );
try{
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
UIManager.setLookAndFeel(lookandfeel);
//SwingUtilities.updateComponentTreeUI(f);
}
catch(Exception e3){
System.out.println("Look And Feel Exception");
System.exit(0);
}
}
另外自己编写相应的properties文件,放到你的程序可以找到的目录下!!