(AJP) Chapter 1
(AJP) Chapter 1
(AJP) Chapter 1
INFORMATICS
DEPARTMENT OF SOFTWARE
ENGINEERING
BY SAMSON R.
Chapter One
GUI II
Introduction
Definition of User Interface
In computer science and human-computer interaction, the user
interface (of a computer program) refers to the graphical, textual
and auditory information the program presents to the user.
The user employs several control sequences (such as keystrokes
with the computer keyboard, movements of the computer mouse,
or selections with the touch screen) to control the program.
Cont..
Types of User Interfaces
Command-Line Interface (CLI)
The user provides the input by typing a command string with the
computer keyboard and the system provides output by displaying
text on the computer monitor.
Graphical User Interface (GUI)
The use of pictures rather than just words to represent the input
and output of a program.
Input is accepted via devices such as keyboard and mouse.
CLI
GUI
Graphical user interface
Graphical user interface (GUI) presents a user-friendly
mechanism for interacting with an application.
Gives an application a distinctive “look” and “feel”.
Providing different application with consistent, intuitive user
interface components allows users to be
-- somewhat familiar with an application
BorderPane
HBox
VBox
GridPane
FlowPane
TilePane
StackPane
BorderPane
The BorderPane layout pane provides five regions in which to place
nodes: top, bottom, left, right, and center.
The regions can be any size.
If your application does not need one of the regions, you do not
need to define it and no space is allocated for it.
A border pane is useful for the classic look of a tool bar at the top, a
status bar at the bottom, a navigation panel on the left, additional
information on the right, and a working area in the center.
Cont..
If the window is larger than the space needed for the contents of
each region, the extra space is given to the center region by default.
If the window is smaller than the space needed for the contents of
each region, the regions might overlap.
The overlap is determined by the order in which the regions are set.
For example, if the regions are set in the order of left, bottom, and
right, when the window is made smaller, the bottom region overlaps
the left region and the right region overlaps the bottom region.
Cont..
HBox
The Hbox layout pane provides an easy way for
arranging a series of nodes in a single row (horizontally).
The padding property can be set to manage the distance
between the nodes and the edges of the Hbox pane.
Spacing can be set to manage the distance between the
nodes.
The style can be set to change the background color.
Cont..
Adding HBox
label1.setGraphic(new ImageView(image));
label1.setTextFill(Color.web("#0076a3"));
Applying Font Settings to a label
label2.setFont(Font.font("Cambria", 32));
Button
Button class resides in the javafx.scene.control package of the JavaFX API
enables developers to process an action when a user clicks it.
is an extension of the Labeled class.
It can display text, an image, or both.
Cont..
Creating Button
Assigning an Action
The primary function of each button is to produce an action when it is
clicked. Use the setOnAction() method of the Button class to define what will
happen when a user clicks the button.
Cont..
Defining an Action for a Button
button2.setOnAction((ActionEvent e) ->{
label.setText("Accepted");
});
shows how to process an ActionEvent, so that when a user presses
button2 the text caption for a label is set to "Accepted."
You can use the Button class to set as many event-handling methods as
you need to cause the specific behavior or apply visual effects.
Cont..
Styling a Button
//Code added to the CSS file
.button1{
-fx-font: 22 arial;
-fx-base: #b6e7c9;
} //Code in the ButtonSample.java file
button1.getStyleClass().add("button1");
rb3.setToggleGroup(group);
CheckBox
CheckBox class resides in the javafx.scene.control package of the
JavaFX API.
CheckBox control allow the user to select many options at a time.
Cont..
Creating Checkboxes
//A checkbox without a caption
CheckBox cb1 = new CheckBox();
//A checkbox with a string caption
CheckBox cb2 = new CheckBox("Second");
cb1.setText("First");
// set the checked box to be selected
cb1.setSelected(true);
ChoiceBox
Choice Box class resides in the javafx.scene.control package of the JavaFX API.
Choice Box control provides support for quickly selecting between a few options.
//Creating TextField
TextField tf = new TextField ();
Cont.
To defines the string that appears in the text field when the application is
started TextField use setPromptText() method.
Prompt captions notify users what type of data to enter in the text fields.
The difference between the prompt text and the text entered in the text field
is that the prompt text cannot be obtained through the getText() method
Cont.
Some helpful methods that you can use with text fields.
passwordField.setPromptText("Your password");
ComboBox
A combo box is a typical element of a user interface that enables users to
choose one of several options.
A combo box is helpful when the number of items to show exceeds some limit,
because it can add scrolling to the drop down list, unlike a choice box.
If the number of items does not exceed a certain limit, developers can decide
whether a combo box or a choice box better suits their needs.
ComboBox
Creating a Combo Box with an Observable List
At any time, you can supplement the list of items with new values.
comboBox.getItems().addAll(
"Option 4","Option 5","Option 6");
Just Relax
Quiz
1.What is stackPane?Why it is ne
2. What is the exact difference between TilePane and FlowPane?
3. One layout can be root node for the other layout(T/F)?
4.Clearly describe the difference between java swing and javafx. Also compare
and contrast the advantage and disadvantage of javafx and swing?
5.Assume the arrangement order of nodes in flowPane layout is bottom ,top,
right and left flowPane Layout. Which one of the followings are possible
overlapping if size of node is larger than the cell in layout.
A. Right Overlaps Left B. Top Overlaps Bottom
C. Right Overlaps Top D. Left Overlaps Right
Just Relax
Quiz
1.What is stackPane?When we use StackPane?
2. Create VBOx layout and add two button on layout?
3. One layout cannot be root node for the other layout(T/F)?
4.Clearly describe the difference between java AWT,Swing and javafx. Also
compare and contrast the advantage and disadvantage of javafx and swing?
5.Assume the arrangement order of nodes in flowPane layout is bottom ,top,
right and left flowPane Layout. Which one of the followings are possible
overlapping if size of node is larger than the cell in layout.
A. Right Overlaps Left B. Top Overlaps Bottom
C. Right Overlaps Top D. Left Overlaps Right