Results 1 to 6 of 6

Thread: Java program code for frame

  1. #1
    Join Date
    Dec 2009
    Posts
    41

    Java program code for frame

    Hello Friends,

    I am IT student, and I have one confusion regarding the frames of the java programming. I seems very difficult to code java program for Frame because of it's complexity.
    Pleases let me know some java program code example for frame. I would greatly appreciate your any help over this.

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

    Re: Java program code for frame

    Following is the simple java program which depicts the java frame concept. Please go through this:
    import javax.swing.*;

    public class Swing_Frame_Demo
    {
    public static void main(String arg[])
    {
    JFrame frame1 = new JFrame("Java Swing Frame");

    frame1.setVisible(true);
    frame1.setSize(500, 500);
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
    }

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

    Re: Java program code for frame

    Java Frame example:
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;


    public class ExFrame extends JFrame {

    public ExFrame()
    {
    super();

    setDefaultCloseOperation(EXIT_ON_CLOSE);

    }

    public ExFrame(String tle)
    {
    super(tle);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Java program code for frame

    Hi,

    "JFrame" class is used in java for Frame. There are different properties of this class is used to set the properties to the frame. These different properties include setSize, setVisible and setDefaultCloseOperation. The "setSize" is used to define the size of the frame while the "setVisible " property is used to make the frame visible. To use these properties you need to include "javax.swing" package into you java program.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Java program code for frame

    Let's see if following program is useful for you or not:
    JFrame frameDm = new JFrame("Frame Demo ");

    frame.setIconImage(Toolkit.getDefaultToolkit().getImage("//Put here path of your image"));

    frameDm.setSize(1100,900); // it sets the frame size

    frameDm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frameDm.setVisible(true);

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

    Re: Java program code for frame

    "Frame" is a top-level window with a title and a border. The size of the frame includes any area designated for the border. The border area is included in the overall size of the frame. 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. The border effectively obscures a portion of the frame, constraining the area available for rendering and/or displaying subcomponents to the rectangle which has an upper-left corner location of (insets.top, insets.left), and has a size of width - (insets.left + insets.right) by height - (insets.bottom + insets.top).

Similar Threads

  1. Convert C++ Program to Java Code!! Please help
    By jessesaini in forum Software Development
    Replies: 1
    Last Post: 24-04-2012, 12:24 AM
  2. Need help to convert c++ to java code program
    By xSim21 in forum Software Development
    Replies: 2
    Last Post: 27-11-2010, 04:42 PM
  3. convert C++ program in Java code
    By vaibhavsri in forum Software Development
    Replies: 7
    Last Post: 16-07-2010, 10:08 AM
  4. What is the use of Frame class in java?
    By Truster in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 11:16 AM
  5. Frame constructor in java
    By HardWeaR in forum Software Development
    Replies: 3
    Last Post: 08-12-2009, 02:46 PM

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,714,148,202.11425 seconds with 16 queries