Java – component centric NetBeans, GUI Builder (group layout)
•
Java
I'm trying to design a JButton (an "OK" button), which looks good and must be horizontally centered in the included JFrame
I have taken several GUI builder tutorials( http://netbeans.org/kb/docs/java/quickstart-gui.html ), but the subject has not been found yet In other GUI builders (Delphi), this can be done by removing anchors from both edges
Solution
If you want to keep your component centered in the container, if the container is resized, you can choose several options, but I don't think grouplayout is one of them (if I'm wrong, please correct me) One way is to change the container layout to gridbaglayout, and then simply add JButton to it without any constraints
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码