Yes.
import java.awt.*; import javax.swing.*; public class ButtonFrame extends JFrame { JButton bChange; ButtonFrame(String title) { super( title ); setLayout( new FlowLayout() ); // set the layout manager bChange = new JButton("Click Me!"); add( bChange ); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }
The program constructs a FlowLayout manager and then sets it
using the setLayout()
method of the frame.
This is done before any components are added to the frame.
If there is only one component to place in a frame,
where do you suppose FlowLayout
puts it?