0

Im making the GUI. I created the JFrame and added 2 JPanels, using JTabbedPane. Despite the fact that i used setSize() method, when I press "start" it creates a little window with 3 default Windows buttons, so I have to resize it by myself.

This is what my window looks like when I run the program:

My Window

This is the code I'm using which produces the results in the image:

JTabbedPane tabs = new JTabbedPane();
JFrame frame = new JFrame("crm");
frame.setSize(750, 600);
JPanel panel = new JPanel(); 
JPanel qw = new JPanel();
panel.setPreferredSize(new Dimension(650,500));
frame.add(tabs);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.add(panel, BorderLayout.CENTER);
panel.setLayout(null);
panel.setPreferredSize(frame.getSize());
tabs.add("1", panel);
tabs.addTab("2", qw);

frame.setLocationRelativeTo(null);
frame.setVisible(true);
Vince
  • 14,470
  • 7
  • 39
  • 84
  • Works fine for me. What version are you on? (I'm on 1.8.0_111) – Joe C Sep 15 '17 at 20:09
  • Call `setVisible()` _after_ `add()`. Don't use `null` layout. If this is not a duplicate, please [edit] your question to include a [mcve] that shows your revised approach. – trashgod Sep 16 '17 at 00:33

0 Answers0