What is the correct way to use JPanels in Netbeans?

你离开我真会死。 提交于 2019-12-20 04:23:35

问题


I'm new to Java GUI.

First I created a JFrame and have added a JPanel. After that I set it as a Null Layout. Then added a label and set a background image for the frame. For my project I need to add separate 4 JPanels for this JFrame. On those JPanels I'm going to add Labels and Text boxes. I want to know whether it's correct or not to add 4 JPanels on a main JPanel?


回答1:


I want to know whether it's correct or not to add 4 JPanels on a main JPanel?

Sure. Most of the Java GUIs you see that are any more than trivial put panels inside other panels.

Sometimes a different panel is used to group common controls or output components and possibly give them a titled border. More commonly different panels are used in order to use different layout managers in separate parts of the GUI. Here is a well known example that puts the details of the layout in a titled border for the panel..



来源:https://stackoverflow.com/questions/32901358/what-is-the-correct-way-to-use-jpanels-in-netbeans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!