Minggu, 25 Desember 2011

Java GUI Programming Tips: Create a simple JFrame

For you the beginner of java gui programmer, here i present you how to create a very simple JFrame that can be used as your gui program!

Now the step is:
1. Create a void main class named what ever you want
2. Extends that class with JFrame class
3. Create that class constructor and write the "super" constructor as it will determine your JFrame.... :D
4. Now in the public void main, you want to create the object of your class
5. Now use your object to determine the attributes of your JFrame, such as size, make it unresizable make it univisible and so on

For a better understanding just copy and paste this into your java IDE and see what happened! :D

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class mains extends JFrame{

public mains(){
super("JFrame");
}

public static void main(String []args){
mains ob=new mains();
ob.setResizable(true);
ob.setSize(900,700);
ob.setVisible(true);
ob.setLocationRelativeTo(null);
ob.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

Tidak ada komentar:

Posting Komentar