Reputation: 765
I have been recently trying to utilize the Java API (http://docs.oracle.com/javase/7/docs/api/). I was wondering how I can locate the "page.drawRect" method. Is the "drawRect" method apart of the "page" class ? I'm not sure if that's how the syntax works, or if I'm making sense. All I want is an explanation of "page.drawRect" and maybe some tips on how to use the API documentation. Nothing is wrong with the actual code I posted. Thank you :)
import javax.swing.JApplet;
import java.awt.*;
public class HopeThisWorks extends JApplet
{
public void paint(Graphics page)
{
page.drawRect(50, 50, 40, 40);
page.drawRect(60, 80, 225, 30);
page.drawOval(75, 65, 20, 20);
page.drawLine(35, 60, 100, 120);
page.drawString ("\"Don't try to be like Jackie. There is only one Jackie. " +
"Study computers instead.\"", 110, 70);
page.drawString ("-Jackie Chan",130, 100);
}
}
Upvotes: 0
Views: 266
Reputation: 159874
drawRect
a method in the Graphics
class. Have a look at Graphics.drawRect().
page
here is the variable instance name for the applet Graphics
object.
For more see:
Upvotes: 1
Reputation: 44250
maybe some tips on how to use the API documentation
If you're using Eclipse,
http://docs.oracle.com/javase/7/docs/api/
" in the Javadoc location path textfieldNow you will be able to step into the source code, or simply hover over drawRect
and read the associated documentation.
Upvotes: 1
Reputation: 18468
Other answers are good enough. Adding a small note.
Use an IDE like IntelliJ/Netbeans/Eclipse. Most of these tools has ability to take appropriate definition, show quick documentation etc.
Pragmatic Programmer Tip- Use one editor well
Upvotes: 1
Reputation: 133679
It's quite simple
In your example you are talking about the Graphic
class, page
is indeed a reference to a Graphic instance. So you should look for class java.awt.Graphic
.
Whenever you import a package you don't need to specify the full qualified name of a class contained inside that package, that's why you can use plainly Graphic page
instead that java.awt.Graphic page
but this is just a shorthand to make everything less verbose (and sometimes more ambigue).
Upvotes: 3