java ide programming - ii. controls for output in order to display information to the user, we need...

110
JAVA IDE PROGRAMMING - II

Upload: warren-daniel-sharp

Post on 14-Jan-2016

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

JAVA IDE PROGRAMMING - II

Page 2: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Controls for Output

In order to display information to the user, we need certain controls. These are as follows:

Page 3: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Label

Label is the component of JLabel class. It is used to display the text that can not be edit.

Page 4: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of Label

• enabled: This property determines whether the label is active or not.

• font: This property is used to set the font of the text that appear on the label.

• foreground: This property is used to set the color of the text that appear on the label.

• text: This property is used to set the text of the label.

Page 5: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of Label

void setText(String)- It is used to set the text of the label with the string specified in parenthesis.The general syntax to use the setText() method with the label is as follows:

<labelname>.setText(string);

Page 6: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of Label

void getText()- It is used to get the text of the label. The general syntax to use getText() method with the Label is as follows

<labelname>.getText();

Page 7: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

TextField

TextField is a component of JTextField class and it is used to obtain the input from the user or display the message to the user.

Page 8: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of TextField

• background: This property is used to set the background color of the JTextField.

• enabled: This property determines whether the JTextField is active or not.

• font: This property is used to set the font of the text that appear on the JTextField.

• foreground: This property is used to set the color of the text that appear on the JTextField.

• text : This property is used to set the text of the JTextField.

• editable: This property determines whether user can edit the text or not.

Page 9: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextField

void setText(String)- It is used to set the text of the TextField with the string specified in parenthesis. The general syntax to use the setText() method with the TextField is as follows:

<TextFieldname>.setText(string);

Page 10: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextField

void getText()- It is used to get the text of the TextField. The general syntax to use getText() method is as follows

<textfieldname>.getText();

Page 11: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextField

boolean isEditable()- It returns the setting (true/false) whether the user can edit the text in TextField or not. The general syntax to use this method is as follows:

<textfieldname>.isEditable();

Page 12: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextField

boolean isEnabled()- It returns the setting (true/false) whether the TextField is active or not. The general syntax to use this method is as follows:

<textfieldname>.isEnabled();

Page 13: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

TextArea

It is a multi-line text component to display text or allow user to enter text. It is created through JTextArea class of swing.

Page 14: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of TextArea

• background: This property is used to set the background color of the JTextArea.

• enabled: This property determines whether the JTextArea is active or not.

• font: This property is used to set the font of the text that appear on the JTextArea.

• foreground: This property is used to set the color of the text that appear on the JTextArea.

Page 15: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of TextArea

• editable: This property determines whether user can edit the text or not.

• rows: This property is used to set the number of rows for the Text Area.

• columns : This property is used to set the number of columns of the Text Area.

Page 16: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextArea

void setText(String)- It is used to set the text of the TextArea with the string specified in parenthesis. The general syntax to use the setText() method is as follows:

<textareaname>.setText(string);

Page 17: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextArea

void getText()- It is used to get the text of the TextArea. The general syntax to use getText() method is as follows

<textareaname>.getText();

Page 18: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextArea

boolean isEditable()- It returns the setting (true/false) whether the user can edit the text in TextArea or not. The general syntax to use this method is as follows:

<textareaname>.isEditable();

Page 19: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextArea

boolean isEnabled()- It returns the setting (true/false) whether the TextArea is active or not. The general syntax to use this method is as follows:

<TextAreaname>.isEnabled();

Page 20: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of TextArea

void append(string)- It adds the string specified in parenthesis to the end of TextArea. The general syntax to use this method is as follows:

<TextAreaname>.append(string);

Page 21: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

PasswordField

Password field is a field which display the text in encrypted form. It is a components of JPasswordField class of swing.

Page 22: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of PasswordField

• background: This property is used to set the background color of the JPasswordField.

• font: This property is used to set the font of the text that appear on the JPasswordField.

• foreground: This property is used to set the color of the text that appear on the JPasswordField.

• echoChar: This property determines which character will replace the text in display.

Page 23: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of Passwordfield

char getEchoChar: This method will return the echo character of a password field. The general syntax to use this method is as follows:

<passwordfieldname>.getEchoChar();

Page 24: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of Passwordfield

void setEchoChar(char)- It sets the echo character – the character displayed instead of the actual characters typed by the user.The general syntax to use this method is as follows:

<passwordfieldname>.setEchoChar(char);

Page 25: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

CheckBox

Check box is a control that indicates whether a particular condition is on or off. It is a components of JCheckBox class

Page 26: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of CheckBox

• background: This property is used to set the background color of the CheckBox.

• enabled: This property determines whether the CheckBox is active or not.

• font: This property is used to set the font of the text that appear on the CheckBox.

• foreground: This property is used to set the color of the text that appear on the CheckBox.

• text : This property is used to set the text of the JCheckBox.

• selected: if sets to true checkbox appear selected.

Page 27: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of CheckBox

boolean isSelected(): it returns the state of the checkbox. “true” if selected otherwise “false”. The general syntax to use this method is as follows:

<checkboxname>.isSelected();

Page 28: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of CheckBox

void setSelected(booleanvalue): it is used to check or uncheck the Checkbox. The general syntax to use this method is as follows:

<checkboxname>.setSelected(booleanvalue);

Page 29: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of CheckBox

void setText(String)- It is used to set the text of the CheckBox with the string specified in parenthesis. The general syntax to use the setText() method is as follows:

<CheckBoxname>.setText(string);

Page 30: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of CheckBox

void getText()- It is used to get the text of the CheckBox. The general syntax to use getText() method is as follows

<CheckBoxname>.getText();

Page 31: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

RadioButton

RadioButton is used to provide the set of choices, out of that user can select one and only one.

Page 32: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of RadioButton

• background: This property is used to set the background color of the RadioButton.

• enabled: This property determines whether the RadioButton is active or not.

• font: This property is used to set the font of the text that appear on the RadioButton.

• foreground: This property is used to set the color of the text that appear on the RadioButton.

Page 33: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of RadioButton

• text : This property is used to set the text of the JRadioButton.

• selected: if sets to true RadioButton appear selected.

• buttongroup: it specifies the name of group of buttons to which radiobutton belongs.

Page 34: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of RadioButton

boolean isSelected(): it returns the state of the RadioButton. “true” if selected otherwise “false”. The general syntax to use this method is as follows:

<RadioButtonname>.isSelected();

Page 35: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of RadioButton

void setSelected(booleanvalue): it is used to check or uncheck the RadioButton. The general syntax to use this method is as follows:

<RadioButtonname>.setSelected(booleanvalue);

Page 36: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of RadioButton

void setText(String)- It is used to set the text of the RadioButton with the string specified in parenthesis. The general syntax to use the setText() method is as follows:

<RadioButtonname>.setText(string);

Page 37: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of RadioButton

void getText()- It is used to get the text of the RadioButton. The general syntax to use getText() method is as follows

<RadioButtonname>.getText();

Page 38: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

ScrollPane

To show any component which is bigger than display area, you can put that component in a scroll pane.

others
Page 39: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

JOptionPane

It allows to create popup window( such as alert or message boxes or input box ) with varied content. The JOptionPane comes with some built-in styles that you can use as per your requirement.

Page 40: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

JAVA IDE PROGRAMMING - III

Page 41: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

List

A List( also called List box sometimes) is a box-shaped control containing a list of attributes or objects from which single or multiple selections can be made.

Page 42: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of List

• background: This property is used to set the background color of the List.

• enabled: This property determines whether the List is active or not.

• font: This property is used to set the font of the text that appear on the List.

• foreground: This property is used to set the color of the text that appear on the List.

Page 43: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of List

• model: it is the object containing the data to be exhibited by the list.

• selectedIndex: returns the index of selected item. default is -1.

• selectionMode: It describes the mode for selecting list items. It defines three modes of selection: SINGLE, SINGLE_INTERVAL, MULTIPLE_INTERVAL.

Page 44: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Different list selection modes

SINGLE: User can select a single item.

SINGLE_INTERVAL: User can select single range of items.

MULTIPLE_INTERVAL: User can select multiple range of items.

Page 45: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of List

• Object getSelectedValue() : Returns the selected value when only a single Item is selected. When multiple Items are selected, it returns the first selected value. Returns null if there is no selection.

• int getSelectedIndex() : Returns the index of selected value when only a single Item is selected. When multiple Items are selected, it returns the index of first selected value. Returns -1 if there is no selection.

Page 46: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

ComboBox

A combobox appears as a text field along with a drop-down list arrow from which the user can choose a value. By default, the text field of a combo box is uneditable, but you can change it to be editable by setting its editable property to true. If the text field portion of the control is editable, the user can enter a value into the field or edit a value retrieved from the drop-down list.

Page 47: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of ComboBox

• background: This property is used to set the background color of the ComboBox.

• enabled: This property determines whether the ComboBox is active or not.

• font: This property is used to set the font of the text that appear on the ComboBox.

• foreground: This property is used to set the color of the text that appear on the ComboBox.

Page 48: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used properties of ComboBox

• model: it is the object containing the data to be exhibited by the ComboBox.

• selectedIndex: returns the index of selected item. default is -1.

Page 49: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Commonly Used methods of ComboBox

• Object getSelectedItem() : Returns the selected item.Returns null if there is no selection.

• int getSelectedIndex() : Returns the index of selected value. Returns -1 if there is no selection.

Page 50: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Differences between List and ComboBox

List ComboBox

We can select multiple items.

Only a single item can be selected.

User not have the option to edit the selected item.

User can edit the selected item.

User has to select directly from the list items

User can enter a value if it is not present in set of values

It takes more space. It takes less space.

Page 51: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Programming Guidelines

Page 52: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Stylistic Guidelines

• Meaningful names for identifier.

• Ensure clarity of expression

• Use comment and indentation

• Insert blank lines and spaces

• Statement formatting Style

Page 53: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Preetyprinting

• When program formatting is done to make a program more readable, it is called prettyprinting.

Page 54: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Characteristics of a good program

• Effective and Efficient: The program produces correct result and is faster.

• User Friendly: The program should not interact with user by understandable messages and user should not be concerned about what is happening inside the program.

• Self-Documenting code:

Page 55: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Characteristics of a good program

• Self-Documenting code: Source code uses meaningful name for identifier to clarify the meaning of the program.

• Reliable: It must be able to handle unexpected situations like wrong data or no data.

• Platform: it should be able to run on different platforms

Page 56: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Stages of Program Development Process

• Crack the Problem: An algorithm is formulated which gives the solution for the problem.

• Code the algorithm: algorithm is translated into source code using some programming language.

• Compile the program: In this, source code is converted into the object code.

• Execute the program: In this, program instruction are carried out.

Page 57: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Robustness

The ability of a program, to recover following an error and to continue operating with its environment is called Robustness.

Page 58: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Guard code

The code that can handle exceptional data errors and operational errors is called Guard Code.

Page 59: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Exception Handling

Contradictory or Unexpected situation or unexpected error is known as Exception. Way of handling anomalous situations in a program-run, is known as Exception Handling. To control an exception, Java provides try-catch construction.

Page 60: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Using try and catch block

try{

tested statements;}catch(ExceptionName e){ exceptionhandling statements;}

Page 61: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Problem Solving Methodology

and Techniques

Page 62: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Steps to create a working program

• Understand the problem well: In this step you must understand the problem well so as to figure out “what it is that is to be done”.

• Analyze the problem: It involves identify the program specifications and defining each program’s minimum number of inputs, required for output and processing components

Page 63: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Steps to create a working program

• Design programs: In this step you are supposed to determine the logical sequence of steps to solve the given problem. Such a logical sequence of steps are called algoritm.

• Code programs: It is the step to translate the algorithm into source code using programming language.

Page 64: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Steps to create a working program

• Test and debug the program: Testing is the process of finding the errors in the program and debugging is the process of correcting the errors found during the testing process.

• Complete the documentation: Documentation is intended to allow another person or the programmer at later date, to understand the program.

Page 65: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Documentation

It refer to written description, specifications, design, code and comment, internal and external to a program, which make a program more readable, understandable and more easily modifiable.

It is of two types: 1. internal documentation: refers to comments in

the program. 2. external documentation: refers to instruction

manual

Page 66: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Steps to create a working program

• Understand the problem well: In this step you must understand the problem well so as to figure out “what it is that is to be done”.

• Analyze the problem: It involves identify the program specifications and defining each program’s minimum number of inputs, required for output and processing components

Page 67: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Steps to create a working program

• Maintain programs: Maintaining programs involves modifying the programs to remove previously undetected errors, to enhance the program with different features or functionality or keep the program up-to-date as government regulations or companies polices changes.

Page 68: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Type of Maintenance

• Corrective Maintenance

• Adaptive Maintenance

• Preventive Maintenance

• Perfective Maintenacne

Page 69: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

DBMS Concepts

Page 70: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Database

A database may be defined as a collection of interrelated data stored together to serve multiple applications.

Page 71: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

DBMS

A DBMS(Data Base Management System) refers to a software that is responsible for storing, maintaining and utilizing databases.

Page 72: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Database System

A database along with a DBMS is referred to as a database system.

Page 73: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Advantages of Database System

• Databases reduces the data redundancy to a large extent.

Page 74: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Redundancy

Duplication of data is known as data redundancy.

Page 75: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Advantages of Database System

• Databases can control data inconsistency to a large extent.

• Databases facilitate sharing of data.

• Databases enforce standards.

• Databases can ensure data security.

Page 76: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Security

It refers to the protection of data against accidental or intentional disclosure to unauthorized persons, or unauthorized modification or destruction.

Page 77: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Privacy of Data

It refers to the rights of individuals and organizations to determine themselves when, how, and to what extent information about them is to be transmitted to other.

Page 78: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Advantages of Database System

• Integrity can be maintained through databases.

Page 79: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Levels of Database Implementation

• Internal Level(Physical Level): It describes how the data are actually stored on the storage medium.

• Conceptual Level(Logical Level): It describes what data are actually stored in the database.

• External Level(View Level): This level is closest to the user and is concerned with the way in which data are viewed by the individual user.

Page 80: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Independence

The ability to modify the scheme definition in one level without affecting a scheme definition in next higher level is called Data Independence. Two level of data independence are:

Physical and Logical

Page 81: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Physical Data Independence

It refers to the ability to modify the scheme followed at the physical level without affecting the scheme at conceptual level.

Page 82: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Logical Data Independence

It refers to the ability to modify the scheme followed at the conceptual level without affecting the scheme at view level.

Page 83: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Model

It refers to a set of concepts to describe the structure of a database and certain constraints that the database should obey. Different data models are:

•Relational Data Model

•Hierarchical Data Model

•Network Data Model

•Object Oriented Data Model

Page 84: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Relational Data Model

It was propounded by E.F. Codd of the IBM.

In relational data model, the data is organized into tables(i.e. rows and columns). These tables are called relations.

Page 85: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Relational Data Model Terminology

Page 86: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

View

It is a table that does not exist in its own right but is instead derived from one or more underlying base tables.

Page 87: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Primary Key

It is a set of one or more attributes that can uniquely identify tuples within the relation.

Page 88: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Candidate Key

All attribute combinations inside a relation that can serve as primary key are candidate keys.

Page 89: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Alternate Key

A candidate key that is not the primary key is called an alternate key.

Page 90: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Foreign Key

A non-key attribute, whose values are derived from the primary key of some other table, is known as Foreign-Key in the current table.

Page 91: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Referential Integrity

It is a system of rules that DBMS uses to ensure that relationships between records in related tables are valid, and that users don’t accidentally delete or change related data.

Page 92: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Introduction to MySQL

Page 93: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

MySQL

It is freely available open source Relational Database Management System (RDBMS).

MySQL was created and is supported by MySQL, AB, a company based in Sweden (www.mysql.com). The chief inventor of MySQL was Michael Widenius. MySQL has been named after his daughter My.

Page 94: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Dictionary

It is a file that contains metadata. i.e. data about data.

Page 95: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Classification of SQL statements

• Data Definition Language (DDL) commands

• Data Manipulation Language (DML) commands

• Transaction Control Language (TCL) commands

• Session Control Commands

• System Control Commands

Page 96: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Definition Language (DDL) commands

It allows you to perform tasks related to data definition. You can perform tasks like:

Create, alter and drop schema objectsThis section of DDL commands is used to create or define or change or delete objects such as a table, a view, an index etc. e.g. CREATE TABLE, ALTER TABLE, DROP TABLE etc.

Page 97: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Definition Language (DDL) commands

Grant and revoke privileges and roles:

This section of DDL commands is used to grant or revoke permissions to work upon schema objects. e.g. GRANT, REVOKE etc. This section of DDL commands is also known as Data Control Language (DCL) commands

Page 98: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Definition Language (DDL) commands

Maintenance commands:

This section of DDL commands is used to analyze information on a table with an aim of maintaining it. e.g. ANALYZE TABLE, REPAIR TABLE etc.

Page 99: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Manipulation Language (DML) commands

By data manipulation, we mean : the retrieval of the information stored in

the database.the insertion of new information into the

databasethe deletion of the information from the

database.the modification of data stored in the

database.

Page 100: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Data Manipulation Language (DML) commands

DML is a language that enables user to access or manipulate data as organized by the appropriate data model. E.g INSERT, UPDATE, DELETE etc.

Page 101: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Transaction Control Language (TCL) commands

These commands manages the changes made by DML commands. E.g.

BEGIN / START TRANSACTION : It marks the beginning of a transaction.

COMMIT: It ends the current transaction by saving database changes and start new transaction.

Page 102: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Transaction Control Commands

ROLLBACK: It ends the current transaction by discarding database changes and start new transaction.

SAVEPOINT: It defines breakpoints for the transaction to allow partial rollbacks.

Page 103: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

SIMPLE QUERIES IN

SQL

Page 104: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

SQL

SQL was developed in 1970s in an IBM Laboratory. SQL sometimes also referred to as SEQUEL is 4th generation non-procedural language.

Page 105: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Dialogs in Java

Page 106: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Dialog

A dialog is a small separate sub window that appears to either provide or request information to/from the user.

Page 107: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Types of Dialog

• JDialog: Main dialog class (general purpose dialog)

• JOptionPane: Provides a variety of built-in dialog styles i.e. pre-defined styles.

• JFileChooser: Dialog for choosing files.

• JColorChooser: Dialog for choosing color.

Page 108: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Types of JOptionPane Dialog

• Input dialog: It provides some way for user to enter data. It is created

using showInputDialog method.

• Confirm dialog: It ask user to confirm some information. It is created using showConfirmDialog method.

Page 109: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Types of JOptionPane Dialog

• Message dialog: It simply inform the user by displaying a message. It is created using showMessageDialog method.

• Option dialog: It provides flexiblity, which you can use to create dialog as per your needs. It is created using showOptionDialog method.

Page 110: JAVA IDE PROGRAMMING - II. Controls for Output In order to display information to the user, we need certain controls. These are as follows:

Table

The jTable is a swing control that enables you to display data in a table and manipulate it in many ways. The model property of a jTable component specifies the source of data to be displayed by table.