/* gen3.java PROF. AUCIELLO (gen3 = deals with varying color and canvas location. Goals: . re: "gen3.java" (below), compile it. . use GEN3.HTML set below to execute . make it work. . print results. put in notebook. Topics: . 'public' . x (hor) and y (ver) coord for drawString . Fonts . Colors . Text and Background Color . while (condition) {execution} loop . Time Delay (note speed of loop) . Defining and initializing variables (int x = 50) . incrementing (x =+ 50) Genesis -- Java application ------------------------------------------- */ // FONTS, COLORS, LOCATION as an Applet: import corejava.*; // req. for applet import java.awt.Graphics; // req. for app & prog import java.awt.*; public class gen3 extends java.applet.Applet // req for app { public void paint(Graphics g) // req for app { int red = 00; int gre = 00; int blu = 00; int xx = 1; Font fs = new Font("Sans Serif", Font.BOLD, 10); // define Font Font fm = new Font("Monospaced", Font.BOLD, 15); // define Font // Font is an object. Need to define the 'properties' of Font, // (BOLD, Sans Serif, 14, etc). // Font fs, fm define Fonts. g.setFont(fs); // setFont is part of the graphics 'library' // setFont is now 'linked' with the program. setBackground(Color.yellow); g.setColor(Color.red); while (red<255) { g.setColor(new Color(red,gre,blu)); g.setFont(fm); g.drawString("Watch brown change to orange ..",200,50); g.drawString("Figure out-- Color(red,gre,blu)",200,100); g.setFont(fs); repaint(); g.drawString("10 point font at hor=10, ver="+red,10,red); red += 16; while (xx<10000000) { xx +=1; } xx=0; } } } THIS IS GEN3.HTM: using brackets in place of inequality signs. [html] [table border cellpadding=10 width=140] [tr] [th][th colspan=120 [h3] [pre] "Learn from this Applet about Changing Fonts, controlling location of printing on screen, and changing colors with combinations of red, green, & blue. Using "controlled experiment" method, "hack" away until you improve it and fully understand it." JA [/pre] [/th] [td valign="top" width=140] [IMG SRC="auci-07.gif" width=140][BR] [/td] [/tr] [/table] [APPLET CODE="gen3.class" WIDTH=600 HEIGHT=300 IGNORE=""] [/APPLET] [/html] Questions: WHAT DOES [PRE] DO? HOW TO COMMENT IN JAVA? HOW TO COMMENT IN HTLM? HOW TO SET BACKGROUND COLOR? HOW TO SET TEXT COLOR? WHAT DOES 'REPAINT' DO? WHAT DOES THE setColor Method COLOR(RED,GREEN,BLUE) DO? ARE ALL COLORS MADE UP OF RED,GREEN, BLUE [RGB] COMBINATIONS? IF ORANGE IS THE LIGHT HUE OF BROWN, WHAT IS THE LIGHT HUE OF BLUE? HOW TO SLOW DOWN THE DISPLAYING OF TEXT? end block comment */ -->