Tuesday, January 15, 2008


Java Swing Example

A part of Sun Microsystems Java Foundation classes (JFC) is a widget toolkit for providing a graphical user interface. It consists of many tools including boxes, combo box, list box, buttons, dialog boxes, tables etc.

It is very interesting part of Java programming. It is the favorite topic of all the java programmers. We can customize the components and use it according to our requirements. Lets start with first program :

This program explain you how to create text area using Java swing. Here we are using javax.swing package to create GUI component. The text area will be created on panel in the frame :

import javax.swing.*;
public class TextAreaCode {
public static void main(String[] args){
JFrame frame= new JFrame("TextArea-Frame Program");
JPanel panel=new JPanel();
JTextArea jt= new JTextArea("TextArea Example",4,20);
frame.add(panel);
panel.add(jt);
frame.setSize(250,250);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

Click Here for More example on Java Swing


0 comments: