Skip to main content

Posts

Showing posts with the label boxlayout

BoxLayout can"t be shared error

I have this Java JFrame class, in which I want to use a boxlayout, but I get an error saying java.awt.AWTError: BoxLayout can't be shared . I've seen others with this problem, but they solved it by creating the boxlayout on the contentpane, but that is what I'm doing here. Here's my code: class edit_dialog extends javax.swing.JFrame{ javax.swing.JTextField title = new javax.swing.JTextField(); public edit_dialog(){ setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE); setTitle("New entity"); getContentPane().setLayout( new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); add(title); pack(); setVisible(true); } }