My comment was independent of layouts - mixing the Components should be avoided for reasons you can find by googling. Suffice it to say, Layouts in the links I provided above are find for both AWT...
Type: Posts; User: copeg
My comment was independent of layouts - mixing the Components should be avoided for reasons you can find by googling. Suffice it to say, Layouts in the links I provided above are find for both AWT...
The method setLayout is defined by the class Container...it must be called on an object that is or extends the class Container. For example, the JPanel you defined:
myPanel.setLayout(myLayout);...
Define 'it didn't work'....and yes you need a JFrame - that code snippet was just a demonstration for the Layout to incorporate into your code.
See the following link for details:
How to Use BoxLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)
The main concept is to create a JPanel,...
Sorry it wasn't that helpful, but that link was for novices, and its one of the best resources for newcomers to the language to dive into. Amongst the list of layouts in that page, which looks...
Use a LayoutManager. See the following link for the most appropriate Layouts. Also note that layouts can be nested - JPanel within JPanel with different layouts as needed.
A Visual Guide to Layout...