gpt4 book ai didi

java - 以最大化方式启动 JEditorPane

转载 作者:行者123 更新时间:2023-11-29 03:26:53 26 4
gpt4 key购买 nike

我有这个代码:

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);
}
}

有什么方法可以使这个窗口最大化?我尝试将滚动和编辑 Pane 的大小都设置为 setPreferredSize as .getMaximumSize 但这不起作用。

最佳答案

参见 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.

关于java - 以最大化方式启动 JEditorPane,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20571434/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com