Category: FromSitesTree.com

Driver class that creates three threaded objects (Counter2) that count from 0 to 4. #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing

/** Try out a few instances of the Counter2 class. public class Counter2Test { public static void main(String[] args) { Counter2 c1 = new Counter2(5); Counter2 c2 = new Counter2(5); Counter2 c3 = new Counter2(5); } } /** A Runnable that counts up to a specified * limit with random pauses in between each count. …

Continue reading

Template illustrating the first approach for creating a class with thread behavior. #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing

/** Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * © 2001 Marty Hall and Larry Brown; * may be freely used or adapted. */ public class ThreadClass extends Thread { public void run() { // Thread behavior here. } } Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan …

Continue reading

C++ Template Example #Programming Code Examples #Java/J2EE/J2ME #Ajax

/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in …

Continue reading

Pointers #Programming Code Examples #Java/J2EE/J2ME #Ajax

/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in …

Continue reading

Basic template for a Java applet #Programming Code Examples #Java/J2EE/J2ME #Applets and Basic Graphics

AppletTemplate.java >>>>>>>>>>>>>>>>>>>> import java.applet.Applet; import java.awt.*; ******************** public class AppletTemplate extends Applet { // Variable declarations. public void init() { // Variable initializations, image loading, etc. } public void paint(Graphics g) { // Drawing operations. } } >>>>>>>>>>>>>>>>>>>>> Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017 From: http://sitestree.com/?p=10382 Categories:Programming Code Examples, Java/J2EE/J2ME, …

Continue reading

HelloWWW2.java Illustrates the ability of an applet to read parameters contained in the HTML document #Programming Code Examples #Java/J2EE/J2ME #Applets and Basic Graphics

HelloWWW2.java Illustrates the ability of an applet to read parameters contained in the HTML document (PARAM element containing a NAME-VALUE pair). &&&&&&&&&&&&&&&&&&&&&&&&&&&&&& import java.applet.Applet; import java.awt.*; ************************* public class HelloWWW2 extends Applet { public void init() { setFont(new Font("SansSerif", Font.BOLD, 30)); Color background = Color.gray; Color foreground = Color.darkGray; String backgroundType = getParameter("BACKGROUND"); if (backgroundType …

Continue reading

Loading Images #Programming Code Examples #Java/J2EE/J2ME #Applets and Basic Graphics

JavaMan1.java Applet that loads an image from a relative URL. ************************************************************* import java.applet.Applet; import java.awt.*; /** An applet that loads an image from a relative URL. * >>>>>>>>>>>>>>>>>>> public class JavaMan1 extends Applet { private Image javaMan; public void init() { javaMan = getImage(getCodeBase(),"images/Java-Man.gif"); } public void paint(Graphics g) { g.drawImage(javaMan, 0, 0, this); } …

Continue reading

Controlling Image Loading #Programming Code Examples #Java/J2EE/J2ME #Applets and Basic Graphics

~~~~~~~~~~~~~~~~~~~ ImageBox.java A class that incorrectly tries to load an image and draw an outline around it. The problem is that the size of the image is requested before the image is completely loaded, thus, returning a width and height of -1. ~~~~~~~~~~~~~~~~~~~ import java.applet.Applet; import java.awt.*; /** A class that incorrectly tries to load …

Continue reading

Javascript : Miscellaneous Code #Programming Code Examples #Java/J2EE/J2ME #Ajax

var browser=navigator.appName; var b_version=navigator.appVersion; <a href="http://www.justetc.net" target="_blank"> <img border="0" alt="hello" src="b_pink.gif" id="b1" width="26" height="26" onmouseover="mouseOver()" onmouseout="mouseOut()" /> Place the following code under script tag/in a javascript file function mouseOver() { document.getElementById("b1").src ="b_blue.gif"; } function mouseOut() { document.getElementById("b1").src ="b_pink.gif"; } <map name="planetmap"> <area shape ="rect" coords ="0,0,82,126" onMouseOver="writeText(‘You are over the target area’)" href ="target.htm" target …

Continue reading

Valarray Example #Programming Code Examples #Java/J2EE/J2ME #Ajax

/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in …

Continue reading