Swing
Hello World
The two following examples give the same result, but using two
different implementations for handling the action event on the button :
- In this version , the main class implements ActionListener and then, is used as instance of ActionListener to listen the button.
- In this version, the instance of ActionListener is done using an anonymous inner class.
SwingApplication
This example of a simple application is coming from the Java tutorial.
Coordinates Demo
This example, which explains how to draw in a componant, is coming from the Java tutorial.
Layout Demos
These examples are coming from the Java tutorial. Most useful layout managers are (in my opinion) :
- Border Layout
- Box Layout
- Flow Layout
- Grid Layout
- GridBag Layout
Browser
This example shows how to implement a simple web browser. In
particular, it contains a generic history.
- First version
- The history is implemented in a generic way in the class History. Then it may be reused in any context where an history is needed. History extends Observable and it is this class which will activate the updates of the two others components Browser and HistoryBar, which are instances of Observer.
- HistoryBar uses two images for its buttons : HorizontalPrevious.png et HorizontalNext.png, placed in a directory images.
- When a web page cannot be loaded, a default page, Failure.html, is used to prevent the user.
- Version with multiple windows and a menu
- In this version, classes History and HistoryBar are unchanged.
- The class Browser have been renamed BrowserFrame.
The frame is completed by adding a menu "File" allowing to create or
close a frame, or to quit the application. Setting the size and showing
the frame is let to the responsability of the client of the class BrowserFrame.
- Frames are managed by a FrameController, implemented here by the class Browser. Please note the use of a dialog to confirm the intention to quit the program.