Home Swing How to make frame in java
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

How to make frame in java

Advertisement
We are going to discus about frame in java. In this example We have make frame in java Swing. We have created JFrame class and JFrame is an extended of java.awt.Frame.

How to make frame in java

We are going to discus about frame in java. In this example We have make frame in java Swing. We have created JFrame class and JFrame is an extended of java.awt.Frame.We have created JLabel object can display either text, an image, or both. The argument of the constructor is the title of the window or frame. We have used setVisible(true) function. The setVisible(true) function is called passing the Boolean value true.

In this below example we have used some method:-

  • setSize (400, 400):-Above method sets the size of the frame or window to width (400) and height (400) pixels.
  • setVisible(true):-Above method makes the window visible.

Example of Frame in Swing

package Frame;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class FrameExample extends JFrame{
	 private static final long serialVersionUID = 1L;
		public void start()
	    {
	        JFrame jFrame=new JFrame("Frame Tutorial");
	        JLabel l=new JLabel("Naulej Kumar(Software Devloper)");
	        jFrame.add(l);
	        jFrame.setSize(400,400);
	        jFrame.setVisible(true);
	    }
	    public static void main(String args[])
	    {
	        new FrameExample ().start();
	    }
	}

Output

Download Source Code

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 29, 2013

Ask Questions?    Discuss: How to make frame in java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com