简体   繁体   English

在Macintosh上使用Swing GUI出现问题

[英]Problem with Swing GUI on Macintosh

I am new to Swing. 我是Swing的新手。

Are there any specific issues related to customizing the paint operation on the Mac? 在Mac上自定义绘画操作是否有任何特定问题?

I have developed a sample application using NetBeans + Swing on Windows. 我已经在Windows上使用NetBeans + Swing开发了一个示例应用程序。 It is working fine. 一切正常。 But if I run the same application on a Mac, panels' buttons' labels don't appear on the screen. 但是,如果我在Mac上运行相同的应用程序,则面板的按钮标签不会出现在屏幕上。 Only when the mouse over operation is performed on particular component does it get displayed on the screen. 仅当对特定组件执行鼠标悬停操作时,它才会显示在屏幕上。

Kindly can anyone help me out in solving this issue? 有人可以帮助我解决这个问题吗?

Thanks in advance. 提前致谢。 sakkiharry 萨基哈里

Since Swing paints all UI itself, it is not really influenced by Mac OS. 由于Swing绘制了所有UI本身,因此它实际上不受Mac OS的影响。 There are exceptions, though. 但是也有例外。 If you allow Java to use a native menu, the menu will behave like any other Swing menu, but it is in fact translated to native menu functions (so it will be displayed on top of screen and behave like a native Mac OS X menu... nothing you as programmer need to care about, but great for Mac users, who hate menus to appear elsewhere). 如果允许Java使用本机菜单,则该菜单的行为将与其他任何Swing菜单一样,但实际上已转换为本机菜单功能(因此它将显示在屏幕顶部,并且其行为类似于本机Mac OS X菜单。 ..作为程序员,您无需担心,但对讨厌菜单出现在其他位置的Mac用户而言非常有用。

I guess your issue is probably something else, but it's hard to guess, if I have no code to work with. 我想您的问题可能还有其他问题,但是如果我没有代码可以使用,则很难猜测。 Can you break down the issue into an ultra minimal test case? 您可以将问题分解为一个极小的测试用例吗? Eg can you just draw a JFrame, add a singe one of your custom buttons there, that shows the problematic behavior and just use as much code as is necessary to paint this minimal UI and expose the problem? 例如,您可以只绘制一个JFrame,在其中添加一个自定义按钮,以显示有问题的行为,并使用必要的代码来绘制最小的UI并暴露问题吗? If you'd post this code here, I'd take a closer look into it and will try to find out what causes the issue and how to resolve it (I'm a graduated Java programmer, but I also have years of Mac OS X development experience; so these are two fields of knowledge I should know really well, but I usually don't combine them, as I don't develop in Java for Mac OS X). 如果您在此处发布此代码,我将对其进行仔细研究,并将尝试找出导致该问题的原因以及如何解决该问题(我是Java程序员,但我也有多年的Mac OS X开发经验;因此,我应该非常了解这两个知识领域,但是由于我不是在Mac OS X的Java中开发的,所以我通常不将它们结合在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM