1. Architecture Dependent /* My first C program. */ #include <stdio.h> Main() { Printf(“Hello World!”); } Platform independent C source code C compiler for Sun Solaris C compiler for Windows C compiler for Mac OS C compiler for Linux Compilation Yields 10010110011101101001010101001010 10110101011001010111010101111101 01010100101010101011101010001001 10101011110011101000101001011100 Platform specific binary code
2. Java Architecture Neutral // My first Java program. public class HelloWorld { public static void main (String[ ] args) { System.out.println(“Hello World!”); } } Platform independent java source code Compilation Yields E po 3/4 - () V ([Ljava/lang/String;)V <init> Code HelloWorld HelloWorld.java…………. Platform independent byte code A platform DEPENDENT JVM running on the underlying Hardware architecture 101010010100100101001010010010100011010001010010001000001001010001010010 Binary code java compiler for Sun Solaris java compiler for Windows Java compiler for Mac OS Java compiler for Linux
3. Hierarchical diagram Dimension Font FontMetrics Color Graphics Component LayoutManager Container Panel Window Applet Frame Dialog JApplet JFrame JDialog JComponent 1 ** Classes in the java.awt package Swing Components in the javax.swing package HeavyWeight LightWeight
6. Event Registration, Listening and Handling Register a Listener object Source Object Event Object Event Handler Listener Object Trigger an Event Generate an Event Generate an Event An event triggered by user actions on the source objects. The source object generates the event object and invokes the handler of the listener object to process the event. User action
7. Graphical user interface: Application Frame Pull-down Menus A frame can contain menus, panels, and user interface components. Panels can contain other panels. Panel Panel Panel UI Panel UI Panel UI Panel UI User Interface Components (UI)
8. Graphical user interface: Applet Applet Pull-down Menus A frame can contain menus, panels, and user interface components. Panels can contain other panels. Panel Panel User Interface Component Panel User Interface Component Panel Panel Panel User Interface Component Panel Panel User Interface Component Panel User Interface Component Panel Panel User Interface Component Panel Panel
9. UserAction, SourceObject and EventType MouseEvent Component Mouse pressed, released, moved, clicked, entered, or exited KeyEvent Component Key released or pressed ListSelectionEvent JList Select Item(s) AdjustmentEvent JScrollBar Move the scroll bar WindowEvent Window Window open, close,closing, iconified,de-iconified ContainerEvent Container Component added/removed ComponentEvent Component Component moved, resized, hidden or shown TextEvent JTextComponent Change text FocusEvent Component Component gained or lost focus ItemEvent, ActionEvent JRadioButton Click a radio button ItemEvent, ActionEvent JCheckBox Click a check box ItemEvent, ActionEvent JComboBox Select a new item ActionEvent JMenuItem Select menu item ActionEvent JTextField <cr> on a text field ActionEvent JButton Click a button Event Type generated Source Object User Action