Results 1 to 6 of 6

Thread: What is the use of Frame class in java?

  1. #1
    Join Date
    Dec 2009
    Posts
    59

    What is the use of Frame class in java?

    Hi All,

    I just started to study the class concepts of java programming language. For me the core java was not too much complicated. But I am totally confused about the 'Frame class'. I am able to get the exact use of this java programming class. If anyone has good knowledge about the Frame class, then please let me aware about that. If possible then please give suitable example for 'Frame class'.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: What is the use of Frame class in java?

    A Frame class is a top-level window with a title and a border. The size of the frame includes any area designated for the border. The dimensions of the border area may be obtained using the getInsets method, however, since these dimensions are platform-dependent, a valid insets value cannot be obtained until the frame is made displayable by either calling pack or show. Since the border area is included in the overall size of the frame, the border effectively obscures a portion of the frame.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: What is the use of Frame class in java?

    Hi friend,

    Following example will definitely give you idea about the 'Frame class':
    Code:
    java.awt.Frame
    import java.awt.event.WindowEvent;
    public class FrameDM extends JFrame {
      public CenteredFrame() {
        setTitle("CenteredFrame");
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        };
        Toolkit tk1 = Toolkit.getDefaultToolkit();
        Dimension screenSize1 = tk.getScreenSize();
        int screenHeight1 = screenSize.height;
        int screenWidth1 = screenSize.width;
        setSize(screenWidth1 / 2, screenHeight1 / 2);
        setLocation(screenWidth1 / 4, screenHeight1 / 4);
      }
    
      public static void main(String[] arpgs) {
        FrameDM frame1 = new CenteredFrame();
        frame1.show();
      }
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: What is the use of Frame class in java?

    I suggest you to go through the following methods of Frame class:
    • setUndecorated(boolean bl)
    • setTitle(String ttle)
    • setState(int state1)
    • setResizable(boolean bl)
    • setMenuBar(MenuBar mbr)
    • setMaximizedBounds(Rectangle bnd)

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: What is the use of Frame class in java?

    Example of Frame class of java:
    Code:
    import java.awt.event.WindowAdapter;
    java.awt.Frame
    
    public class FrameSample extends JFrame
     {
      public CloseFrameAction() 
    {
        setTitle("CloseableFrame");
        setSize(350, 200);
        addWindowListener(new WindowAdapter()
     {
          public void windowClosing(WindowEvent e) 
    {
            System.exit(0);
          }
        };
      }
      public static void main(String[] ardgs) {
        FrameSample frameB = new CloseFrameAction();
        frameB.show();
      }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: What is the use of Frame class in java?

    Hello friend,

    Review following nested classes of Frame class, which are useful to access it's properties:
    1. Frame.AccessibleAWTFrame
    2. Component.BltBufferStrategy
    3. Window.AccessibleAWTWindow
    4. Component.AccessibleAWTComponent
    5. Container.AccessibleAWTContainer

Similar Threads

  1. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  2. Creating an Internal Frame in java
    By samualres in forum Software Development
    Replies: 4
    Last Post: 24-02-2010, 10:46 PM
  3. Frame constructor in java
    By HardWeaR in forum Software Development
    Replies: 3
    Last Post: 08-12-2009, 02:46 PM
  4. How to create button on frame in java?
    By JagdishP in forum Software Development
    Replies: 4
    Last Post: 10-08-2009, 06:04 PM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,865,972.15870 seconds with 16 queries