You set the layout of the JFrame to null, when you probably meant to set the content pane's layout to null. This works:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public Window() { JFrame mainFrame = new JFrame(); mainFrame.setSize(1024, 786); mainFrame.setLocationRelativeTo(null); mainFrame.setTitle("Temp Name"); mainFrame.setDefaultCloseOperation(EXIT_ON_CLOSE); mainFrame.setResizable(false); insets = mainFrame.getInsets(); mainFrame.getContentPane().setLayout(null); JTextArea gameTextArea = new JTextArea(); gameTextArea.setEditable(false); gameTextArea.setBounds(50, 30, 100, 20); mainFrame.getContentPane().add(gameTextArea); mainFrame.setVisible(true); } |
Standard Swing-fanatic disclaimer: It's really preferable to use a LayoutManager rather than null layout, as then your UI could be designed to allow the window to be resizable and still look nice, not to mention handling different LookAndFeels having different widget sizes, the user's desktop settings, etc.