开发者

Netbeans JLabel anchor overpowers my layout managers

开发者 https://www.devze.com 2023-02-28 03:33 出处:网络
I know this has been asked alot and in various ways, and I have tried them, but with no success.i am using netbeans and swing to create my GUI.

I know this has been asked alot and in various ways, and I have tried them, but with no success. i am using netbeans and swing to create my GUI.

i have a Jlabel inside of a JPanel. Whenver I place the label inside the panel, it automatically anchors it to the closest component which is NOT what I want. I want to center the component, regardless of size.

However, creating custom JPanels in the "Code" section of the GUI editor to make a BoxLayout and GridBagLayout does not seem to work. It seems no matter what, it still anchors. You can see the attached jpg of what it is doing in my editor.

Netbeans JLabel anchor overpowers my layout managers

Anybody have some ideas?

As mentioned, I have tried to change the "Custom Creation Code" of the JPanel to do: new javax.swing.JPanel(new GridBagLayout());

and then removed the parent tag of my JLabel an开发者_如何学Cd added "Post-Creation Code" to be: statusPanel.add(versionLabel,new GridBagConstraints());

I have also tried typing out the GridBagConstraints to say centered.


Get a copy of NetBeans 7.0 They've just completely overhauled their GridBagLayout Visual Designer

You should be able to achieve this quite handily with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号