I am having a problem resizing swing components on my GUI. I want to have a "status box" at the bottom of my JFrame to display what is going on and the top of the frame is going to hold panels that will be switched out depending on what menu is showing. However, using the setSize() or setLocation() methods does nothing. It's been a while since I've worked with GUIs and all of my code samples are at home. Thanks for any help:
public class TestGUI extends JFrame
{
private Container c;
private JPanel dispPanel, statusPanel;
private JComboBox userCombo;
private JTextArea status;
public TestGUI()
{
super();
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
double screenX = dim.getWidth();
double screenY = dim.getHeight();
System.out.println(screenX);
System.out.println(screenX / 2);
super.setLocation((int)(screenX / 2) - 300, (int)(screenY / 2) - 300);
super.setSize(500, 500);
super.getContentPane().setLayout(new BoxLayout(super.getContentPane(), BoxLayout.Y_AXIS));
super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
status = new JTextArea();
userCombo = new JComboBox();
status.setBackground(Color.black);
status.setForeground(Color.green);
status.setSize(100, 100);
status.setText("test");
dispPanel = new JPanel();
dispPanel.setLayout(new FlowLayout());
dispPanel.setSize(500, 250);
dispPanel.add(userCombo);
statusPanel = new JPanel();
statusPanel.setLayout(new FlowLayout());
statusPanel.setSize(500, 250);
statusPanel.add(status);
dispPanel.add(userCombo);
statusPanel.add(status);
c = super.getContentPane();
c.add(dispPanel);
c.add(statusPanel);
super.setVisible(true);
}
-Greg :-Q
public class TestGUI extends JFrame
{
private Container c;
private JPanel dispPanel, statusPanel;
private JComboBox userCombo;
private JTextArea status;
public TestGUI()
{
super();
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
double screenX = dim.getWidth();
double screenY = dim.getHeight();
System.out.println(screenX);
System.out.println(screenX / 2);
super.setLocation((int)(screenX / 2) - 300, (int)(screenY / 2) - 300);
super.setSize(500, 500);
super.getContentPane().setLayout(new BoxLayout(super.getContentPane(), BoxLayout.Y_AXIS));
super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
status = new JTextArea();
userCombo = new JComboBox();
status.setBackground(Color.black);
status.setForeground(Color.green);
status.setSize(100, 100);
status.setText("test");
dispPanel = new JPanel();
dispPanel.setLayout(new FlowLayout());
dispPanel.setSize(500, 250);
dispPanel.add(userCombo);
statusPanel = new JPanel();
statusPanel.setLayout(new FlowLayout());
statusPanel.setSize(500, 250);
statusPanel.add(status);
dispPanel.add(userCombo);
statusPanel.add(status);
c = super.getContentPane();
c.add(dispPanel);
c.add(statusPanel);
super.setVisible(true);
}
-Greg :-Q