The BA wants a window that
- has a close button
- has a maximize button
- has no enabled minimize button
Considering the requirements for window control buttons, it seems there’s no way around JFrame
. But how do I disable the minimize button? I will consider going for native methods, if it’s the only way (the apps are installed on Windows PCs)
I can do something like this, but the minimize button stays enabled — just the frame pops back up
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class NonMinimizableFrameDemo {
public NonMinimizableFrameDemo() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
frame.addWindowListener(getWindowAdapter());
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(NonMinimizableFrameDemo::new);
}
private final JFrame frame = new JFrame();
private WindowAdapter getWindowAdapter() {
return new WindowAdapter() {
@Override
public void windowIconified(WindowEvent we) {
frame.setState(JFrame.NORMAL);
JOptionPane.showMessageDialog(frame, "Cant Minimize");
}
};
}
}