nutless
asked on
Problem getting GUI to size properly
Hi,
I have created a JPanel to which I add a JTable and alot of JButtons. I then instantiate this JPanel inside my main method and then add it to my JFrame.
Here a snippet of my "main method":
public static void main(String s[]) {
JFrame frame = new JFrame("Kirk");
//pass handle of JFrame
DataFileTable panel = new DataFileTable(frame);
frame.setDefaultCloseOpera tion(JFram e.EXIT_ON_ CLOSE);
frame.setForeground(Color. black);
frame.setBackground(Color. lightGray) ;
frame.getContentPane().add (panel,"Ce nter");
frame.setSize(panel.getPre ferredSize ());
frame.pack();
frame.setVisible(true);
frame.addWindowListener(ne w WindowCloser());
}
The problem is that when I execute my program the GUI comes out "squeeze" looking. Instead of displaying seven buttons it display three buttons. The only way for me to get the full display is to stretch out the frame.
I think the only way to fix my problem is to set a size to my panel since my frame set its size from the panel that is added.
If anyone knows a better solution please let me know.
--nutless
I have created a JPanel to which I add a JTable and alot of JButtons. I then instantiate this JPanel inside my main method and then add it to my JFrame.
Here a snippet of my "main method":
public static void main(String s[]) {
JFrame frame = new JFrame("Kirk");
//pass handle of JFrame
DataFileTable panel = new DataFileTable(frame);
frame.setDefaultCloseOpera
frame.setForeground(Color.
frame.setBackground(Color.
frame.getContentPane().add
frame.setSize(panel.getPre
frame.pack();
frame.setVisible(true);
frame.addWindowListener(ne
}
The problem is that when I execute my program the GUI comes out "squeeze" looking. Instead of displaying seven buttons it display three buttons. The only way for me to get the full display is to stretch out the frame.
I think the only way to fix my problem is to set a size to my panel since my frame set its size from the panel that is added.
If anyone knows a better solution please let me know.
--nutless
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If my stupid suggestion led you to the solution, it should be B or A
Please re-read the guidelines as for what are grades "A", "B" and "C"
community support : anyone ?