I need to remove the maximize and minimize buttons from a JFrame
. Please suggest how to do this.
Here's a related example using setUndecorated()
to disable the frame decorations.
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class FrameTest implements Runnable {
public static void main(String[] args) {
EventQueue.invokeLater(new FrameTest());
}
@Override
public void run() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setUndecorated(true);
JPanel panel = new JPanel();
panel.add(new JLabel("Stackoverflow!"));
panel.add(new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}));
f.add(panel);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}