如何设置文本背景颜色JOptionPane?
图片:

UIManager UI = new UIManager();
UI.put("OptionPane.background", Color.white);
UIManager.put("Button.background", Color.white);
UI.put("Panel.background", Color.white);
UI.put("OptionPane.foreground", Color.white);
UI.put("OptionPane.messagebackground", Color.white);
UI.put("OptionPane.textbackground", Color.white);
UI.put("OptionPane.warningDialog.titlePane.shadow", Color.white);
UI.put("OptionPane.warningDialog.border.background", Color.white);
UI.put("OptionPane.warningDialog.titlePane.background", Color.white);
UI.put("OptionPane.warningDialog.titlePane.foreground", Color.white);
UI.put("OptionPane.questionDialog.border.background", Color.white);
UI.put("OptionPane.questionDialog.titlePane.background", Color.white);
UI.put("OptionPane.questionDialog.titlePane.foreground", Color.white);
UI.put("OptionPane.questionDialog.titlePane.shadow", Color.white);
UI.put("OptionPane.messageForeground", Color.white);
UI.put("OptionPane.foreground", Color.white);
UI.put("OptionPane.errorDialog.border.background", Color.white);
UI.put("OptionPane.errorDialog.titlePane.background", Color.white);
UI.put("OptionPane.errorDialog.titlePane.foreground", Color.white);
UI.put("OptionPane.errorDialog.titlePane.shadow", Color.white);
JOptionPane.showMessageDialog(null, "Hello world", "HELLO WORLD", JOptionPane.INFORMATION_MESSAGE);
Run Code Online (Sandbox Code Playgroud) 有没有一种特定的方法来改变swing应用程序的外观和感觉,而不需要在每次LAF被用户更改时重新启动应用程序?
我正在寻找一个解决方案,在这个解决方案中,可以从配置对话框中选择LAF并直接在应用中进行更改,而不必回退告诉用户重新启动应用程序.
目前我记得属性文件中选择的LAF,并在打开任何窗口之前在启动时设置它.
如何在Java中创建一个如下所示的窗口:

我想要窗口布局,而不是标准的Windows边框,我不知道如何调用它.
编辑:外观对我来说不起作用:

我想知道如何自定义 jtextfield 的 ui,以便我可以创建圆角矩形边框,而文档不会超出边框。
到目前为止,我想我已经尝试了我能想到的大部分内容,我创建了一个新的 FieldView 类,并根据我绘制圆形矩形的自定义边框更改了paint方法中的形状,这是我设法获得的唯一方法摆脱白色文本字段文档/视图是将其设置为不透明,但我认为应该有另一种方法而不设置不透明值。
您是否有任何自定义 jtextfield 的 laf 的经验,请回信,我什至没有运气读过 Core Swing 高级书籍,如果您尝试使用谷歌搜索,请告诉我搜索词组,因为我已经尝试过使用“样式”等关键字,"customizing","ui","plaf","laf"等等。
我真诚地希望你能在正确的方向上给我一个推动,我希望没有人会因此而战,我真的用尽了我能想到的所有资源。
诚挚的问候。
我最近在本地下载并构建了qt 4.7.4,但是自从使用它以来我遇到了一个问题.我没有得到Windows 7的外观和感觉.我没有4.6.3这个问题.这是我的designer.exe的样子:

即使我尝试使用以下命令打开应用程序,我仍然保持这种外观:
designer.exe -style windowsxp
designer.exe -style windowsvista
Run Code Online (Sandbox Code Playgroud)
我尝试用CDE和Plastique样式打开应用程序,然后将这些应用程序应用到应用程序中.
我的Qt GUI项目也保留了这种外观和感觉.欢迎任何帮助或想法.
编辑:
我的Qt配置如下:
-opensource -platform win32-g++ -qt-sql-sqlite -no-qt3support -no-3dnow
-no-phonon -no-multimedia -no-audio-backend -no-webkit -no-native-gestures
-no-qmake
Run Code Online (Sandbox Code Playgroud) 有没有办法更改swing组件(例如JPanel)的所有实例的默认背景绘画,以绘制渐变背景?或者我是否需要创建一个使用渐变绘制的JPanel扩展,然后在我的应用程序中使用它而不是JPanel?
我有一个Java Swing项目,可以在Windows和Ubuntu上正常工作.我没有任何Mac,所以我无法测试它; 我使用Nimbus主题作为该项目的标准.
现在,最近我的朋友在Eclipse和导出的jar中测试了同一个项目,它提供的错误并没有引用我所做的任何特定Java类.
它确实显示了GUI,但有时它会粘住,或者有时菜单丢失.
以下是启动GUI时显示的错误版本:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.apple.laf.AquaMenuPainter.paintMenuBarBackground(AquaMenuPainter.java:123)
at com.apple.laf.AquaMenuUI.paintBackground(AquaMenuUI.java:57)
at com.apple.laf.AquaMenuPainter.paintMenuItem(AquaMenuPainter.java:160)
at com.apple.laf.AquaMenuUI.paintMenuItem(AquaMenuUI.java:35)
at javax.swing.plaf.basic.BasicMenuItemUI.paint(BasicMenuItemUI.java:452)
at javax.swing.plaf.basic.BasicMenuItemUI.update(BasicMenuItemUI.java:448)
at javax.swing.JComponent.paintComponent(JComponent.java:752)
at javax.swing.JComponent.paint(JComponent.java:1029)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:34)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
Run Code Online (Sandbox Code Playgroud)
你能告诉我可能是什么问题,还是我应该在Mac上使用任何具体的外观主题?Mac上是否不支持Nimbus,如果是,那么我应该使用什么?
我已经浏览了这个网站改变外观和感觉,JSlider
但除了Slider.altTrackColor没有其他工作.我想做一些像pic1所示的事情,任何建议都会有很大的帮助.我正在研究JDK 1.6.
UIDefaults defaults = UIManager.getDefaults();
defaults.put("Slider.altTrackColor", Color.red);
defaults.put("Slider.thumb", Color.red);
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
WindowUtilities.setNativeLookAndFeel();
// WindowUtilities.setNimbuzzLookAndFeel();
// WindowUtilities.setJavaLookAndFeel();
Run Code Online (Sandbox Code Playgroud)
WindowUtilities是一个类,它告诉系统使用本机外观,就像在以前的版本中一样.Metal(Java)LAF是默认值.
public static void setNativeLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
System.out.println("Error setting native LAF: " + e);
}
Run Code Online (Sandbox Code Playgroud)

我正在构建一个java应用程序,我想在运行时使用这些单选按钮更改应用程序的主题(外观和感觉).我不知道怎么做!

提前致谢!
当我使用Swing为GUI启动Java应用程序时,我注意到Mac上Swing仍然呈现"旧"Mac UI(10.9及更早版本).由于Oracle现在负责为Mac OS X编写JRE - 我在哪里可以找到任何新UI?
或者那里有其他选择吗?
look-and-feel ×10
java ×9
swing ×9
nimbus ×2
gradient ×1
japplet ×1
jslider ×1
jtextfield ×1
macos ×1
netbeans ×1
osx-yosemite ×1
qt ×1
qt-creator ×1
qt4.7 ×1
themes ×1