简体   繁体   中英

JFrame minimize icon query?

我可以通过设置setResizable(false)来隐藏最大化图标,如何为最小化图标实现相同的效果?

Here is the way, how to remove min/max buttons from JFrame

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JFrameTest extends JDialog {
    public JFrameTest(JFrame frame, String str) {
        super(frame, str);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent evt) {
                System.exit(0);
            }
        });
    }

    public static void main(String[] args) {
        JFrameTest frame = new JFrameTest(new JFrame(), "Title");
        JPanel panel = new JPanel();
        panel.setSize(200, 200);
        JLabel lbl = new JLabel("JFrame without max/min");
        panel.add(lbl);
        frame.add(panel);
        frame.setSize(400, 400);
        frame.setVisible(true);
    }
}

But it's really nasty to users and could be walk arounded by key shortcuts etc.

检查示例指定窗户装饰

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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