KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > swing > JFrame

javax.swing
Class JFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
See Also:
Top Examples, Source Code, XMLEncoder, JRootPane, setDefaultCloseOperation(int), WindowListener.windowClosing(java.awt.event.WindowEvent)

protected AccessibleContext accessibleContext
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void addImpl(Component comp,
                       Object constraints,
                       int index)
See Also:
RootPaneContainer, setRootPaneCheckingEnabled(boolean), IllegalArgumentException, Container
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected JRootPane createRootPane()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int EXIT_ON_CLOSE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void frameInit()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AccessibleContext getAccessibleContext()
See Also:
Frame, Accessible
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Container getContentPane()
See Also:
setContentPane(java.awt.Container), RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1252]Simple JFrame
By Anonymous on 2005/01/13 17:46:22  Rate
import java.awt.*;  
 import java.awt.event.*;  
  
  
 import javax.swing.*;  
  
  
 /**  
  * Simple convenience for code snippets: creates a Frame that  
  * adds the input component and adds a listener to exit the application  
  * on demand.  
  *  
  */
  
 public class SnippetFrame extends JFrame {   
   /**  
    * @param JComponent component to add to the frame's content pane  
    */
  
   public SnippetFrame ( JComponent cmp )  {   
     super (  ) ;  
  
  
     // Add component  
     getContentPane (  ) .add ( cmp ) ;  
  
  
     // Set white background as a default  
     getContentPane (  ) .setBackground ( Color.white ) ;  
  
  
     // Pack to fit cmp's preferred size  
     pack (  ) ;  
  
  
     // Add a listener to close the application when  
     // user closes the frame.  
     addWindowListener ( new WindowAdapter (  )  {   
       public void windowClosing ( WindowEvent evt )  {   
    System.exit ( 0 ) ;  
        }   
      }  ) ;  
      
     setVisible ( true ) ;  
    }   
  }   
 


public int getDefaultCloseOperation()
See Also:
setDefaultCloseOperation(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Component getGlassPane()
See Also:
setGlassPane(java.awt.Component), RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JMenuBar getJMenuBar()
See Also:
setJMenuBar(javax.swing.JMenuBar)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JLayeredPane getLayeredPane()
See Also:
setLayeredPane(javax.swing.JLayeredPane), RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JRootPane getRootPane()
See Also:
setRootPane(javax.swing.JRootPane), RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static boolean isDefaultLookAndFeelDecorated()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected boolean isRootPaneCheckingEnabled()
See Also:
RootPaneContainer, setRootPaneCheckingEnabled(boolean), setLayout(java.awt.LayoutManager), addImpl(java.awt.Component, java.lang.Object, int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JFrame()
       throws HeadlessException
See Also:
JComponent.getDefaultLocale(), Component.setVisible(boolean), Component.setSize(int, int), GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[531]Bean Persistence Example
By Anonymous on 2004/03/21 16:26:45  Rate
//Bean Persistence Example 
 import java.beans.*; 
 import java.io.* 
  
  
 InputStream is = null; 
 try  {  
     is = new FileInputStream ( fileName ) ; 
  }  catch  ( IOException ioe )   {  
 // Process exception 
  }  
  
  
 XMLDecoder d = new XMLDecoder ( is ) ; 
 JFrame frame =  ( JFrame ) d.readObject (  ) ;


public JFrame(GraphicsConfiguration gc)
See Also:
JComponent.getDefaultLocale(), GraphicsEnvironment.isHeadless(), IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JFrame(String title)
       throws HeadlessException
See Also:
JComponent.getDefaultLocale(), Component.setVisible(boolean), Component.setSize(int, int), GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[903]Empty frame with title
By Melvin Ninal (thick_melvz { at } shadango { dot } com on 2004/10/11 04:21:35  Rate
import javax.swing.*; 
  
  
 class FrameUp 
  {  
   public static void main ( String args [  ]  )  
    {  
     JFrame frame = new JFrame ( "Sheryl Satorre loves Francis" ) ; 
     frame.setSize ( 300,100 ) ; 
     frame.show (  ) ; 
    }  
  }  
  
  
  
 //this outputs an empty frame with the title "Sheryl Satorre loves Francis"


public JFrame(String title,
              GraphicsConfiguration gc)
See Also:
JComponent.getDefaultLocale(), GraphicsEnvironment.isHeadless(), IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected String paramString()
See Also:
Frame
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void processWindowEvent(WindowEvent e)
See Also:
setDefaultCloseOperation(int), Window
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void remove(Component comp)
See Also:
RootPaneContainer, Container.add(java.awt.Component), NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected JRootPane rootPane
See Also:
RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected boolean rootPaneCheckingEnabled
See Also:
RootPaneContainer, setRootPaneCheckingEnabled(boolean), isRootPaneCheckingEnabled()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setContentPane(Container contentPane)
See Also:
JRootPane, getContentPane(), IllegalComponentStateException, RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1847]setContentPane() Example
By stephen84s { at } gmail { dot } com on 2006/11/20 05:59:41  Rate
public class ExampleX extends JFrame {  
   JPanel contentPane=new JPanel (  ) ; 
   JTextField jtName = new JTextField ( 30 ) ; 
   JLabel jlName = new JLabel ( "Name" ) ; 
  
  
   public ExampleX (  )  {  
     super ( "setContentPane (  )  Example" ) ; 
     mainPanel.add ( jlName ) ; 
     mainPanel.add ( jtName ) ; 
     setContentPane ( mainPanel ) ; 
      
     setSize ( 200,200 ) ; 
     setVisible ( true ) ; 
    }  
   public static void main ( String [  ]  args )  {  
     new ExampleX (  ) ; 
    }    
  } 


public void setDefaultCloseOperation(int operation)
See Also:
Runtime.exit(int), WindowConstants, getDefaultCloseOperation(), Window.addWindowListener(java.awt.event.WindowListener), SecurityException, IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1267]Uses the title bar provided by the system look and feel
By Anonymous on 2005/01/20 13:28:20  Rate
//uses the title bar provided by the system look and feel 
 JFrame.setDefaultLookAndFeelDecorated ( true ) ; 
 JFrame frame = new JFrame ( "Hello World" ) ; 
 frame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE ) ; 
 frame.setSize ( 300, 100 ) ; 
 frame.setVisible ( true ) ; 
 


public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)
See Also:
LookAndFeel.getSupportsWindowDecorations()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setGlassPane(Component glassPane)
See Also:
getGlassPane(), RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setIconImage(Image image)
See Also:
Frame.getIconImage()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setJMenuBar(JMenuBar menubar)
See Also:
getJMenuBar()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setLayeredPane(JLayeredPane layeredPane)
See Also:
getLayeredPane(), IllegalComponentStateException, RootPaneContainer
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setLayout(LayoutManager manager)
See Also:
RootPaneContainer, setRootPaneCheckingEnabled(boolean), Container
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void setRootPane(JRootPane root)
See Also:
getRootPane()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void setRootPaneCheckingEnabled(boolean enabled)
See Also:
RootPaneContainer, isRootPaneCheckingEnabled(), setLayout(java.awt.LayoutManager), addImpl(java.awt.Component, java.lang.Object, int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void update(Graphics g)
See Also:
Container
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags