1 / 4

CS201 Introduction to Java Programming I/O Using JOptionPane

CS201 Introduction to Java Programming I/O Using JOptionPane. Chengyu Sun California State University, Los Angeles. JOptionPane. Input and output using a Dialog box. JOptionPane.showInputDialog( some_string ); JOptionPane.showMessageDialog( null , some_string );. Input Example.

portis
Download Presentation

CS201 Introduction to Java Programming I/O Using JOptionPane

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. CS201 Introduction to Java ProgrammingI/O Using JOptionPane Chengyu Sun California State University, Los Angeles

  2. JOptionPane • Input and output using a Dialog box JOptionPane.showInputDialog( some_string ); JOptionPane.showMessageDialog( null, some_string );

  3. Input Example import javax.swing.JOptionPane; public class InputExp { public static void main( String args[] ) { int a; double b; String sa; // error! showInputDialog returns a String type a = JOptionPane.showInputDialog( “Please input a integer:” ); sa = JOptionPane.showInputDialog( “Please input a integer:” ); a = Integer.parseInt( sa ); sa = JOptionPane.showInputDialog( “Please input a real number:” ); b = Double.parseDouble( sa ); System.exit(0); } } // end of InputExp

  4. Output Example JOptionPane.showMessageDialog( null, “The integer is ” + a + “\nThe real number is ” + b );

More Related