我们正试图从我们的应用程序中获取quaqua.我们一直在使用quaqua调用将字体大小设置得更小,调用如下:
System.setProperty("Quaqua.sizeStyle", "small");
Run Code Online (Sandbox Code Playgroud)
没有使用quaqua,是否容易做同样的事情?或者有没有人知道OS X的另一个好看的外观和感觉?
我在java中使用外观和感觉工作很多并且它运行良好但唯一的问题是唯一没有变化的组件是标题栏(标题)仍然具有相同的原生外观和操作系统(以windows平台为例)
我想知道是什么原因以及如何解决这个问题?任何身体帮助..........
提前致谢
我正在寻找几个月前使用的工具,但我无法记住这个名字.
这是一个用于自定义Nimbus Swing外观的图形工具.在窗口的右侧,有一组示例Swing组件,左侧是所有可自定义属性的列表(与结果相同UIManager.getDefaults()).该工具允许更改属性的值(颜色,字体,整数值),并实时查看右侧的结果.
该工具也允许导出文件中的更改(设置自定义值的Java代码).
我记得整个程序只是一个大的java文件.我认为这个工具是另一个项目的一部分(该工具是独立的).
对于我的任务,我需要在JFrame中的网格JPanel中使用JButtons的二维数组.单击时,JButtons必须更改颜色.我不能让他们持有任何颜色.
我实现了前一个线程中提出的解决方案,发现只能生成边框颜色:
JButton button = new JButton("test");
button.setBackground(Color.RED);
button.setOpaque(true);
Run Code Online (Sandbox Code Playgroud)
没有边界:
button.setBorderPainted(false);
Run Code Online (Sandbox Code Playgroud)
只是导致整个JFrame变红.
此问题仅适用于MAC计算机,而不是分配的预期问题.
有什么想法吗?
我在我的网络应用程序中使用PrimeFaces 3.4,对于特定页面,控件不会与普通的PrimeFaces皮肤一起显示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>VMS login</title>
</h:head>
<h:body>
<h:form id="loginForm">
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
<p:panel header="#{msgs['login.title']}">
<p:panelGrid id="loginPanel" columns="2">
<h:outputText value="#{msgs['login.username']}" />
<p:inputText id="j_username" value="#{loginFormBean.userName}" required="true"></p:inputText>
<p:message for="j_username" ></p:message>
<h:outputText value="#{msgs['login.password']}" />
<p:password id="j_password" value="#{loginFormBean.password}" required="true" feedback="false"></p:password>
<p:message for="j_password"></p:message>
<p:commandButton action="#{loginController.loginUsingSpringAuthenticationManager}" value="#{msgs['login.button']}" update="loginForm" ajax="true"></p:commandButton>
</p:panelGrid>
</p:panel>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
这输出到:

面板应该有一个标题,依此类推.
有趣的是,在我<p:layout>在布局中使用不同面板的另一个页面中,它们显示正常的PrimeFaces外观和感觉.
我究竟做错了什么?谢谢
我希望能够动态更新 Swing GUI 的 LookAndFeel 属性。在本例中,我有一个简单的 Swing/Awt 游戏,运行的内容最初是 Nimbus LookAndFeel。在启动后的各个时刻,我只想更改(比方说)一个细节:应用程序的背景颜色。
我可以通过这样做来更改背景颜色:
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
UIManager.getLookAndFeelDefaults().put("Panel.background", Color.RED);
SwingUtilities.updateComponentTreeUI(SomeGame.this);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这是“有效的”,因为应用程序的背景颜色会正确更改并且程序不会崩溃。但在命令行上我收到错误:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.synth.SynthLookAndFeel.paintRegion(SynthLookAndFeel.java:371)
at javax.swing.plaf.synth.SynthLookAndFeel.update(SynthLookAndFeel.java:335)
Run Code Online (Sandbox Code Playgroud)
显然,有些东西是空的,但我不知道它是什么或如何修复它。一定有什么我不明白的地方。我查看了有关在 Nimbus 中设置背景颜色并在启动后覆盖 LookAndFeel 信息的其他 StackOverflow 问题。
getLookAndFeelDefaults()我是否还需要指定其余的默认值?如何为JMenuBar其中的JMenu对象和对象设置自定义背景颜色?我试过.setBackgroundColor,它不起作用!
我正在写一个 custom JComponent,它应该看起来不同,外观和感觉不同。我打算ComponentUi至少为WindowsLookAndFeel、MetalLookAndFeel和有不同的类MotifLookAndFeel。
现在,虽然这项任务看起来很简单,但我无法找到如何使用自定义ComponentUi类轻松扩展现有外观。
我将如何ComponentUi为不同的外观和感觉注册正确的?这可能吗?如果没有,为不同的外观和感觉编写自定义组件的首选方法是什么?
更具体地说,目前我正在JComponent#updateUI我的自定义组件中覆盖以设置不同的ComponentUi实例:
@Override
public void updateUI() {
LookAndFeel feel = UIManager.getLookAndFeel();
if (feel instanceof WindowsLookAndFeel) {
setUI(MyWindowsCustomUi.createUI(this));
} else if (feel instanceof MotifLookAndFeel) {
setUI(MyMotivCustomUi.createUI(this));
} else if (feel instanceof MetalLookAndFeel) {
setUI(MyMetalCustomUi.createUI(this));
} else{
setUI(MyBasicCustomUi.createUI(this));
}
}
Run Code Online (Sandbox Code Playgroud)
但这种方法似乎完全违背了观感的目的和用处。我希望能够将其更改为以下内容:
public void updateUI() {
setUI((MyCustomUi)UIManager.getUI(this));
}
Run Code Online (Sandbox Code Playgroud)
这应该MyCustomUi为当前的外观设置正确的子类。
我知道,我可以通过创建每个支持的自定义子类来轻松实现这一点,在 eg 期间LookAndFeel注册相应的子类- 但这不是我想要做的。ComponentUiBasicLookAndFeel#initComponentDefaults(UIDefaults)
我正在使用 SystemLookAndFeel,它在我的按钮周围设置默认边框。
现在我想要一个股票黑色边框,但是当我设置边框时,它只会在默认边框周围添加我的新边框,所以我有两个。
如何在不删除 LookAndFeel 的情况下更改或删除边框?
另外:我正在使用 java 7 和 Win 8.1
我在 Netbeans 中安装了Darcula LAF,它可以正常工作。它修改了 IDE 的外观以及应用程序在“预览设计”弹出窗口和 GUI 生成器中的外观。
这是一个例子。
但是,在运行应用程序时不会保持外观。
这是一个例子。
使用此代码列出了已安装的外观
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
System.out.println(info.getName());
}
Run Code Online (Sandbox Code Playgroud)
显然,安装了 Darcula LaF。但是,它并未显示为已安装到编译器。有没有办法让我在维护 Netbeans 模块的同时为编译器获取 LaF?
我查看了下载页面、GitHub 页面,甚至Geertjan 的博客以获取有关该主题的信息,但没有发现与此相关的任何信息。
我确定我遗漏了一些非常明显的东西。不设置外观默认为金属,使用操作系统默认外观也不能解决问题。
感谢所有帮助,如果格式不正确,我深表歉意。
编辑:为了清晰起见,它仅在代码中设置为 Nimbus。有一些关于它在未设置为 Nimbus 时如何反应的屏幕截图。它默认为金属。我之前删除了将它设置为 Nimbus 的代码,它使用了 Metal。http://prntscr.com/bte2xg 过去我已将其设置为使用“Darcula”而不是 Nimbus,但它仍然使用 Metal。http://prntscr.com/bte2b5
过去我已将其设置为使用“darcula-1.0.0”而不是 Nimbus,但它仍然使用 Metal。http://prntscr.com/bte3nh
过去我已经将它设置为使用“darcula-1.0.0.jar”而不是 Nimbus,但它仍然使用 Metal。 http://prntscr.com/bte42m
过去我已将其设置为使用“com.bulenkov.darcula”,但它仍然使用 Metal。http://prntscr.com/bte3du
我只是将 Nimbus 留在那里,以便它出现在一些像样的东西中。