CS431 ws99 Half Text Half Graphics

Slides:



Advertisements
Similar presentations
Dialogs. Displaying Text in a Dialog Box Windows and dialog boxes –Up to this our output has been to the screen –Many Java applications use these to display.
Advertisements

Using JOptionPanes for graphical communication with our programs. Pages Horstmann 139.
1 Introduction to Java Programming Lecture 4 Using JOptionPane Spring 2008.
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
Chapter 2 - Introduction to Java Applications
1 Introduction to Java Programming Lecture 4 Using JOptionPane Spring 2010.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
JOptionPane class. Dialog Boxes A dialog box is a small graphical window that displays a message to the user or requests input. A variety of dialog boxes.
Warm-Up: Monday, March 3 List all devices you can think of that can be used to input information into the computer.
F27SB2 Software Development 2 Lecture 9: Java GUIs 6.
SWING. Split Panes JSplitPane is used to divide two (and only two) Components. The two Components are graphically divided based on the look and feel implementation,
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
11/9: Recursion, Method Overloading About Scoping.java Recursion Method overloading.
Java Programming, Second Edition Chapter Five Input and Selection.
Intro to Java Java Applications Swing Class Graphics.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
9/6: Variable Types, Arithmetic Operators, Comparison Operators Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic.
Dale Roberts GUI Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
CSTP FS99CS423 (cotter)1 Java Graphics java.awt.*;
习 题 4.23 编写一个 applet ,读取一个矩形的边长,然后 用在 paint 方法中使用 drawString 方法画出用星组成 的空心矩形。程序应能画出边长从 1 到 20 的任何矩 形。
GUI Clients 1 Enterprise Applications CE00465-M Clients with Graphical User Interfaces.
Input/Output in Java. Output To output to the command line, we use either System.out.print () or System.out.println() or System.out.printf() Examples.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
1 Java Programming 1 Introduction to Basic GUI Lesson 4.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
1 COMP 241: Object-Oriented Programming with Java Fall 2004 Lecture 1 September 27, 2004 Serdar Taşıran.
9/20: The while Repetition Structure last time’s program repetition structures: what they are the while repetition structure homework due on Thursday program.
1/23: Java Modular Components Identifiers: naming requirements for Java variables & objects Stepping out of the MS-DOS window: The Java Modular Component:
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
1/28: Inputs, Variable Types, etc. Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic operators.
Dialog Boxes.
Data Types – Reference Types Objective To understand what reference types are The need to study reference types To understand Java standard packages To.
GUI Graphical User Interface Each onscreen component and window is an object Object interaction makes communication and scoping challenging Event-driven.
2/18: Assignment Operators About Average2.java –while loop use –explicit casting –twoDigits object Assignment Operators Increment & Decrement Operators.
JOptionPane Class JOptionPane makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something. While the JOptionPane.
SE-1020 Dr. Mark L. Hornick 1 Graphical User Interfaces.
Creating and Using Dialogs ● A dialog is a box that pops up and prompts the user for a value or informs them of something ● One way: directly create objects.
Casting, Wrapper Classes, Static Methods, JOptionPane Class.
Object Oriented Programming Object and Classes Lecture 3 MBY.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 6_1 GEORGE KOUTSOGIANNAKIS Copyright: FALL 2015 Illinois Institute of Technology- George Koutsogiannakis 1.
Objects First With Java A Practical Introduction Using BlueJ Building Graphical User Interfaces (GUIs) Week
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Introduction to GUI in 1 Graphical User Interface Nouf Almunyif.
Object Oriented Programming (OOP) LAB # 3 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
AP Java 10/1/2015. public class Rolling { public static void main( String [] args) public static void main( String [] args) { int roll; int roll; for.
Java Programming Lecture 2
Building a Swing Interface
OBJECT ORIENTED PROGRAMMING I LECTURE 7 GEORGE KOUTSOGIANNAKIS
A Java Program: // Fig. 2.1: Welcome1.java // Text-printing program.
AP Java 10/4/2016.
2.5 Another Java Application: Adding Integers
Section 64 – Manipulating Data Using Methods – Java Swing
Dialogues and Wrapper Classes
CSE 114 – Computer Science I Event Programming
Message, Input, Confirm, and Specialized Dialogs
JOptionPane Dialogs javax.swing.JOptionPane is a class for creating dialog boxes. Has both static methods and instance methods for dialogs. Easy to create.
Introduction to GUI in Graphical User Interface Nouf Almunyif.
OBJECT ORIENTED PROGRAMMING I LECTURE 7 GEORGE KOUTSOGIANNAKIS
CS18000: Problem Solving and Object-Oriented Programming
Chapter 2 - Introduction to Java Applications
AP Java 10/4/2016.
Message, Input, and Confirm Dialogs
Object Oriented Programming
Ch. No Name Marks 01 AWT Networking JDBC Swing 05
Object-Oriented Software Engineering
Ch. No Name Marks 01 AWT Networking JDBC Swing 05
JOptionPane class.
F II 2. Simple Java Programs Objectives
Chapter 2: Java Fundamentals cont’d
Presentation transcript:

CS431 ws99 Half Text Half Graphics 4/8/2019 Applications in Java 1.2 Half Text Half Graphics CSTP FS99 CS423 (cotter) <title>

Swing Components Defined in package javax.swing CS431 ws99 4/8/2019 Swing Components Defined in package javax.swing Pure Java components AWT components tied to local platform GUI UNIX java windows look like X windows Windows java windows look like windows windows (??) etc. Swing defines a common look and feel for Java. CSTP FS99 CS423 (cotter) <title>

Swing Components Derive from awt classes CS431 ws99 4/8/2019 Swing Components Derive from awt classes java.lang.Object -> java.awt.Component -> jav.awt.Container -> javax.swing.Jcomponent Methods overloaded in swing to allow different behaviour CSTP FS99 CS423 (cotter) <title>

Product.java / From Java: How to Program - Deitel and Deitel CS431 ws99 4/8/2019 Product.java / From Java: How to Program - Deitel and Deitel // Calculate the product of three integers import javax.swing.JOptionPane; public class Product { public static void main( String args[] ) { int x, y, z, result; String xVal, yVal, zVal; xVal = JOptionPane.showInputDialog( "Enter first integer:" ); yVal = JOptionPane.showInputDialog( "Enter second integer:" ); zVal = JOptionPane.showInputDialog( "Enter third integer:" ); CSTP FS99 CS423 (cotter) <title>

Product.java x = Integer.parseInt( xVal ); CS431 ws99 4/8/2019 Product.java x = Integer.parseInt( xVal ); y = Integer.parseInt( yVal ); z = Integer.parseInt( zVal ); result = x * y * z; JOptionPane.showMessageDialog( null, "The product is " + result ); System.exit( 0 ); } CSTP FS99 CS423 (cotter) <title>

Product Output(s) CSTP FS99 CS423 (cotter) CS431 ws99 4/8/2019 <title>

JOptionPane Similar to windows message boxes Types of Option Panes: CS431 ws99 4/8/2019 JOptionPane Similar to windows message boxes Types of Option Panes: showConfirmDialog(null,message,title,optionType,msgType); Asks a confirming question, like yes/no/cancel. showInputDialog(message); Prompt for some input. showMessageDialog(null, message); Tell the user about something that has happened. showOptionDialog(....); The Grand Unification of the above three. CSTP FS99 CS423 (cotter) <title>

OptionType DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION CS431 ws99 4/8/2019 OptionType DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION OK_CANCEL_OPTION CSTP FS99 CS423 (cotter) <title>

messageType ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE CS431 ws99 4/8/2019 messageType ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE PLAIN_MESSAGE CSTP FS99 CS423 (cotter) <title>