Download presentation
Presentation is loading. Please wait.
Published byKory Robinson Modified over 8 years ago
1
IB103 Week 9 Free Standing Programs Chapter 18
2
Applets vs. Applications Applications are free standing See Program “Greeting” which prints out Hello because of the line in main: System.out.println(“Hello\n”); Application types: Input/output and windows/widgets
3
Greeting public class Greeting { public static void main(String[] args) { System.out.println("Hello"); }
4
The “main” method creates an object Public static void main(String args[ ]) { Application a = new Application( ); a.doWhatIsNeeded( );{ } } The sequence: 1. The operating system makes a static method “main” 2. Main creates an instance (an object) 3. Main invokes a method(s) as needed
5
Using AWT an example “Balloon” revisited “Play Balloon” example program not an applet anymore…an application version “MenuBalloon” adds menubars for – left/right and grow/shrink See Author’s web site and run examine program
6
PlayBalloon public class PlayBalloon extends Frame implements ActionListener, WindowListener { private Button grow, shrink, left, right; private Balloon myBalloon; public static void main(String[] args) { PlayBalloon f = new PlayBalloon(); f.setSize(500, 300); f.setVisible(true); } public PlayBalloon() {
7
PlayBalloon 2 public void windowClosing(WindowEvent e) { System.exit(0); } public void windowIconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowActivated(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.