Creating Graphical User Interfaces 2011.04.22.

Slides:



Advertisements
Similar presentations
Graphical User Interfaces
Advertisements

Graphic User Interfaces Layout Managers Event Handling.
JAVA 程式語言入門 (II).  版面配置  事件驅動  Ch14_01.java 1. import javax.swing.*; 2. import java.awt.*; 3. class Ch14_01 4. { 5. public static void main(String.
JAVA API (GUI) Subject:T0934 / Multimedia Programming Foundation Session:1 Tahun:2009 Versi:1/0.
 Java GUI API  Layout Managers [Sample code] ShowFlowLayout.java 、 ShowGripLayout.java 、 ShowBorderLayout.java TestImageIcon.java.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
1 Chapter 13 Creating User Interfaces. 2 Objectives F To create graphical user interfaces with various user-interface components: JButton, JCheckBox,
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 16 Creating User Interfaces.
Thinking in Objects Outline The this Reference [Sample code] PressEnter.java.
Binary I/O Outline Text I/O Chap 9. WriteData Chap 9. ReadData Binary I/O Text I/O vs Binary I/O Binary I/O Classes Using DataInputStream/DataOutputStream.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
IEEM 110 Computing in Industrial Applications Basic User Interface in Java.
Graphics Outline Graphical Coodinate Systems The Graphics Class Drawing Strings, Lines, Rectangles, and Ovals Drawing Polygons.
Layout Managers Outline Java GUI API Layout Managers [Sample code] ShowFlowLayout.java 、 ShowGripLayout.java 、 ShowBorderLayout.java.
Applet and Multimedia Outline Developing Applets Applet Life-Cycle Method Passing Strings to Applets [Sample code] DisplayLabel.html.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L03 (Chapter 15) Creating.
OBJECTS AND CLASSES Outline Reference Variables and Reference Types Primitive Types and Reference Types Static Variable, Constants,
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L04 (Chapter 15) Creating.
Event-Driven Programming Outline Event and Event Source Event Types Listeners,Registerations,and Handling Events Event’s Declaration.
String and Text I/O Outline The String Class Immutable Strings and Interned Strings String Comparisons String Length, Characters,
1 Creating User Interfaces. 2 Motivations A graphical user interface (GUI) makes a system user-friendly and easy to use. Creating a GUI requires creativity.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Java class Outline Defining a method Calling Method Passing parameters [Sample code] TestMethod.java 、 TestMethod2.java 、 GCD.java 、 prime.java.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Java the UML Way versjon Only to be used in connection with the book "Java the UML Way", by Else Lervik and.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 12 GUI Basics.
Java Swing. Swing is a set of classes that provides more powerful and flexible components than are possible with the AWT. In addition to the familiar.
SWING. AbstractButton Swing Buttons are subclasses of the AbstractButton class, which extends JComponent. Abstract class javax.swing.AbstractButton AbstractButton.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight.
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Java Programming Applets. Topics Write an HTML document to host an applet Understand simple applets Use Labels with simple AWT applets Write a simple.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
Java GUI. Overview The ”idea” The ”idea” The Components The Components Listeners Listeners The Program The Program Interface Eventlistener Interface Eventlistener.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Review_6 AWT, Swing, ActionListener, and Graphics.
Creating User Interfaces Chapter 13 CSCI CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons.
Creating User Interfaces Event-Driven Programming.
Basics of GUI Programming Chapter 11 and Chapter 22.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
Lecture 33: More Graphical User Interface (GUI) Announcements & Review Read Ch GU1 & GU2 Cohoon & Davidson Ch 14 Reges & Stepp Lab 10 set game due 4/26.
1 Lecture 8: User Interface Components with Swing.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 12 GUI Basics.
GUI.1 Graphical User Interfaces GUIs. GUI.2 The Plan Components Flat Layouts Hierarchical Layouts Designing a GUI Coding a GUI.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 7. GUI Components - > Jframe ->JPasswordField (javax.Swing.JPasswordField) GUI Components - > Jframe ->JPasswordField.
JButton Chapter 11 Lecture 3.
Lecture 09 Applets.
Chapter 13: Advanced GUIs and Graphics
Welcome to CIS 068 ! GUIs: JAVA Swing
Chapter 7 Creating User Interfaces
Chapter 13 Creating User Interfaces
Basic Elements of The GUI
Graphical User Interfaces in Java Event-driven programming
Chapter 12 GUI Basics.
Advanced GUIs and Graphics
Presentation transcript:

Creating Graphical User Interfaces

Outline Swing GUI components Buttons Button Alignments CheckBox [Sample code] TestButtonIcons.java 、 TestCheckBox.java

Swing GUI components ( 課本 p.596)

Buttons JButton inherits AbstractButton Defined in javax.swing.AbstractButton javax.swing.AbstractButton -actionCommand: String -text: String -icon: javax.swing.Icon -pressedIcon: javax.swing.Icon -rolloverIcon: javax.swing.Icon -mnemonic: int -horizontalAlignment: int -horizontalTextPosition: int

javax.swing.JButton +JButton() +JButton(icon: javax.swing.Icon) +JButton(text: String) +JButton(test: String, icon: Icon) +addActionListener(listener: ActionListener) : void javax.swing.AbstractButton ( 課本 p.597)

程式範例 :  TestButtonIcons.java

Button Alignments Horizontal alignment: ( 調校按鈕 icon 及 text 水平位置 ) LEADING 、 LEFT 、 CENTER 、 RIGHT 、 TRAILING Ex:.setHorizontalAlignment(SwingConstants.CENTER) Vertical alignment: ( 調校按鈕 icon 及 text 垂直位置 ) TOP 、 CENTER 、 BOTTOM Ex:.setVerticalAlignment(SwingConstants.CENTER)

CheckBox javax.swing.JCheckBox +JCheckBox() +JCheckBox(text: String) +JCheckBox(text: String, selected: boolean) +JCheckBox(icon: Icon) +JCheckBox(text: String, icon: Icon) +JCheckBox(text: String, icon: Icon, selected: boolean) +addActionListener(listener: ActionListener): void +addItemListener(listener: ItemListener): void javax.swing.JToggleButton javax.swing.AbstractButton ( 課本 p.602)

程式範例 :  TestCheckBox.java

程式練習 :  Programming Exercises 17.2