- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将程序中的 LookAndFeel 更改为“windows”。Clean and Build 之后,我运行 .jar 文件,但 LookAndFeel 已更改。当我在 Netbeans 中编译程序时,我选择的“windows”LookAndFeel 工作正常。
问题出在哪里?有图书馆错过了吗?
来自德国的问候,帕特里克
public class main{
final private static String lookAndFeel = "Windows";
public static String getLookAndFeel(){
return lookAndFeel;}
[...]
}
在我的帧级:
public static void main(String args[]){
main ref = new main();
String lookAndFeel = ref.getLookAndFeel;
try{
for(javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()){
if(lookAndFeel.equals(info.getName())){
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}}}catch[...]
最佳答案
您的代码是正确的。可能是你在另一边做错了。这是一个可以帮助您解决问题的示例。
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UnsupportedLookAndFeelException;
public class LookAndFeel {
public static void main(String... args) {
String lookAndFeel = "Windows";
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if (lookAndFeel.equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
System.out.println("ERROR : " + ex);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame f = new JFrame("TESTING");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500, 300);
f.setLayout(new java.awt.FlowLayout());
f.add(new JButton("Click ME"));
f.setVisible(true);
}
});
}
}
我在我的 PC 上使用 Netbeans 运行它,也通过 CMD 运行它,它工作正常。
在 Clean and Build
之后,您将在项目的 dist
目录中获得一个 .jar 文件。
到达 dist
目录后,在 cmd 中写入以下命令。
java -jar MyProject.jar
其中 MyProject
是我创建的项目的名称。
这是我在每种情况下在我的 PC 上得到的输出:
关于java - Build 后 LookAndFeel 发生了变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25302157/
我正在使用 JTattoo 来更改我的应用程序 LookAndFeel。我知道如何设置任何可用的皮肤,但现在我希望用户能够选择其中任何一个。带有 LAF 的字符串被保存在一个文件中,因此每次运行该程序
This page列出了一种使用 DevExpress 10.2 更改 .net 应用程序的默认 LookandFeel 的方法。它不适合我。 我的代码(在 Main() 中) imports Dev
我创建了一个 JPopupmenu 并添加了一个 JTextField。当我使用 metal 或 nimbus 时,一切都很好。问题是当我将 LookAndFeel 切换到 Windows 时。我不能
我需要将 LookAndFeel 接口(interface)的副本序列化到文件中。结果我写了以下代码: public class SerializableLookAndFeel extend Look
我正在尝试使用 JRadioButton 将它们放在 JToolbar 上并选择最后一个单击的按钮。如果我使用 JButtons,他们不会保留选择。 由于 JRadioButton 始终具有该点,因此
所以,我使用了 Substance LookAndFeel 皮肤之一。对于4.0版本的物质库,不存在这样的问题。然而,从那里开始,我第一次注意到它是在 4.3 中,它时不时地出现。然后,当我跳上新版本
我可以通过以下方式获取 LookAndFeel 列表 UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(
我希望能够即时更新我的 Swing GUI 的 LookAndFeel 属性。在这种情况下,我有一个简单的 Swing/Awt 游戏,它运行最初作为 Nimbus LookAndFeel 的游戏。
有谁知道这个“LookAndFeel”的名字吗?或者至少知道类似的?它真的很棒,我希望我可以将它用于我的程序。 http://www.axbo.com/webstart/aXbo.jnlp 最佳答案
是的,有些问题很接近:) Java 中有一个 Bug(自 2011 年以来一直存在并被报告,似乎也没有努力修复它 - 应该在 VM 的 native 端处理) 也就是说,当您最大化“未修饰”窗口或使用
当我在 java swing 代码中使用 SyntheticaBlackMoonLookAndFeel 时,我收到错误。下面是我的代码::我不知道为什么会出现错误? try { UIManag
如何列出所有可用的 LookAndFeel 主题?然后我想在 JComboBox 中显示以供用户选择。 最佳答案 其实很简单: public static UIManager.LookAndFeelI
我目前正在为我工作的公司的产品开发一组自定义控件。为此,我扩展了很多 Swing 控件并覆盖了很多 paint方法。 为了保持一致的配色方案,我使用 UIManager.getColor 为我的
有人知道为什么下面的代码中的 laf 没有改变吗? (在 Ubuntu 中运行) import java.awt.Dialog; import java.awt.event.ActionEvent;
我编写了一个程序,首先在测试 GUI 上更新 LookAndFeel。用户单击“选择”按钮后,LookAndFeel 将传递到主要 GUI 方法,该方法使用该选择创建一个新窗口。 它工作正常。虽然,随
我正在更改由 Custom 填充的 JTable 的 LookAndFeel JPanel 的类扩展,但我做不到。 我编辑了我的代码,但它仍然很长。 public class LAF_TableCus
我正在尝试更改 Substance 外观的文本颜色(实际上我正在使用 SubstanceGraphiteGlassLookAndFeel 。我不知道该怎么做... 最佳答案 最终你不得不搞乱配色方案。
我将程序中的 LookAndFeel 更改为“windows”。Clean and Build 之后,我运行 .jar 文件,但 LookAndFeel 已更改。当我在 Netbeans 中编译程序时
Java 6 中的 native Windows LookAndFeel 似乎无法正确调整某些字体的大小。 测试程序: import java.awt.*; import java.awt.event
我正在尝试序列化包含 JDesktopPane 和多个 JInternalFrame 的 JFrame。我遇到了 LookAndFeel 的问题,因为无论出于何种原因,都不可能将 Swing 组件与
我是一名优秀的程序员,十分优秀!