java lookandfeel怎么用_Java的LookAndFeel切换问题,急!

做一个swing的界面,用了jtattoo的一个LookAndFeel的包。在里面用一个JComboBox来切换界面,切换后用了SwingUtilities.updateComponentTreeUI(this);来更新LookAndFeel。但是切换的过...

做一个swing的界面,用了jtattoo的一个LookAndFeel的包。

在里面用一个JComboBox来切换界面,切换后用了

SwingUtilities.updateComponentTreeUI(this);来更新LookAndFeel。

但是切换的过程中,如果每次选择的都是没有用过的LookAndFeel,则显示正常;一旦选择了用的的LookAndFeel,边框就无法完全更新。

求教高手!!!

部分代码如下:

// ComboBox的响应方法

private void style_CboxActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

String name = (String) style_Cbox.getSelectedItem();

updateStyle(name);

pack();

}

// 更新LookAndFeel的方法

public void updateStyle(String name) {

try {

//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

if (name == "Aluminium") {

UIManager.setLookAndFeel(aluminium);

} else if (name == "Aero") {

UIManager.setLookAndFeel(aero);

} else if (name == "McWin") {

UIManager.setLookAndFeel(mcwin);

} else if (name == "Luna") {

UIManager.setLookAndFeel(luna);

} else if (name == "Mint") {

UIManager.setLookAndFeel(mint);

} else if (name == "Smart") {

UIManager.setLookAndFeel(smart);

} else if (name == "Acryl") {

UIManager.setLookAndFeel(acryl);

} else if (name == "Fast") {

UIManager

.setLookAndFeel(new com.jtattoo.plaf.fast.FastLookAndFeel());

}

SwingUtilities.updateComponentTreeUI(this);

SwingUtilities.updateComponentTreeUI(chDlg);

this.repaint();

update_UI();// 一个自设的方法,不用管

} catch (UnsupportedLookAndFeelException e) {

e.printStackTrace();

}

以上setLookAndFeel方法中的参数都是各种LookAndFeel的对象,例如:

MintLookAndFeel mint = new MintLookAndFeel();

回复1楼:

好像UIManager里没有getDefaults()这个方法。。有的话,类型也不是LookAndFeel

能不能给具体点?谢谢!

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值