Use the JFrame
's content panel as the BoxLayout
's target container:
frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.X_AXIS));
Also, please try to follow Java Naming Conventions. Variable names should start with a lowercase letter; class names should start with an uppercase letter.