| Java Applets - Part 2 (Java) | |
|---|---|
| Tweet Topic Started: Jun 3 2007, 12:47 PM (456 Views) | |
| rig | Jun 3 2007, 12:47 PM Post #1 |
|
1a5a6a4
![]()
|
Wonder how to draw graphics, or to have something other then text? This is how to do it... We use 2 classes, java.applet.Applet, and java.awt.Paint. We need to use these classes, so lets import them like this.
Look at the difference from regular programs here
Graphics, is a special object for the paint class. The Graphics page part means we are creating a Graphics object called page. You'll learn more about objects later. The graphics object, page, has some of its own methods. Like the keyboard class, it is what we call Abstract. We will also talk about that more later. Here are some basic methods for you to use: • drawRect(x,y,l,w) • fillRect(x,y,l,w) • drawOval(x,y,l,w) • fillOval(x,y,l,w) • drawString(str,x,y); • setColor(Color) //Color.black Color.blue Color.red Color.green and so on //You can also use this: page.setColor(new Color(r,g,B)); You can also search through some of the java class libraries online to find out more With most drawing methods, you can replace draw with fill. Not all, but most.
|
| |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Tutorials · Next Topic » |







3:20 AM Jul 11