1

I have this code:

package web.test;

import java.awt.Dimension;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class WebTest {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    JEditorPane Window = new JEditorPane();
    Window.setEditable(false);   

    try {
        Window.setPage("http://www.sparky.org/safety_tips.html");
    } catch (IOException e) {
        Window.setContentType("text/html");
        Window.setText("<html>Cannot Load Page/html>");
    } 

    JScrollPane ScrollPane = new JScrollPane(Window);     
    JFrame Frame = new JFrame("Fire Safety Tips");
    Frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Frame.getContentPane().add(ScrollPane);
    Frame.setPreferredSize(new Dimension());
    Frame.setVisible(true);
    Frame.setLocationRelativeTo(null);
}
}

Is there any way to make this window appear maximized? I've tried to set the sizes of both the scroll and edit pane to setPreferredSize as .getMaximumSize but that won't work.

Jan Vorcak
  • 19,261
  • 14
  • 54
  • 90
  • 1) Use a consistent and logical indent for code blocks. The indentation of the code is intended to help people understand the program flow. 2) Please learn common [Java naming conventions](http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#73307) (specifically the case used for the names) for class, method & attribute names & use them consistently. – Andrew Thompson Dec 13 '13 at 16:38
  • This Stack Overflow question may help you out. - http://stackoverflow.com/questions/479523/java-swing-maximize-window – Simon Shirley Dec 13 '13 at 16:38
  • The reason the code is like that is because I was in a hurry, the actual file is indented. Sorry about that. – Shoddy Weather Dec 13 '13 at 18:11

1 Answers1

5

See Frame.setExtendedState(int).

Sets the state of this frame. The state is represented as a bitwise mask.

  • NORMAL Indicates that no state bits are set.
  • ICONIFIED
  • MAXIMIZED_HORIZ
  • MAXIMIZED_VERT
  • MAXIMIZED_BOTH Concatenates MAXIMIZED_HORIZ and MAXIMIZED_VERT.
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433