KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The following Swing code doesn't work correctly on my machine or my co-workers machines (all Windows XP & Java 6): public class Test { public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(800, 600); frame.setLayout(new FlowLayout()); frame.add(new JButton(new AbstractAction("Maximize") { @Override public void actionPerformed(ActionEvent e) { frame.setExtendedState((frame.getExtendedState() & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH ? JFrame.NORMAL : JFrame.MAXIMIZED_BOTH); } })); frame.setUndecorated(true); frame.setVisible(true); } } It maximizes the window, but does not take into consideration the windows task bar (it fills the screen). If you comment out "frame.setUndecorated(true);" it seems to work correctly. The Javadoc seems to imply this should work. Is this a bug in Java? Is it limited to a specific release, or version of Windows? Is there a workaround? I've seen a few workarounds , but they seem incomplete. I can't be the first person to code my own frame decorations in Java. EDIT: After downloading the OpenJDK and digging through the native code, I found that Java is calling the win32 function SetWindowPlacement and under some conditions altering MINMAXINFO to get the right window size. I think what I was seeing was the default windows behavior for a window with no title or border (although I can't find that documented anywhere). I've f
Tags (comma-separated)
Save Edits
Cancel