[nbusers] Re: Using g.DrawRect and paint functions in Netbeans

  • From: Edson Richter < >
  • To:
  • Subject: [nbusers] Re: Using g.DrawRect and paint functions in Netbeans
  • Date: Fri, 26 Oct 2012 20:43:55 -0200
  • Organization: Simkorp Inform├ítica Ltda

Em 26/10/2012 23:28, trhouse escreveu:
On 10/26/2012 10:35 AM, nagatopain17 wrote:
Hello! First of all, I'm rather new to both netbeans and java. I get the coding when i see it because ive programmed somewhat in C++ and basic visual, but im still new :3

Ok, im reading this guide:
http://www.gamedev.net/page/resources/_/technical/game-programming/java-game-programming-part-i-the-basics-r1262

im trying to use the shape functions like g.drawRect(x,y,width,height)

netbeans however tells me it doesnt know what g. is or something...

cant post the specific words right now, but could someone tell me how i can use this? Thanks!




"g" is a Graphics (an object type). It carries internally a state which determines what it draws.. That state is sometimes referred to as the graphics context and sometimes people mean just the graphics object itself when they say "graphics context" .

Please, forgive me for intruding on this explain. I don't want to be rude, but there is a misconception here. Happens that "g" is not a Graphics neither an object type. It would be a method parameter of kind Graphics in the specific case of method paint.

In the method signature

public void paint(GraphicsContext graphics);

We have the following entities (or terms) involved:

public -> this keyword provide this method is publicy available to all classes in the virtual machine
void -> it is the return type, in this case means there is not return type!!!
paint -> is the method name
GraphicsContext -> is the object type for the next entity (graphics). In this case means that when the applet is called to paint it self, represents in a high level the graphic portion of the browser will be available in the object. GraphicsContext would be, itself, a class or an interface.
graphics -> is the method parameter or variable name that will point to the memory address that contains an object (instance) of type GraphicsContext. You will manipulate the methods in this object (instance) in order to perform your goal. It could become any valid name (like "g", "graphics", "gr", "graph", "mybigvariablename", "_any_thing_else_2012" - all without quotes).


Sometimes these terms would be confusing, so is very good to clear soon enough to avoid trouble understanding OOP in future.

A good start point is the great The Java Tutorial - you will find it here: http://docs.oracle.com/javase/tutorial/getStarted/index.html (I'm his big fan, trust me: after +15 years of Java programming, I still go there for education).

I know that starting from very beggining would be boring, but a good solid basement is crucial for developing complex applications (and games, IMHO, are in the top 5 complex applications every).

Regards,

Edson



[nbusers] Using g.DrawRect and paint functions in Netbeans

nagatopain17 10/26/2012

[nbusers] Re: Using g.DrawRect and paint functions in Netbeans

Benno Markiewicz 10/26/2012

[nbusers] Re: Using g.DrawRect and paint functions in Netbeans

trhouse 10/26/2012

[nbusers] Re: Using g.DrawRect and paint functions in Netbeans

Edson Richter 10/26/2012

[nbusers] Re: Using g.DrawRect and paint functions in Netbeans

trhouse 10/26/2012

[nbusers] Re: Using g.DrawRect and paint functions in Netbeans

Edson Richter 10/27/2012

[nbusers] Re: Using g.DrawRect and paint functions in Netbeans

trhouse 10/27/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close