How to maximaze a window correct?
Hello Guys!I need to maximize a JFrame.
But the problem is that it overlays the desktop bar with applications at the bottom of the screen.
I would like to have the bar with the applications visible.
If you test this code In hope you see my problem:
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestFrame
{
private static JFrame frame;
public static JFrame getFrame()
{
return frame;
}
private static void setFrame(JFrame jFrame)
{
frame = jFrame;
}
private static void createAndShowGUI()
{
setFrame(new JFrame("Test"));
getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getFrame().setResizable(false);
getFrame().pack();
getFrame().validate();
getFrame().setVisible(true);
getFrame().setExtendedState(getFrame().getExtendedState() | JFrame.MAXIMIZED_BOTH);
getFrame().getContentPane().add(new JPanel());
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
Best regards
Fredrik
