try
{
UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
}
想问一下大家如何添加com.birosoft.liquid.LiquidLookAndFeel这样的参数呢?
我们怎么样才能知道里面的路径呢?(不同的皮肤包不一样的嘛!);
还有我用了个苹果的皮肤包,怎么setBackground这个命令就失效了呢?就是固定的模式,还有我的字体也无法改了呢?
[我的swing.properties内容是这样的::
swing.installedlafs = motif,windows,metal,mac,liquid
swing.installedlaf.motif.name = CDE/Motif
swing.installedlaf.motif.class = com.sun.java.swing.plaf.motif.MotifLookAndFeel
swing.installedlaf.windows.name = Windows
swing.installedlaf.windows.class = com.sun.java.swing.plaf.windows.WindowsLookAndFeel
swing.installedlaf.metal.name = Metal
swing.installedlaf.metal.class = javax.swing.plaf.metal.MetalLookAndFeel
swing.installedlaf.mac.name = Mac
swing.installedlaf.mac.class = com.sun.java.swing.plaf.mac.MacLookAndFeel
swing.installedlaf.liquid.name = Liquid
swing.installedlaf.liquid.class = com.birosoft.liquid.LiquidLookAndFeel
swing.defaultlaf=com.birosoft.liquid.LiquidLookAndFeel]希望大家帮帮忙啊,如果解决了马上给分,如果某个人解决分归给他一个人!(如果你有空的话,麻烦解释lookandfeel到底是怎么一回事,顺便搞个例子)谢谢了
{
UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
}
想问一下大家如何添加com.birosoft.liquid.LiquidLookAndFeel这样的参数呢?
我们怎么样才能知道里面的路径呢?(不同的皮肤包不一样的嘛!);
还有我用了个苹果的皮肤包,怎么setBackground这个命令就失效了呢?就是固定的模式,还有我的字体也无法改了呢?
[我的swing.properties内容是这样的::
swing.installedlafs = motif,windows,metal,mac,liquid
swing.installedlaf.motif.name = CDE/Motif
swing.installedlaf.motif.class = com.sun.java.swing.plaf.motif.MotifLookAndFeel
swing.installedlaf.windows.name = Windows
swing.installedlaf.windows.class = com.sun.java.swing.plaf.windows.WindowsLookAndFeel
swing.installedlaf.metal.name = Metal
swing.installedlaf.metal.class = javax.swing.plaf.metal.MetalLookAndFeel
swing.installedlaf.mac.name = Mac
swing.installedlaf.mac.class = com.sun.java.swing.plaf.mac.MacLookAndFeel
swing.installedlaf.liquid.name = Liquid
swing.installedlaf.liquid.class = com.birosoft.liquid.LiquidLookAndFeel
swing.defaultlaf=com.birosoft.liquid.LiquidLookAndFeel]希望大家帮帮忙啊,如果解决了马上给分,如果某个人解决分归给他一个人!(如果你有空的话,麻烦解释lookandfeel到底是怎么一回事,顺便搞个例子)谢谢了
swt是什么东西啊?是不是java 开始界面的工具啊 !
都没人反应吗?
跪求大家帮帮忙啊
看你的包名,应该不是标准类库里面的,
也就是说,即使你这个程序在你电脑上能调式出来
但是在别的电脑上是调式不出来的,
所以建议你用LookAndFeel,最好是用SUN自带的
类似于这有的东西:com.birosoft.liquid.LiquidLookAndFeel
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class StyleChooser extends JPanel {
static JFrame frame;
static String metal = "Metal";
static String metalClassName = "javax.swing.plaf.metal.MetalLookAndFeel";
static String motif = "Motif";
static String motifClassName =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
static String windows = "Windows";
static String windowsClassName =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
JRadioButton metalButton, motifButton, windowsButton;
public StyleChooser() {
//建立一個提示標籤
JLabel label = new JLabel("Try the stytle Swing has");
metalButton = new JRadioButton(metal);
metalButton.setMnemonic('c');
metalButton.setActionCommand(metalClassName); motifButton = new JRadioButton(motif);
motifButton.setMnemonic('m');
motifButton.setActionCommand(motifClassName); windowsButton = new JRadioButton(windows);
windowsButton.setMnemonic('w');
windowsButton.setActionCommand(windowsClassName);
//將RadioButton歸為同一組
ButtonGroup group = new ButtonGroup();
group.add(metalButton);
group.add(motifButton);
group.add(windowsButton);
// Register a listener for the radio buttons.
RadioListener myListener = new RadioListener();
metalButton.addActionListener(myListener);
motifButton.addActionListener(myListener);
windowsButton.addActionListener(myListener); add(label);
add(metalButton);
add(motifButton);
add(windowsButton);
} //加入一個事件監聽器處理選擇RadioButton事件
class RadioListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String InfName = e.getActionCommand();
try {
UIManager.setLookAndFeel(InfName);
SwingUtilities.updateComponentTreeUI(frame);
frame.pack();
} catch (Exception ex) {
JRadioButton button = (JRadioButton) e.getSource();
button.setEnabled(false);
updateState();
System.err.println("Could not load LookAndFeel:" + InfName);
}
}
}
public void updateState() {
String InfName = UIManager.getLookAndFeel().getClass().getName();
if (InfName.indexOf(metal) >= 0) {
metalButton.setSelected(true);
} else if (InfName.indexOf(windows) >= 0) {
windowsButton.setSelected(true);
} else if (InfName.indexOf(motif) >= 0) {
motifButton.setSelected(true);
} else {
System.err.println("StyleChooser is using an unknown L&F:" +
InfName);
}
} public static void main(String[] args) {
StyleChooser panel = new StyleChooser();
frame = new JFrame("StyleChooser");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.getContentPane().add("Center", panel); ;
frame.pack();
frame.setVisible(true);
panel.updateState();
}
}
// Possible Look & Feels
private static final String mac =
"com.sun.java.swing.plaf.mac.MacLookAndFeel";
private static final String metal =
"javax.swing.plaf.metal.MetalLookAndFeel";
private static final String motif =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
private static final String windows =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
private static final String gtk =
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
每一种对应的样子你可以运行jdk目录下demo/jfc/swingset2/swingset2.jar如果你需要设置自己定义的字体,参考下面的代码
FontUIResource f = new javax.swing.plaf.FontUIResource(new Font(....));
java.util.Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get(key);
if (value instanceof javax.swing.plaf.FontUIResource) {
UIManager.put(key, f);
}
}
欢迎大家到这个贴上讨论