繁体   English   中英

如何使框架随窗口自动调整大小?

[英]How to make frame automatically resize with window?

当我调整窗口大小时,滚动框不会随之调整大小,只是超出了框架。 有没有什么办法解决这一问题? 这是代码片段:

    TextEditor(){
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setTitle("Emu Editor J");
        this.setSize(700,550);
        this.setResizable(true);
        this.setLayout(new FlowLayout());
        this.setLocationRelativeTo(null);

        textArea = new JTextArea();
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setFont(new Font("Cascadia Code",Font.PLAIN,20));
        
        scrollPane = new JScrollPane(textArea);
        scrollPane.setPreferredSize(new Dimension(this.getWidth()-25,this.getHeight()-100));
       // scrollPane.setSize(this.getWidth()-25,this.getHeight()-100);
        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

我试过允许调整大小但没有用

尝试使用BorderLayout并使用BorderLayout.CENTER添加面板。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM