|
|
||
| You are here: | ||
|
All about Java Applications
An application starts with a main method of this form. This main method just calls the Constructor for the Class. The Constructor contains the executable code. This outputs to "the console" in text only mode.
Note: You need to run these applications in BlueJ by right-clicking the Class and selecting main() to get it started. A Frame is like a windows Window
If we don't set size and make visible, we won't see anything.
An inner class is a class that is used or defined in another class and they are convenient when writing event-driven applications. Here we want to implement a window listener that detects only the window closing event. The easiest way to do this is to extend the convenience class WindowAdapter. However, we are already extending Frame so we can't do that. We could implement the WindowListener interface but then we have to include code for all 7 of the window events (such as windowIconified (minimized), windowDeicoconified (restored), etc).
|
On this page: [ Outline | Inner Classes | Main Methods | Summary ] /** If we want to use a GUI ( Graphical User Interface ) we have to use the awt as in our Applets. import java.awt.*; There is a slight disadvantage of this Application - it won't close (although it will in BlueJ if you re-compile the code). The easiest way to handle this is to use an inner class (we met these briefly in VideoTapeInner ) import java.awt.*; In summary:
On to the Biscuit Collection Application. Related: [ Java home | previous: applications | next: The Biscuit App ] |
So far we have worked exclusively with Applets, small applications designed to run in a web page. Since Java Applets are designed to be hosted on a user's computer, Applets are not allowed to access the local filing system to create and edit files. Therefore our file handling programs must be applications rather than Applets. For this reason you won't find demonstration programs on these web pages for applications. However, the source code is provided so that you can simply import or cut and paste the listings. |
|
|
|||
|
Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: May 31, 2009 |