jSeparator外观-预览设计与运行文件(netbeans) [英] jSeparator looks - Preview Design vs Run File (netbeans)

查看:104
本文介绍了jSeparator外观-预览设计与运行文件(netbeans)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个小问题.我正在使用Netbeans.当我单击预览设计"时,我看到这样的jSeparators:

I have this little problem. I'm using Netbeans. When I click on Preview Design I see the jSeparators like this:

但是当我运行项目时,它是这样的:

But when I run the project this is what it looks like:

如何解决此问题?我希望项目看起来像预览设计.

How can I fix this problem? I want the project to look like the Preview Design.

谢谢!

推荐答案

在预览设计"中运行窗口(JFrameJDialog)/组件(JPanel)时,将使用系统外观进行显示,但是当您运行应用程序时, UIManager 使用一个跨平台L& F,默认情况下也称为Metal L& F.

When you run your window (JFrame, JDialog) / component (JPanel) in Preview Design it's displayed using system look and feel, but when you run your application UIManager uses a cross-platform L&F by default, also called Metal L&F.

我希望项目看起来像预览设计.

查看相关内容:

  • How to Set the Look and Feel
  • How to set jframe look and feel

这是反对使用GUI构建器的争论之一.您将使用预览设计"对所有组件进行布局,以排列所有组件.假设您使用Windows,现在将外观设置为系统L& F,因此在您的计算机中,您的应用程序可以正常运行并显示:

This is one of the arguments against the use of GUI builders. You will lay-out all your components using Preview Design to arrange all your components. Let's say you use Windows and now you set the look and feel to system L&F so in your computer your application runs and displays prefectly:

public static void main(Strin[] args) {
    ...
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    ...
}

太棒了,它有效!现在,假设您的一个朋友喜欢您的应用程序,然后将其与您的朋友共享.事实证明您的伴侣使用Linux或Mac ...然后系统外观不再是Windows,GUI可能看起来很糟糕.例如,请考虑以下帖子:不同的外观beetwen Preview和Runview 您可以在第二张图片中看到组件的最后一行被切成两半.

Awesome, it works! Now lets say a friend of yours likes your application and you share it with your friend. It turns out your mate uses Linux or Mac... Then the system look and feel won't be Windows anymore and GUI will probably look terrible. For instance consider this post: Different looks beetwen Preview and Runview You can see in the second picture that last row of components is cut in the half.

发生这种情况是因为NetBeans使用的 Layout Manager GUI构建器是 GroupLayout ,旨在与GUI构建器,让它在与您的平台不同的平台上工作真是让人头疼(很抱歉,表达方式是对的,但这是事实).

This happens because the Layout Manager used by NetBeans GUI builder is GroupLayout, which is designed to be used with GUI builders and it can be a really pain in the ass (sorry for the expression, but it's true) to make it work in a different platform than yours.

根据我的经验,我曾使用Builder进行过两个较小的项目,这些项目旨在全部在同一平台上运行,但是当我真的不得不开发跨平台应用程序时,这真是一场噩梦.因此,我强烈建议您不要使用GUI构建器,而要手工编写GUI.

In my experience I've used builder for a couple of minor projects, intended to run all in the same platform, but when I really had to develop a cross-platform application it turns out a nightmare. So I strongly recommend you to forget about GUI builders and write your GUIs by hand.

请参见 NetBeans中的GroupLayout自动生成的代码.有很多非常好的布局管理器,可以使您的生活更轻松,并且您的应用程序UI真正跨平台,就像任何Java应用程序一样.

See GroupLayout autogenerated code in NetBeans. There is a list of really good layout managers that can make your life easier and your applications UI truly cross-platform, as any Java application is supposed to be.

这篇关于jSeparator外观-预览设计与运行文件(netbeans)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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