I am developing a Java Swing application. I have a small issue on how to resize the layout in a JFrame
to the same size of the JFrame
in the Design tab in Eclipse.
The layout's space is not enough to effectively design my intended user interface. I can add items in a crammed manner and those items display in the final output but at design time I would like the layout to expand as much as the JFrame
. Following image would describe my problem:
I tried this code but it does not seem to work:
getContentPane().setPreferredSize(new Dimension(800, 600));
This is my code:
public class ExployeeScreen extends JFrame {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ExployeeScreen frame = new ExployeeScreen();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public ExployeeScreen() {
setBounds(100, 100, 450, 300);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
getContentPane().setPreferredSize(new Dimension(800, 600));
}
}
Any help regarding this is highly appreciated. Thanks :)