======================================= Java - ExamplesJ/ TABLE OF CONTENTS Sep. 8, 2017 ======================================= This directory contains a collection of programs and writeups that will be of interest (and aid) to students studying Java and Java programming. 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/ FLAG DESCRIPTION ------------------- ---- --------------------------------------------------------------- 00INDEX.txt - This file Abs.java C Demonstrate use of an abstract class and inheritance AbsClsVsIfx.rtf - The difference between an abstract class and an interface AbsExt.java C Extending an abstract class; one containing concrete methods AddEmUp/ C Designing for command-line and GUI use; MVC ADTList/ D Implementations of ADT List and ADT ArrayList ADTQueue/ D Implementation of ADT Queue ADTStack/ D Implementations of ADT Stack and ADT ArrayStack AnimalTalk/ C Building and using several objects; Help for F3 AnimationDemo/ D Animation using sprites, threads, gif files AnimatorApplet/ J Template showing how to do simple animation AppletComm/ - How an applet can communicate with other running applets ArrayExample/ C Using an array; using Math.random; using printf() ArrayListDemo.java C Demonstrate ArrayList methods AssignmentZero.java - Java source for Homework Assignment Zero for all Java courses Async.java - Responding to events using asynchronous (threaded) semantics AudioItem/ C Playing sound in Java 1.1 & Java 2; .AU and .WAV clips; Adapters AUSounds/ - A collection of sound clips in .AU format Authors/ C How to "half-simulate" a dialog in an applet AutoBoxing.java C Demonstrate automatic boxing and unboxing of primitives/wrappers AutoPolygons/ C Demonstrate creating polygons, Random, timer, animation, resizing Average/ C How to use Scanner's nextDouble to read data; Help for F3 BankData.txt J Data for CIS 144 homework assignment J6 Batch/ C How to run a Batch script from Java Beep.java C How to play the PC's 'beep' sound BinarySearch.java - The Binary Search algorithm in Java BinSrchFlwchrt.ppt C Binary Search Structured Flowchart: in both C/C++ and Java Black/ C Show how to display a full-sceen black window using AWT BlowStack/ C Demonstrate 'blowing the stack' - applet and application ButtonPos.java C How to position and size a button using absolute coordinates Calc.zip D Bary's solution for CSCI ??? homework assignment D2 - Calculator Callback/ C Simple callback; demo how access/information is passed CenterDesktop.java C Initially display a JFrame at the center of the Windows desktop clean.bat - A Windows (DOS) "batch file" used by the makefile ClientServer/ J Client/Server using sockets Clock/ - (Digital) Clock thread example Clock2/ - (Analog) Clock thread example Clock3/ - (Analog) Clock thread example; run as application or applet CMBubble/ - Drawing using an off-screen buffer; createImage Cmplx/ - Complex numbers example CnP.java D Combinations and Permutations (recursively) CodeConv/ C Coding Conventions (style); most recent version (view-ready HTML) CodeConventions.pdf - Coding Conventions (style); most recent version (in PDF format) CodeConventions2.pdf - iCarnegie's 2-page quick summary of the Sun Java Coding Conventions Coding.pdf - Coding Conventions (style); an older opinion (in PDF format) Colors/ C How to use predefined and user-defined colors Colors.java C Using JButtons, inner classes, Enter key, Java named colors CompileJava/ - A Java application that compiles Java programs Components/ - Applet illustrating how to use various Components CompoundSort.java C Compound sort - sorting on both a primary and secondary field ConsoleIO/ - Show how to read data from the keyboard; also from a file (obs.) CountDown.java C How to use sleep() and beep() CountFlips/ C Simple programmer-defined class CycleThru.java C Demonstrate Enumeration and Iteration DemoHeirarchy.java C Demonstrate inheritance, upcasting, downcasting, abstract class Direction/ C Demonstrate how to listen for the cursor keys DirSize.java - How to find the size of a directory tree in bytes DitherTest/ D How to use the image buffering routines for fast screen updates DnD.java C Drag and Drop Between a TextField and a TextArea DocumentModalDialog.java D Modal Dialogs in Swing Doodle/ C Doodle example from L&L; using MouseMotion and MouseListener DoodleIC/ C Doodle example from L&L; using inner classes DoodleIC2/ C Doodle example from L&L; showing Canvas, Panels, Layout Managers Dots/ C Demonstrate setting up listeners and a "callback" handle DoubleBuffering/ C Using double-buffering to avoid flicker Dual/ C Running the same program both as an applet and an application DualModal.java D Modal and non-modal dialogs in Swing Enum/ C Show how to use enum (enumerated types) Except.java C Demonstrate Exceptions and Exception Handling Execute.java - How to execute an operating system command Execute2.java - How to execute an operating system command (> Java 1.5) ExeJar/ - How to create an "executable JAR file" ExtendImplement.rtf C Extending classes, implementing interfaces, abstract classes ExtendInnerClass.java - How to extend an inner class Fibonacci.java - Traditional and memorized recursive Fibonacci calculations Figure4/ - Show how to draw simple shapes and control color; also show time FileCopy/ C Show how to read/write flat ASCII files, one line at a time (Scanner) FileIO/ - How to read/write from files; how to use StreamTokenizer FileNIO.java - How to read/write from files using the nio api Fireworks/ - Fireworks - use of threads for animation FishPlus/ C Helpful hint for Skyline - Homework Assignment F2 FormatNumbers.java C How to format numbers for output GifImages/ C Displaying GIF images on a Canvas Grids/ - Setting up a visual layout; layout managers & absolute positioning GridLayoutDemo.java C Demonstrate using GridLayout HelloWorld.java - Java source for Homework Assignment Zero (application) HelloJavaWorld/ C Java source for Homework Assignment Zero (applet) HT.java C Show how to use a Hashtable (and Enumeration) ImportStatic/ - Show use of import static and packages Interf/ - A tiny example showing how to set up and use interfaces JBlack/ C Show how to display a full-sceen black window using Swing JButtonDemo/ C A tiny Swing example - applet & application - like TwoButtons/Dual JColorChooserDemo.java C Using the Java Color Chooser dialog JComboBoxDemo/ C Swing application showing JComboBox and anonymous inner class JFontSlider.java - Swing application showing use of a Slider to control font size JLabelArray/ C Swing applet showing an array of JLabels JLists.java C Singly-linked, simple, forward-directed Lists application JMenusDemo/ C A tiny Swing example showing how to set up Menus Jotpad.zip C Bary's solution for CSCI 211 homework assignment F7 - Jotpad JTableDemo/ D Create and fill a JTable using MySQL JTextFieldDemo/ C A tiny Swing example showing how to set up a JTextField JukeBox/ C Using a Swing Combo Box; playing sounds in Swing KeywordOrder.htm C Preferred order of appearance of Java keywords (reserved words) KochSnowflake/ C Swing applet demonstrating recursion LayoutDemos/ C How to use the layout managers LeftRightMouse/ C How to detect the left, middle, right mouse button LifeData.txt D Data for CSCI ??? homework assignment D3 MakeDirectory.java - How to create a directory (folder) makefile - A "makefile" for compiling and running Java programs Marquee/ - A "marquee" applet using threads based on ScrollText MasterSlave/ C Demo "master-slave" relationship (help for Blobs) MatMult.java C Demonstrate 2-D arrays and matrix multiplication MaxThreads/ - Multiple threads and synchronization example using a mutex MazeSearch/ C Demonstrate recursion and how to search a simple maze MenusDemo/ C How to set up menus and dialogs using AWT, including FileDialog MinThreads/ - Multiple threads and critical section example Moire/ - Graphics - Moire pattern - and threads MostDivisors.java - Find integer with the most divisors MouseFollow.java C How to follow the mouse; change the cursor MouseMove.java - How to move the mouse under "Robot" control MyApps/ C AWT & Swing versions of RealJ's default (simple GUI) application MyApps/MyApp.java C Anonymous inner class for windowClosing Newline.java - How to handle end-of-line (newline) environment independently (LS line-separator) Newton.java - Show Newton's Method for solving y = f(x) = 0; using doubles OuterClass.java - Passing handles to inner and outer classes PackageDemo/ - How to declare and use your own Packages Palindromic.java J Main class for CSCI 311 homework assignment J2 Parameters.java - How to extract parameters from an Applet's HTML Perms.java C A highly recursive way to print the permutations of a string Picture/ C How to rotate and display a picture (.jpg) PlayASound/ C How to play sounds and use radio buttons Plot.java - How to plot data as points PlotLines.java - Expansion of the Plot.java example, using lines and a timer PlowDataFINAL.txt D Data for CSCI ??? homework assignment L5 Poly.zip D Bary's solution for CSCI ??? homework assignment D1 - Poly PolyData.txt D Data for CSCI ??? homework assignment D1 PolyMain.java D Main program / driver for CSCI ??? assignment D1 Polys/ C Demonstrate polylines, polygons and animation in time PPGame/ D PingPong Game - thread synchronization using wait and notifyAll PressMe/ C A simple GUI showing a button and a color panel Primes/ C Calculating prime numbers; number theory; residue sieve Print.java - How to print to a printer rather than draw on a canvas ProducerConsumerSync/ J Synchronized Producer-Consumer example Property.java - Show what's in the System's "properties" PWriter.java C How to create and write a file using a PrintWriter QueueClass/ - A Queue class, since Java doesn't have one Quotes/ C Swing push buttons, radio buttons and check boxes RailData.txt J Data for CSCI 311 homework assignment J3 RandomRange.java C How to calculate a random int in a given range RanPolygons/ C Random Polygons in random colors; using Random and random() RealPolymorphism.rtf - Is polymorphism used in the "real world?" Rebound/ C How to do simple timer-based animation Rebound2/ C Extension of Rebound for two animated images Redir/ C How to redirect stdin and stdout for input/output Redirect2/ Another stdin/stdout/stderr redirection example Redirection.rtf - Using Redirection; capturing output (Java/C++) RobotDemo/ - Driving the JVM -- move the cursor/mouse, etc. RSAData.txt D Data for CSCI ??? homework assignment D2 RubberLines/ C How to "rubberband" w/wo inner classes Scale/ - How to scale (resize) a GIF or JPG image ScanConsoleApp.java C Demonstrate use of the Scanner Class ScreenSize.java - Determine current screen size in pixels ScrollText/ - Scrolling text thread application ScrollingHelloWorld/ - Scrolling text thread/notify applet SendMail.java - Tiny SMTP send EMail application Serialize.java - Demonstrate serialization and deserialization ShowLabels/ C Using Swing JLabel and image icons SimpleApGraphics - The simplest application with graphics SimpleApplet/ C The all-time simplest possible Applet SimpleJApplet/ C The all-time simplest possible JApplet SimpleJApplet2/ C The all-time simplest possible JApplet; uses contentpane SimpleSounds/ C A simple sound-playing applet SimpleThread/ - A simple multiple free-running thread example Sine/ - Animation of the trigonometric sine function (using threads) SingleListenerHandler/ F Using a single Listener and Handler for a bunch of Buttons Singleton.java - How to create a Singleton object SlideShow/ C Applet for a "slide show," also shows how to run a Jar applet SlideShowJS/ - JavaScript slide shows (w/wo fading between images) Sockets/ - Using sockets for Client-Server Internet communications Sorts.java C Selection sort and insertion sort examples SoundApplet/ - Sun's SoundApplet tutorial example, modified slightly SoupTest/ D Producer and Consumer Threads example; wait and notify SplashTest/ C Show how to set up and use a "splash screen" SplashWindow3/ C Earlier technique for setting up and using a "splash screen" StackQueue.java - Show how to use a Java Stack StandardMenus.java C Setting up standard menus, shortcut keys (accelerator keys) SubMenusDemo/ C How to set up sub-menus; how to set up a key listener SwingVsAWT.rtf C The architectural differences between Swing and AWT TableDemo.java D Filling a JFrame in Swing TableSortDemo.java D Sorting columns in a JFrame TextClock.java C Creates a digital clock; uses anonymous class and Timer TicTacToe/ J Source code and other files for CSCI 311 homework assignment J4 TimeAnimation.java C Demonstrate "time animation" using sleep() - for TwoSorts TimeAnimationT.java C Demonstrate "time animation" using a Timer - for TwoSorts TimepieceTaxonomy/ - A taxonomy of "timepieces" -- like watches & clocks... Towers.java - A solution to the "Tower of Hanoi" puzzle TreeData.txt D Data for CSCI ??? homework assignment D4 Treemap.java C Show how to use a TreeMap TreeOfDoubles.java - Show how to use the Java 2 TreeSet Collection Triangles/ C Animation in time using triangles, polygons, timer TwoButtons/ C A tiny applet showing two buttons, inner classes TwoDArrays.java/ C Using 2D arrays - rectangular and triangular TwoPolygons/ C Show the two ways to create Polygons; draw a PolyLine TwoScreens.java D How to "ping-pong" between two screens, passing data TxtArea/ C How to use a TextArea, Menus, Accelerator Keys UniversalDemo.java C Creating a universally accessible method UseAVector.java/ C Show how to use a Vector UsingRealJ.pdf C How to use the RealJ Integrated Development Environment V2A/ C How to copy information from a Vector to a pair of arrays VarArgsArrayExample.java C Using a variable length parameter list with 2D arrays VarArgsInts.java C Using a variable length parameter list with ints VarArgsOverloads.java C Using overloads with a variable length parameter list VMSpec2ed.zip - Java Virtual Machine Specification 2nd Edition in HTML WhatClass.java J Find what class called your method WhoAmI.java J Get a computer's current IP address ZipIO/ J How to use Zip compression/decompression during file I/O Notes: "/" indicates a subdirectory containing several files L&L = Lewis & Loftus, 'Java Software Solutions' textbook - o - O - o - File: http://Snow.SierraNevada.edu/~csci/ExamplesJ/00INDEX.txt Mirror: http://www.csci-snc.com/ExamplesJ/00INDEX.txt 12:24 PM 3/12/2017