Professor Kit Romano's Web Site

 



Site Index

About Me

Welcome
Definition of Program
Variable Types
Understanding Memory
Declaring Variables
Simple Commands
Concatenation and Strings
Sleep-Threads-Try Catch
Campus Scenes
Pictures
Java simplified
Application Shell Styles
Reading Data From File
Overview of Applets
Excellent Graphics Applet
Online Reference
Nested if statements
Arrays
Sorting Arrays
Using Strings
Functions
Top 20 Replies 
First program 211
Important Class Example
JAVA in SDK Environment
Understanding OOP
OOP simple example
Recursion example
Example of Inheritance
     and use of JTextArea



*** Web Related **********
Build Student Web Page ?
What is FTP
Download WS ftp95
Download Java Plug In
Applets from jbuilder to sdk
Practice Problems

 

Programming Examples

 

 

                                                

 

Program 1-6

// simple program that allows entry of a score (string)
// and then displays the score
// Demonstrates 2 JOptionPane methods showInputDialog and showMessageDialog
// This application builds a frame object and draws a circle prior to data entry
// This program does not use a loop but one could be added easily
// Accept the import as they are for now.
// This is a start of showing you i/o in a frame using the JOptionPane methods
// provided in the swing class

import java.awt.*;
import java.net.*;
import java.awt.event.*;
import javax.swing.*;

public class Application1
{
   public Application1()
    {
     Frame df = new Frame("application frame");
     df.setSize(400,300);
     df.show();
     Graphics g = df.getGraphics() ;
     g.drawOval(100,100,100,100);

   
  // notice that score is string ??? what about arithmetic ???

     String score=JOptionPane.showInputDialog("enter score ");
     JOptionPane.showMessageDialog(null,score,"output
           result",JOptionPane.NO_OPTION);
   }
    public static void main(String[] args)
       {
         Application1 app=new Application1();
        System.exit(0);
       }
}