I'm working with JFrames in java to make a GUI. I'm having a problem where my 2 JFrames are painting over eachother though.
public VidbergGUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
super("Automatic Output Verifier");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
setBounds(100, 100, 600, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = this.getContentPane();
con.add(titlePane);
titlePane.setLayout(new BoxLayout(titlePane, BoxLayout.PAGE_AXIS));
componentPane.setLayout(new BoxLayout(componentPane, BoxLayout.LINE_AXIS));
programsLoaded = new JTable(data, columnNames) {
@Override
public boolean isCellEditable(int row, int col) {
if (col == 3) return false;
return true;
}
};
programsLoaded.getColumnModel().getColumn(2).setCellEditor(new FileChooserEditor());
tableHolder = new JScrollPane(programsLoaded);
titleLabel.setFont(new Font("Ariel", Font.BOLD, 28));
addButton.setSize(40, 40);
removeButton.setSize(40, 40);
titlePane.add(titleLabel, BorderLayout.PAGE_START);
con.add(componentPane);
componentPane.add(tableHolder, BorderLayout.LINE_END);
componentPane.add(addButton, BorderLayout.EAST);
componentPane.add(removeButton, BorderLayout.EAST);
setVisible(true); // make frame visible
}
With this setup, only the componentPane is visible. If I comment out con.add(componentPane)
, only the titlePane is visible. Is there a way I can assign some sort of layout so the 2 frames stack vertically?