Credits

Thursday, February 4, 2010

Teaching GUI of Java

Graphical User Interface (GUI) allows interaction of user with the system. Java like any object - oriented languages does allow GUI in different ways. These include actions with buttons, check boxes, list, scroll bar, textboxes, and others. 


GUI components take the standard javax.swing and jawa.awt as the fundamental classes for instantiating objects.


Java in 21 days provides easy - to - understand examples.  Check the program below that makes a text area.  

[+/-] show/hide




import javax.swing.*;
import java.awt.*;

public class TextArea extends JFrame {
public TextArea() {
super("TextArea");
setSize(500, 180);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextArea comments = new JTextArea(8, 40);
FlowLayout flo = new FlowLayout();
setLayout(flo);
add(comments);
setVisible(true);
}

public static void main(String[] arguments) {
TextArea app = new TextArea();
}
}

AddThis