The graphics screen is comprised of "components". These may include windows, buttons, labels, text fields, and scroll bars (among other things). They can be put in "containers" (an applet is considered a container) and then may be arranged through the use of a "layout manager". Finally, the use of "listeners" and "handlers" allows us to interact with the program by detecting and reacting to "events" such as clicking the mouse, dragging, etc.
setBackground(Color.thecolor); setForeground(Color.thecolor); Font f=new Font(family, Font.style, size); g.setFont(f); //Families may be: "Serif", "SanSerif", "Monospaced", etc. //equivalent of TimesRoman, Helvetica, Courier //Styles may be: BOLD, ITALIC, PLAIN, etc. g.drawString(thestring, x, y); //draws a string at (x,y) g.setColor(Color.thecolor); //sets pen color, where thecolor //may be: black, white, red, blue, magenta, orange, pink, yellow, //green, cyan, gray g.drawLine(x1,y1,x2,y2); //draws a line from (x1,y1) to (x2,y2) g.drawRect(x,y,width,height); //frames a rectangle g.fillRect(x,y,width,height); //paints a rectangle g.drawOval(x,y,width,height); //frames an oval g.fillOval(x,y,width,height); //paints an oval
Click here to return to IT 108 web page