290 likes | 715 Views
An Introduction to GUI’s in Java. GUI. GUI – Graphic User Interface Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console. A GUI presents a windows interface to a program. A GUI gives a distinctive “look” and “feel”. GUI.
E N D
GUI • GUI – Graphic User Interface • Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console. • A GUI presents a windows interface to a program. A GUI gives a distinctive “look” and “feel”.
GUI • GUI Applications and how they are built. • GUI components • java.awt (Abstract Window Toolkit) and javax.swing (Swing Components).
GUI • Components and the Container object. • As the name suggests the Container object is an object that can contain other GUI objects. • A Frame is a type of container.
GUI • import javax.swing.*; • import java.awt.*;
Example import javax.swing.*; import java.awt.*; public class JFrameEg extends JFrame { public JFrameEg() { super("JFrameEg: Testing JFrame"); setSize(300,150); setVisible(true); } public static void main(String args[]) { JFrameEg example = new JFrameEg(); } }
GUI Components: Overview • Can use GUI components to get input from the user and display output • Components are placed in a container and the container is shown to the user in the form of a window • When you create your component object you must add it to the container, otherwise it will not be visible
Setting up the screen to take components • Components and the layout manager object. • Layout manager and logical arrangement of components