我有这个代码:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
有什么办法可以让这个窗口最大化吗?我尝试将滚动和编辑窗格的大小设置为 setPreferredSize as .getMaximumSize 但这不起作用。