1/23: Java Modular Components Identifiers: naming requirements for Java variables & objects Stepping out of the MS-DOS window: The Java Modular Component:

Slides:



Advertisements
Similar presentations
 2005 Pearson Education, Inc. All rights reserved Introduction.
Advertisements

1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Chapter 2 - Introduction to Java Applications
 2003 Prentice Hall, Inc. All rights reserved. 1 Lecture 3 Variables Primitive Data Types calculations & arithmetic operators Readings: Chapter 2.
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.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
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.
Object-Oriented Programming with Java Java with added Swing Lecture 3.
COMP 14 Introduction to Programming Miguel A. Otaduy May 17, 2004.
Introduction to Computers and Programming Lecture 3: Variables and Input Professor: Evan Korth New York University.
Writing methods and Java Statements. Java program import package; // comments and /* … */ and /** javadoc here */ public class Name { // instance variables.
 2003 Prentice Hall, Inc. Modified for use with this class. All rights reserved. 1 Introduction to Computers and Programming in JAVA: V Primitive.
Introduction to Computers and Programming Lecture 4: Mathematical and Relational Operators.
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.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing.
Using Classes BCIS 3680 Enterprise Programming. Overview 2  Using Classes  Using premade classes for input and output  Display output: System, JOptionPane.
Chapter 2 Introduction to Java Applications.
Chapter 2: Java Fundamentals
9/6: Variable Types, Arithmetic Operators, Comparison Operators Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic.
习 题 4.23 编写一个 applet ,读取一个矩形的边长,然后 用在 paint 方法中使用 drawString 方法画出用星组成 的空心矩形。程序应能画出边长从 1 到 20 的任何矩 形。
Introduction to Java. 2 A Brief History of OOP and Java Early high level languages –_________________________ More recent languages –BASIC, Pascal, C,
 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.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
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/28: Inputs, Variable Types, etc. Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic operators.
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
2/18: Assignment Operators About Average2.java –while loop use –explicit casting –twoDigits object Assignment Operators Increment & Decrement Operators.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
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.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing.
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.
Introduction to Java. 2 A Brief History of OOP and Java Early high level languages –FORTRAN, COBOL, LISP More recent languages –BASIC, Pascal, C, Ada,
1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing a Line of Text 2.2.1Compiling and Executing.
3 Introduction to Classes and Objects.
Outline Creating Objects The String Class Packages Formatting Output
A Java Program: // Fig. 2.1: Welcome1.java // Text-printing program.
“Form Ever Follows Function” Louis Henri Sullivan
CSC305: COMPUTER PROGRAMMING II (JAVA)
Yanal Alahmad Java Workshop Yanal Alahmad
2.5 Another Java Application: Adding Integers
Chapter 2 - Introduction to Java Applications
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.
Advanced Programming Lecture 02: Introduction to C# Apps
CS18000: Problem Solving and Object-Oriented Programming
Chapter 2 - Introduction to Java Applications
Java I.
MSIS 655 Advanced Business Applications Programming
Chapter 2 - Introduction to Java Applications
AP Java 10/4/2016.
Chapter 3 – Introduction to C# Programming
Message, Input, and Confirm Dialogs
CS431 ws99 Half Text Half Graphics
Chapter 2 - Introduction to Java Applications
JOptionPane class.
F II 2. Simple Java Programs Objectives
Chapter 2: Java Fundamentals cont’d
Presentation transcript:

1/23: Java Modular Components Identifiers: naming requirements for Java variables & objects Stepping out of the MS-DOS window: The Java Modular Component: the JOptionPane.

Identifiers: How to Name. Must start with a lowercase non-number –but classes must start with a capitalized non-number Can contain alphas (letters), numbers, underscores, dollar signs –acceptable: $dinero value$2 g my_debt Cannot contain other symbols or spaces –unacceptable: a*b Value2 2nd my Cannot be a Java keyword –EX: static void class private import

Outside the MS-DOS Window Most programs today work in a “Windows”-type environment, not a MS-DOS window. Dialog boxes: informational, request input, show output, give warnings, etc. In Java, we use the JOptionPane.

Welcome4.java // Fig. 2.6: Welcome4.java (pg. 66) //Java extension packages – import JOptionPane import javax.swing.JOptionPane; public class Welcome4 { //main method begins execution of app public static void main ( String args[] ) { JOptionPane.showMessageDialog ( null, “Welcome\nto\nJava\nProgramming!” ); System.exit ( 0 ); } comments import statement class header method header statement

JOptionPane: A Dialog Box must import javax.swing.JOptionPane before defining the class. –a library of objects & methods for dialog boxes Usage: a statement like this: JOptionPane.showMessageDialog( null,“Words” ); to get

JOptionPane: Variations The third parameter varies the title bar string: JOptionPane.showMessageDialog ( null, “Words”, “Title Here”, JOptionPane.INFORMATION_MESSAGE) –Replaces the Message header with Title Here. More info available at Title Here

JOptionPane: Variations The last parameter varies the icon shown in the box: JOptionPane.showMessageDialog( null,“Word”,“Title”, … JOptionPane.PLAIN_MESSAGE –JOptionPane.ERROR_MESSAGE –JOptionPane.INFORMATION_MESSAGE –JOptionPane.WARNING_MESSAGE –JOptionPane.QUESTION_MESSAGE More info available at

JOptionPane.showInputDialog A dialog box that allows the user to input a String. EX: JOptionPane.showInputDialog ( “Please type your name” ); Learn more at

Program of the Day: pg. 69 Pg. 69: Addition.java –Pay attention to the use of the dialog boxes. Friday: –Finish Addition.java –Getting comfortable with Dialog Boxes Monday: –Addition.java in depth –Getting values from the user –Strings vs. integers and other primitive data types –Arithmetic operators