/** * @author Igor Kholodov, Bristol Community College * * CIS-75 sample: * Setting the Window Close Box * JFrame.addWindowListener() demo */ package application; import cis75.CallTrace; import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.text.*; public class SwingMain { public static void main(String args []) { if (args.length > 0) { CallTrace.strDebugOutput = args[0]; } // Swing test setSystemLookFeel(); JFrame frame = new JFrame("JFrame is me"); frame.setBounds(0, 0, 400, 300); frame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent ev) { System.exit(0); } } ); JPanel jpan = new JPanel(); frame.getContentPane().add(jpan); JButton jbut = new JButton("Hello"); jpan.add(jbut); frame.setVisible(true); } //main // Setting system look and feel: private static void setSystemLookFeel() { // Force to come up in the system look and feel String laf = UIManager.getSystemLookAndFeelClassName(); try { UIManager.setLookAndFeel(laf); } catch (UnsupportedLookAndFeelException exc) { System.err.println("Unsupported: " + laf); } catch (Exception exc) { System.err.println("Error loading " + laf); } } } //SwingMain