learning objectives by the end of this lecture you should be able to: have a well-earned rest! ch...

12
Learning objectives By the end of this lecture you should be able to: have a well-earned rest! Ch 24 Beyond the second semester

Upload: jeffry-scott

Post on 12-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Learning objectives

By the end of this lecture you should be able to:

have a well-earned rest!

Ch 24 Beyond the second semester

Page 2: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Rapid Application Development (RAD)

The RAD approach to program development involves sophisticated development tools for automating or simplifying tasks that would otherwise have to be coded by the programmer.

This greatly speeds up development time and so increases productivity.

In particular RAD programming tools help significantly in the production of graphical user interfaces.

Page 3: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

The PushMe application revisited

After pushing the buttonBefore pushing the button

Page 4: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

A typical RAD environment

Graphical components, such as AWT Buttons and Labels are selected from a palette

Here, an AWT Frame has been selected

Here the Design view is selected so the actual appearance of the Frame can be seen. Clicking the Source view shows us the Java code that has been generated.

The look and behaviour of the graphical component selected can be changed from this list.

Page 5: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Building the GUI

Rather than hard coding the selection and appearance of GUI components, the RAD tool allows you to pick them from a palette:

The appearance of these GUI components on the Frame does not match exactly the appearance we are after so we can customise them.

Page 6: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Customising the GUI

Each component’s look can be modified by changing its properties in the properties list.

For example, to change the text on the Label to “Enter some text and push the button” select the Label’s text property

The Label’s text property is selected

Then the Label’s text property is modified

Page 7: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Attaching code to the GUI

In order for the GUI application to respond to events we still need to write the code for the event handler.

If we double click the Button in design view, the RAD tool will automatically assign an actionListener to this button and take us to that part of the generated code that needs completing.

void button1_actionPerformed(ActionEvent e) {

// code to be complrted goes here}

This code will be the same as that developed before.

Page 8: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Java Beans

A Java Bean is a more abstract and powerful concept than a simple Java class.

A Java Bean is a self contained object that can be used and tested independently of any environment restrictions.

A stand-alone visual object is often called a component.

Java's AWT and Swing components (which can be found on component palettes of RAD tools) are examples of Java beans.

Page 9: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Writing your own Java beans

When you write your own Java bean it can be added to a RAD tools component palette.

To make a class into a Java Bean it must meets a set of Java Bean rules which

These include ensuring the class is declared public and following strict naming rules for get and set methods for private attributes.

Page 10: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Java Database Connectivity

A common model upon which these database applications are based is the relational database model.

Data in such a database consists of a collection of tables.

SQL (Structured Query Language) is a common language used to retrieve and modify information within tables.

Java’s JDBC (Java DataBase Connectivity) API provides a set of classes for communicating with such databases with SQL statements.

These classes are found in the java.sql package.

Page 11: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

The java.sql package

The four main classes in this package are:

DriverManager : loads and sets up the software required to communicate with an external database.

Connection: authenticates and connects the Java program to a database.

PreparedStatement: sends SQL statements to the database for execution.

ResultSet: allows the results of SQL statements to be analysed in the Java program.

Page 12: Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester

Networking

The java.rmi and java.net packages provide extensive support for networking and distributed systems development.

These packages include classes for simplifying the communication between objects spread over a network and include classes such as Socket, and ServerSocket.