^^^^^^^^^^^^^^^^^ TiledImages.java Demonstrates using a TexturePaint to fill an shape with a tiled image. Uses the following class and images: * ImageUtilities.java Simplifies creating a BufferedImage from an image file. ~~~~~~~~~~~~~~~~~~ import javax.swing.*; import java.awt.*; import java.awt.geom.*; import java.awt.image.*; /** An example of using TexturePaint to fill objects with tiled * images. Uses the getBufferedImage …
Category: FromSitesTree.com
May 03
Example Java Programs #Programming Code Examples #Java/J2EE/J2ME #J2SE
Very Simple Java Example Programs HelloWorld.java public class HelloWorld { // method main(): ALWAYS the APPLICATION entry point public static void main (String[] args) { System.out.println ("Hello World!"); } } // Print Today’s Date import java.util.*; public class HelloDate { public static void main (String[] args) { System.out.println ("Hello, it’s: "); System.out.println(new Date()); } } …
May 03
DOM example that represents the basic structure of an XML document as a JTree #Programming Code Examples #Java/J2EE/J2ME #JavaScript
//XMLTree.java //Uses the following files Uses the following files: * XMLFrame.java:Swing application to select an XML document and display in a JTree. ExtensionFileFilter.java Allows you to specify which file extensions will be displayed in a JFileChooser. test.xml Default file loaded if none selected by user. perennials.xml and perennials.dtd Data on daylilies and corresponding DTD. WindowUtilities.java …
May 03
# StoppableThread.java A template to place a thread in a RUN, WAIT, or STOP state. #Programming Code Examples #Java/J2EE/J2ME #Java Threads
/** A template to control the state of a thread through setting * an internal flag. public class StoppableThread extends Thread { public static final int STOP = 0; public static final int RUN = 1; public static final int WAIT = 2; private int state = RUN; /** Public method to permit setting a …
May 03
Multithreaded Graphics and Double Buffering #Programming Code Examples #Java/J2EE/J2ME #Java Threads
ShipSimulation.java Illustrates the basic approach of multithreaded graphics whereas a thread adjusts parameters affecting the appearance of the graphics and then calls repaint to schedule an update of the display. import java.applet.Applet; import java.awt.*; public class ShipSimulation extends Applet implements Runnable { … public void run() { Ship s; for(int i=0; i<ships .length; i++) { …
May 03
LinkedList and Iterators in Java #Programming Code Examples #Java/J2EE/J2ME #J2SE
/* * LinkedList.java * * Created on January 10, 2008, 8:51 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package linkedlist; import java.util.List; import java.util.LinkedList; import java.util.Iterator; import java.util.ListIterator; import java.util.Collections; import java.util.Random; /** * * @author Sayed */ public class LinkedListTest …
May 03
QueryViewer.java: An interactive database query viewer #Programming Code Examples #Java/J2EE/J2ME #JDBC
# QueryViewer.java An interactive database query viewer. Connects to the specified Oracle or Sybase database, executes a query, and presents the results in a JTable. Uses the following file: * DBResultsTableModel.java Simple class that tells a JTable how to extract relevant data from a DBResults object (which is used to store the results from a …
May 03
extract relevant data from a DBResults #Programming Code Examples #Java/J2EE/J2ME #JDBC
package cwp; import javax.swing.table.*; /** Simple class that tells a JTable how to extract * relevant data from a DBResults object (which is * used to store the results from a database query). */ public class DBResultsTableModel extends AbstractTableModel { private DBResults results; public DBResultsTableModel(DBResults results) { this.results = results; } public int getRowCount() { …
May 03
PreparedStatements.java An example to test the timing differences resulting from repeated raw queries vs. repeated calls #Programming Code Examples #Java/J2EE/J2ME #JDBC
package cwp; import java.sql.*; /** An example to test the timing differences resulting * from repeated raw queries vs. repeated calls to * prepared statements. These results will vary dramatically * among database servers and drivers. With my setup * and drivers, Oracle prepared statements took only half * the time that raw queries required …
May 03
EmployeeCreation.java: Make a simple "employees" table using the database utilities #Programming Code Examples #Java/J2EE/J2ME #JDBC
package cwp; import java.sql.*; /** Make a simple "employees" table using DatabaseUtilities. */ public class EmployeeCreation { public static Connection createEmployees(String driver, String url, String username, String password, boolean close) { String format = "(id int, firstname varchar(32), lastname varchar(32), " + "language varchar(16), salary float)"; String[] employees = {"(1, ‘Wye’, ‘Tukay’, ‘COBOL’, 42500)", "(2, …
