Mac上的小应用程序UI组合框的问题 [英] ComboBox issue on Mac applet UI

查看:263
本文介绍了Mac上的小应用程序UI组合框的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Java Swing和小应用程序的用户界面,我已经开发了一个小程序在Mac和Windows上运行,该功能运行正常,但在苹果的用户界面特别是当我尝试选择在组合框中的项目毁损形状(加扰),并没有显示值如下面的图像。但是,相同的用户界面在Windows中工作正常。
我试图在我的code。在小程序的开始添加这些行仍然不起作用。

I am new to java swing and applet UI, i have developed a applet to run on mac and windows, The functionality works fine , But the UI in Mac specially when i try to select the items in combo box disfigures the shape (Scrambles) and doesn't show values as in image below. But the same UI works fine in Windows. i Have tried to add these lines in my code at start of applet still it does not work.

UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());

和还设置了组合框使用不透明

and also set the combo boxes opaque using

group.setOpaque(true);

exception occurred is
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at com.apple.laf.AquaMenuPainter.paintSelectedMenuItemBackground(AquaMenuPainter.java:153)
at com.apple.laf.AquaComboBoxRendererInternal.paintComponent(AquaComboBoxRenderer.java:151)
at javax.swing.JComponent.paint(JComponent.java:1054)
at javax.swing.CellRendererPane.paintComponent(CellRendererPane.java:151)
at javax.swing.plaf.basic.BasicListUI.paintCell(BasicListUI.java:227)
at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:317)
at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:240)

下面我附上了图片

Below i have attached the images


推荐答案

使用此code。在您的设计开始它会正常工作,我面临同样的问题了。

Use this code at start of your design it will work fine , I was facing the same issue too.

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

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

下面是面临的UI问题的链接的Java文档

Here is the link for java doc for the issue faced in UI

Java文档的用户界面的外观和感觉

这篇关于Mac上的小应用程序UI组合框的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆