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

 

 

                                                

import java.awt.*; 
import javax.swing.*; 
public class Applet14 extends JApplet
{
Thread t = new Thread();
int a;
int tot;
float piggy = 3.98f;
String cat = "TOTAL IS ";

String bubba = JOptionPane.showInputDialog("ENTER NUMBER ?");
int horse = Integer.parseInt(bubba); //Convert bubba to an int

public void paint(Graphics g)
{
Font turkey = new Font("Arial",Font.BOLD,24); //declare new font

g.setFont(turkey); //set font

g.setColor(Color.yellow); //Background 
g.fillRect(1,1,500,500);

g.setColor(Color.red); //Draw textbox
g.fillRect(65,165,300,50);

g.setColor(Color.blue); //Font color

for(a=1;a<=horse;a++) //loop from 1 to the number input

tot = tot + a; //add up the numbers from 1 to
} //the number that was input

cat = cat + tot; //Example of concatenate

g.drawString(cat,100,200); //Draw string (String,x-pos,y-pos)
}

}