JFrame.HIDE_ON_CLOSE
Below code shows how to use JFrame.HIDE_ON_CLOSE to frame setDefaultCloseOperation method.
When the JFrame close button is clicked, nothing happens to JFrame window
When the JFrame close button is clicked, nothing happens to JFrame window
JFrame.HIDE_ON_CLOSE Example
[
import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Color; import java.awt.Graphics; import java.awt.Font; import java.awt.Container; import java.awt.Dimension; public class JFrameMethods extends JPanel{ public void paint(Graphics g) { Font font=new Font("Times Roman",Font.ITALIC,12); Color color=Color.GREEN; g.setColor(color); g.setFont(font); g.drawString("This is java programming", 10, 10); } public static void main(String args[]) { JFrame frame=new JFrame(); frame.getContentPane().add(new JFrameMethods()); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); frame.setSize(new Dimension(300,300)); frame.setVisible(true); } }]