/* 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 …
Category: FromSitesTree.com
May 15
Using the this reference in class Ship3 #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing
/./././././././././. // Give Ship3 a constructor to let the instance variables // be specified when the object is created. /./././././././././ class Ship3 { public double x, y, speed, direction; public String name; public Ship3(double x, double y, double speed, double direction, String name) { this.x = x; // "this" differentiates instance vars this.y = y; …
May 15
Message.java Applet that reads customization parameters from an HTML file #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing
******************* Message.java Applet that reads customization parameters from an HTML file ******************* import java.applet.Applet; import java.awt.*; **************** public class Message extends Applet { private int fontSize; private String message; public void init() { setBackground(Color.black); setForeground(Color.white); // Base font size on window height. fontSize = getSize().height – 10; setFont(new Font("SansSerif", Font.BOLD, fontSize)); // Read heading message …
May 15
ContactSection.jsp A snippet of a JSP page. It defines a field (accessCount), so pages that include it and want to directly utilize that field must use the include directive, not jsp:include. #Programming Code Examples #Java/J2EE/J2ME
ContactSection.jsp A snippet of a JSP page. It defines a field (accessCount), so pages that include it and want to directly utilize that field must use the include directive, not jsp:include. <%@ page import="java.util.Date" %> <%– The following become fields in each servlet that results from a JSP page that includes this file. –%> <%! …
May 15
articleTitle #Programming Code Examples #CategoryName #SubCategoryName
articleLongDescription Note: This article is brought from our old site: http://www.salearningschool.com/example_codes/. The author can be Sayed Ahmed or Can be Just Posted by Rafiq (for the most cases) (Jan 1st, 2017) From: http://sitestree.com/?p=10172 Categories:Programming Code Examples, CategoryName, SubCategoryNameTags:CategoryNameSubCategoryName Post Data:2017-01-02 15:53:09 Shop Online: https://www.ShopForSoul.com/ (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com In Bengali: http://Bangla.SaLearningSchool.com …
May 15
Call member function for each element in vector #Programming Code Examples #C++ #Vector
/* 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 …
May 15
Accesses methods in a Ship2 object #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing
********************************************* Test2.java Accesses methods in a Ship2 object ********************************************* // Give the ship public move and printLocation methods. class Ship2 { public double x=0.0, y=0.0, speed=1.0, direction=0.0; public String name = "UnnamedShip"; private double degreesToRadians(double degrees) { return(degrees * Math.PI / 180.0); } public void move() { double angle = degreesToRadians(direction); x = x + …
May 15
draws a circle wherever mouse was pressed #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing
CircleListener.java A subclass of MouseAdapter that draws a circle wherever mouse was pressed. Illustrates first approach to event-handling with listeners: attaching a separate listener *********** import java.applet.Applet; import java.awt.*; import java.awt.event.*; /** The listener used by CircleDrawer1. Note call * to getSource to obtain reference to the applet. * *************** public class CircleListener extends MouseAdapter …
May 15
Adds typing to the freehand drawing. #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing
import java.applet.Applet; import java.awt.*; import java.awt.event.*; /** A better whiteboard that lets you enter * text in addition to freehand drawing. * ****************** public class Whiteboard extends SimpleWhiteboard { protected FontMetrics fm; public void init() { super.init(); Font font = new Font("Serif", Font.BOLD, 20); setFont(font); fm = getFontMetrics(font); addKeyListener(new CharDrawer()); } private class CharDrawer extends …
May 15
DashedStrokeExample.java Draws a circle with a dashed line segment (border). Inherits from FontExample.java. #Programming Code Examples #Java/J2EE/J2ME #Advanced Swing
>>>>>>>>>>>>>>>>> import java.awt.*; /** An example of creating a custom dashed line for drawing. * ********************* public class DashedStrokeExample extends FontExample { public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D)g; drawGradientCircle(g2d); drawBigString(g2d); drawDashedCircleOutline(g2d); } protected void drawDashedCircleOutline(Graphics2D g2d) { g2d.setPaint(Color.blue); // 30-pixel line, 10-pixel gap, 10-pixel line, 10-pixel gap float[] dashPattern = { …
