Question

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.

Was it helpful?

Solution

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top