Design GUI with NetBeans: What I design and what I view after run differ
I design GUI with NetBeans 7.0.1 using Swing components and NimbusLookAndFeel. Here is design view:
And here is runtime view:
Panel without buttons renders correctly... I 开发者_运维知识库got this error in other interfaces, and simply change panel size by hand so that it render correctly, but I want to solve this problem using anchors. Where should I look to make this thing work? Thanks.
The components are resizing due to being designed in the default look and feel, but then run under Nimbus. You can preview how they will look by going to the Inspector window, right clicking the JFrame/JDialog/etc, and selecting Preview Design -> Nimbus.
There may be a way to actually design the form using the Nimbus look and feel, but I am not aware of one.
In NetBeans 14, select Tools -> Options and select the Appearance tab. Then select the Look and Feel tab. Set the Preferred look and feel to the same as the one you selected for your app. Restart NetBeans. Then the Design View will display the components the same as in your App. Older versions of NetBeans put this control in a different place so you may have to look around (or update to the latest). Kudo to Steven for pointing out it is a Look and Feel problem
精彩评论