Source of JxFrame.java


  1: import java.awt.*;
  2: import java.awt.event.*;
  3: import java.util.*;
  4: 
  5: //swing classes
  6: import javax.swing.text.*;
  7: import javax.swing.*;
  8: import javax.swing.event.*;
  9: 
 10: 
 11: public class JxFrame extends JFrame
 12: {
 13:    public JxFrame(String title)
 14:    {
 15:       super(title);
 16:       setCloseClick();
 17:       setLF();
 18:    }
 19:    private void setCloseClick()
 20:    {
 21:       //create window listener to respond to window close click
 22:       addWindowListener(new WindowAdapter() 
 23:        {
 24:             public void windowClosing(WindowEvent e) {System.exit(0);}
 25:             });
 26:    }
 27:    //------------------------------------------
 28:    private void setLF()
 29:    {
 30:    // Force SwingApp to come up in the System L&F
 31:         String laf = UIManager.getSystemLookAndFeelClassName();
 32:         try {
 33:        UIManager.setLookAndFeel(laf);
 34:             }
 35:        catch (UnsupportedLookAndFeelException exc) 
 36:          {System.err.println("Warning: UnsupportedLookAndFeel: " + laf);}
 37:        catch (Exception exc) {System.err.println("Error loading " + laf + ": " + exc);
 38:            }
 39:    }
 40: }