Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS431 ws99 Half Text Half Graphics

Similar presentations


Presentation on theme: "CS431 ws99 Half Text Half Graphics"— Presentation transcript:

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

2 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>

3 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>

4 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>

5 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>

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

7 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>

8 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>

9 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>


Download ppt "CS431 ws99 Half Text Half Graphics"

Similar presentations


Ads by Google