Hello, I think you need to make use of the code below and then you will able to get the solution for the removing close button on a JFrame in java:
Code:
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class closebutton extends JFrame
{
public closebutton() throws HeadlessException
{
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
JButton b1 = new JButton("Close");
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.setSize(new Dimension(200, 200));
this.getContentPane().add(b1);
}
public static void main(String[] args)
{
new closebutton().setVisible(true);
}
}
Bookmarks