I have a JFrame with a JBoxLayout set Y_AXIS and inside the JFrame i have two JPanels
each with some componets inside them and have put both JPanels inside the JFrame,
but for some reason the JPanel with the JTextArea does not show up.
Here is my source code:
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class FileTest extends JFrame implements ActionListener { private BoxLayout vbox; private JPanel panel; private JPanel topPanel; private JTextArea txtBox; private JButton openBtn; private JButton closeBtn; public FileTest() { super("FileTest"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); vbox = new BoxLayout(this, BoxLayout.Y_AXIS); txtBox = new JTextArea("Hello World", 10, 80); topPanel = new JPanel(); topPanel.add(txtBox); add(topPanel); openBtn = new JButton("Open"); closeBtn = new JButton("Close"); panel = new JPanel(); panel.add(openBtn); panel.add(closeBtn); add(panel); pack(); setVisible(true); } @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub } public static void main(String[] args) { FileTest test = new FileTest(); } }