Java - ExamplesJ/ -
TABLE OF CONTENTS
Dec. 24,
2020
This directory contains a collection of programs and writeups that will be of interest (and aid) to students studying Java and Java programming.
KEY:
Files of particular interest to:
'C' students
taking CSCI 211 - Programming Language Concepts
'J'
students taking CSCI 311 - Java Programming
'D' students
taking CSCI ??? - Data Structures & Algorithms
'-'
students in general
FILE or DIRECTORY/ |
KEY |
DESCRIPTION |
- |
This file |
|
C |
Demonstrate use of an abstract class and inheritance |
|
- |
The difference between an abstract class and an interface |
|
C |
Extending an abstract class, one containing concrete methods |
|
C |
Designing for command-line and GUI use; MVC |
|
D |
Implementations of ADT List and ADT ArrayList |
|
D |
Implementation of ADT Queue |
|
D |
Implementations of ADTStack and ADT ArrayStack |
|
D |
Animation using sprites, threads, gif files |
|
J |
Template showing how to do simple animation |
|
- |
How an applet can communicate with other running applets |
|
C |
Using an array; using Math.random; using printf() |
|
C |
Demonstrate ArrayList methods |
|
- |
Java source for Homework Assignment Zero for all Java courses |
|
- |
Responding to events using asynchronous (threaded) semantics |
|
C |
Playing sound in Java1.1 & Java 2, .AU and .WAV clips, Adapters |
|
- |
A collection of sound clips in .AU format |
|
C |
How to "half-simulate" a dialog in an applet |
|
C |
Demonstrate automatic boxing and unboxing of primitives/wrappers |
|
C |
Demonstrate creating polygons, Random, timer, animation, resizing |
|
J |
Data for CSCI 311 homework assignment J6 |
|
C |
How to run a Batch script from Java |
|
C |
How to play the PC's 'beep' sound |
|
- |
The Binary Search algorithm in Java |
|
C |
Binary Search Structured Flowchart: in both C/C++ and Java |
|
C |
Show how to display a full-screen black window using AWT |
|
C |
Demonstrate 'blowing the stack' -, applet and application |
|
C |
How to position and size a button using absolute coordinates |
|
C |
Simple callback; demo how access/information is passed |
|
D |
Bary's solution for CSCI??? homework assignment D2 -, Calculator |
|
C |
Initially display a JFrame at the center of the Windows desktop |
|
- |
A Windows (DOS) "batch file" used by the makefile |
|
J |
Client/Server using sockets |
|
- |
(Digital) Clock thread example |
|
- |
(Analog) Clock thread example |
|
- |
(Analog) Clock thread example, run as application or applet |
|
- |
Drawing using an off-screen buffer; createImage |
|
- |
Complex numbers example |
|
C |
Coding Conventions (style), most recent version (view-ready HTML) |
|
- |
Coding Conventions (style), most recent version (in PDF format) |
|
- |
iCarnegie's 2-page quick summary of the Sun Java Coding Conventions |
|
- |
Coding Conventions (style), an older opinion (in PDF format) |
|
C |
How to use predefined and user-defined colors |
|
C |
Using JButtons, inner classes, Enter key, Java named colors |
|
- |
A Java application that compiles Java programs |
|
- |
Applet illustrating how to use various Components |
|
C |
Compound sort - sorting on both a primary and secondary field |
|
- |
Show how to read data from the keyboard, also from a file |
|
C |
How to use sleep() and beep() |
|
C |
Simple programmer-defined class |
|
C |
Demonstrate Enumeration and Iteration |
|
C |
Demonstrate inheritance, upcasting, downcasting, abstract class |
|
C |
Demonstrate how to listen for the cursor keys |
|
D |
How to use the image buffering routines for fast screen updates |
|
C |
Drag and Drop Between a TextField and a TextArea |
|
D |
Modal Dialogs in Swing |
|
C |
Doodle example from L&L, using MouseMotion and MouseListener |
|
C |
Doodle example from L&L, using inner classes |
|
C |
Doodle example from L&L, showing Canvas, Panels, Layout Managers |
|
C |
Demonstrate how to set up and use a "callback" handle |
|
C |
Using double-buffering to avoid flicker |
|
C |
Running the same program both as an applet and an application |
|
D |
Modal and non-modal dialogs in Swing |
|
C |
Show how to use enum (enumerated types) |
|
C |
Demonstrate Exceptions and Exception Handling |
|
- |
How to execute an operating system command |
|
- |
How to execute an operating system command (> Java 1.5) |
|
- |
How to create an "executable JAR file" |
|
C |
Extending classes, implementing interfaces, abstract classes |
|
- |
How to extend an inner class |
|
- |
Traditional and memorized recursive Fibonacci calculations |
|
- |
Show how to draw simple shapes and control color, also show time |
|
C |
Show how to read/write flat ASCII files, one line at a time (Scanner) |
|
- |
How to read/write from files, how to use StreamTokenizer |
|
- |
How to read/write from files using the nio api |
|
- |
Fireworks - use of threads for animation |
|
C |
Helpful hint for Skyline - Homework Assignment F2 |
|
C |
How to format numbers for output |
|
C |
Displaying GIF images on a Canvas |
|
- |
Setting up a visual layout, layout managers & absolute positioning |
|
C |
Demonstrate using GridLayout |
|
C |
Java source for Homework Assignment Zero (application) |
|
C |
Java source for Homework Assignment Zero (applet) |
|
C |
Show how to use a Hashtable (and Enumeration) |
|
- |
Show use of import static and packages |
|
- |
A tiny example showing how to set up and use interfaces |
|
C |
Show how to display a full-screen black window using Swing |
|
C |
A tiny Swing example - applet & application - like TwoButtons/Dual |
|
C |
Using the Java Color Chooser dialog |
|
C |
Swing application showing JComboBox and anonymous inner class |
|
- |
Swing application showing use of a Slider to control font size |
|
C |
Swing applet showing an array of JLabels |
|
C |
Singly-linked, simple, forward-directed Lists application |
|
C |
A tiny Swing example showing how to set up Menus |
|
C |
Bary's solution for CSCI211 homework assignment F7, Jotpad |
|
D |
Create and fill a JTable using MySQL |
|
C |
A tiny Swing example showing how to set up a JTextField |
|
C |
Using a Swing Combo Box, playing sounds in Swing |
|
C |
Preferred order of appearance of Java keywords (reserved words) |
|
C |
Swing applet demonstrating recursion |
|
C |
How to use the layout managers |
|
C |
How to detect the left, middle, right mouse button |
|
D |
Data for CSCI ???homework assignment D3 |
|
- |
How to create a directory (folder) |
|
- |
A "makefile" for compiling and running Java programs |
|
- |
A "marquee" applet using threads based on ScrollText |
|
C |
Demo "master-slave" relationship (help for Blobs) |
|
C |
Demonstrate 2-D arrays and matrix multiplication |
|
- |
Multiple threads and synchronization example using a mutex |
|
C |
Demonstrate recursion and how to search a simple maze |
|
C |
How to set up menus and dialogs using AWT, including FileDialog |
|
- |
Multiple threads and critical section example |
|
- |
Graphics - Moire pattern - and threads |
|
- |
Find integer with most divisors |
|
C |
How to follow the mouse, change the cursor |
|
- |
How to move the mouse under "Robot" control |
|
C |
AWT & Swing versions of RealJ's default (simple GUI) application |
|
C |
Anonymous inner class for windowClosing |
|
- |
How to handle end-of-line (newline) environment independently (LS) |
|
- |
Passing handles to inner and outer classes |
|
- |
How to declare and use your own Packages |
|
J |
Main class for CSCI 311 homework assignment J2 |
|
- |
How to extract parameters from an Applet's HTML |
|
C |
A highly recursive way to print the permutations of a string |
|
C |
How to rotate and display a picture (.jpg) |
|
C |
How to play sounds and use radio buttons |
|
- |
How to plot data as points |
|
- |
Expansion of the Plot.java example, using lines and a timer |
|
D |
Data for CSCI ??? homework assignment L5 |
|
D |
Bary's solution for CSCI??? homework assignment D1, Poly |
|
D |
Data for CSCI ??? homework assignment D1 |
|
D |
Main program /driver for CSCI ??? assignment D1 |
|
C |
Demonstrate polylines, polygons and animation in time |
|
D |
Ping-Pong Game - thread synchronization using wait and notifyAll |
|
C |
A simple GUI showing a button and a color panel |
|
C |
Calculating prime numbers; number theory; residue sieve |
|
J |
Synchronized Producer-Consumer example |
|
- |
Show what's in the System's "properties" |
|
C |
How to create and write a file using a PrintWriter |
|
- |
A Queue class, since Java doesn't have one |
|
C |
Swing push buttons, radio buttons and check boxes |
|
J |
Data for CSCI 311 homework assignment J3 |
|
C |
How to calculate a random int in a given range |
|
C |
Random Polygons in random colors; using Random and random() |
|
- |
Is polymorphism used in the "real world?" |
|
C |
How to do simple timer-based animation |
|
C |
Extension of Rebound for two animated images |
|
C |
How to redirect stdin and stdout for input/output |
|
- |
Another stdin/stdout/stderr redirection example |
|
- |
Using Redirection, capturing output (Java/C++) |
|
C |
Driving the JVM -- move the cursor/mouse, etc. |
|
D |
Data for CSCI ??? homework assignment D2 |
|
C |
How to "rubberband," both w/wo inner classes |
|
- |
How to scale (resize) a GIF or JPG image |
|
C |
Demonstrate how to use the Scanner Class |
|
- |
Determine current screen size in pixels |
|
- |
Scrolling text thread application |
|
- |
Scrolling text thread/notify applet |
|
- |
Tiny SMTP send Email application |
|
- |
Demonstrate serialization and deserialization |
|
C |
Using Swing JLabel and image icons |
|
- |
The simplest application with graphics |
|
C |
The all-time simplest possible Applet |
|
C |
The all-time simplest possible JApplet |
|
C |
The all-time simplest possible JApplet; uses ContentPane |
|
C |
A simple sound-playing applet |
|
- |
A simple multiple free-running thread example |
|
- |
Animation of the trigonometric sine function (using threads) |
|
F |
Using a single Listener and Handler for a bunch of Buttons |
|
- |
How to create a Singleton object |
|
C |
Applet for a "slide show," also shows how to run a Jar applet |
|
- |
JavaScript slide shows (w/wo fading between images) |
|
- |
Using sockets for Client-Server Internet communications |
|
C |
Selection sort and insertion sort examples |
|
- |
Sun's SoundApplet tutorial example, modified slightly |
|
D |
Producer and Consumer Threads example, wait and notify |
|
C |
Show how to set up and use a "splash screen" |
|
C |
Earlier technique for setting up and using a "splash screen" |
|
- |
Show how to use a Java Stack |
|
C |
Setting up standard menus, shortcut keys (accelerator keys) |
|
- |
Yields filename sans extension/suffix |
|
C |
How to set up sub-menus, how to set up a key listener |
|
C |
The architectural differences between Swing and AWT |
|
D |
Filling a JFrame in Swing |
|
D |
Sorting columns in a JFrame |
|
C |
Creates a digital clock; uses anonymous class and Timer |
|
J |
Source code and other files for CSCI 311 homework assignment J4 |
|
C |
Example of 'time animation' using sleep() - Help for HW #6 - Sorts |
|
C |
Example of 'time animation' a Timer - Help for HW #6 - Sorts |
|
- |
A taxonomy of "timepieces" -- like watches & clocks... |
|
- |
A solution to the "Towers of Hanoi" puzzle |
|
D |
Data for CSCI ??? homework assignment D4 |
|
C |
Show how to use a TreeMap |
|
- |
Show how to use the Java 2 TreeSet Collection |
|
C |
Animation in time using triangles, polygons, timer |
|
C |
A tiny applet showing two buttons, inner classes |
|
C |
Using 2D arrays, rectangular and triangular |
|
C |
Show the two ways to create Polygons; draw a PolyLine |
|
D |
How to "ping-pong" between two screens, passing data |
|
C |
How to use a TextArea, Menus, Accelerator Keys |
|
C |
Creating a universally accessible method |
|
C |
Show how to use a Vector |
|
C |
How to use the RealJ Integrated Development Environment |
|
C |
How to copy information from a Vector to a pair of arrays |
|
C |
Using a variable length parameter list with 2D arrays |
|
C |
Using a variable length parameter list with ints |
|
C |
Using overloads with a variable length parameter list |
|
- |
Java Virtual Machine Specification, 2nd Edition, in HTML format |
|
J |
Find what class called your method |
|
J |
Get a computer's current IP address |
Notes: "/" indicates
a subdirectory containing several files
L&L =
Lewis & Loftus, 'Java Software Solutions' textbook
File:
http://Snow.SierraNevada.edu/~csci/ExamplesJ/index.html
Mirror: http://www.csci-snc.com/ExamplesJ/index.html
Last updated: Dec. 24,2020 – 15:00