1 / 9

Applications in Java 1.2

Applications in Java 1.2. Half Text Half Graphics. 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.

tilly
Télécharger la présentation

Applications in Java 1.2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Applications in Java 1.2 Half Text Half Graphics CS423 (cotter)

  2. 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. CS423 (cotter)

  3. 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 CS423 (cotter)

  4. 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:" ); CS423 (cotter)

  5. 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 ); } } CS423 (cotter)

  6. Product Output(s) CS423 (cotter)

  7. 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. CS423 (cotter)

  8. OptionType • DEFAULT_OPTION • YES_NO_OPTION • YES_NO_CANCEL_OPTION • OK_CANCEL_OPTION CS423 (cotter)

  9. messageType • ERROR_MESSAGE • INFORMATION_MESSAGE • WARNING_MESSAGE • QUESTION_MESSAGE • PLAIN_MESSAGE CS423 (cotter)

More Related