在frame中添加:
UIManager.addPropertyChangeListener(new UISwitchListener( (JComponent)getRootPane()));UISwitchListener.java
========================================================================
import java.beans.*;
import javax.swing.*;/**
* This class listens for UISwitches, and updates a given component.
*
* @version 1.8 01/23/03
* @author Steve Wilson
*/
public class UISwitchListener
implements PropertyChangeListener {
JComponent componentToSwitch; public UISwitchListener(JComponent c) {
componentToSwitch = c;
} public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
if (name.equals("lookAndFeel")) {
SwingUtilities.updateComponentTreeUI(componentToSwitch);
componentToSwitch.invalidate();
componentToSwitch.validate();
componentToSwitch.repaint();
}
}
}
========================================================================具体可以参考jdk的demo\jfc\Metalworks\src
UIManager.addPropertyChangeListener(new UISwitchListener( (JComponent)getRootPane()));UISwitchListener.java
========================================================================
import java.beans.*;
import javax.swing.*;/**
* This class listens for UISwitches, and updates a given component.
*
* @version 1.8 01/23/03
* @author Steve Wilson
*/
public class UISwitchListener
implements PropertyChangeListener {
JComponent componentToSwitch; public UISwitchListener(JComponent c) {
componentToSwitch = c;
} public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
if (name.equals("lookAndFeel")) {
SwingUtilities.updateComponentTreeUI(componentToSwitch);
componentToSwitch.invalidate();
componentToSwitch.validate();
componentToSwitch.repaint();
}
}
}
========================================================================具体可以参考jdk的demo\jfc\Metalworks\src
解决方案 »
- 谁能告诉我怎么把以前的老项目转变成WTP项目
- Tomcat的一个异常
- 现在还有哪里可以下载到不基于Eclipse的JBuilder
- JCreatorPro运行未响应
- JAVA求救,急啊急啊
- 上传附件的问题 下面的函数是判断附件是否存在,但是走到objStream.LoadFromFile(strFileName);退到catch里,在我的机器上是好用的,但是
- JDBC驱动加载失败的问题
- help me
- 问一下怎么用java模拟遍历,添加和删除二叉树?
- j2SDK帮助文件在哪下载?
- 在Java包中的两个类(放在两个文件中)如何互相引用?
- 请教高手一个问题,虽然我已无分可用,但请DX们务必帮忙啊!!
但是Frame没有得到更新.还是原来的!