+Many more documents and lessons in http://grow-book.blogspot.com/
+Video content
what's going on guys it's fucking and welcome to your 84th Jeff tutorial and
this story i'm going to be going over graphics because well my ultimate goal
of these stories is pretty much make computer games and we can make a
computer game without sweet graphics so I'm finally getting into graphics i
decided to abandon flowlayout and stuff for now because you know this is just
much more exciting if we need any other layouts will go back to him but for now
i want to start making some sweet graphics on the screen so let's go ahead
and do that as you can see i made a new class called peach because well to be
quite honest just because I like peaches and in these extends jpanel because
we're going to be using that so don't forget to have all your imports now
let's go ahead and get started with making graphics on the screen now in
order to make graphics on the screen we need a method called paintcomponent in
this paint component method is used to draw graphics on the screen so let's go
ahead and put public void paint component and for a parameter it takes
an object from the graphics class so graphics and I just named Angie can name
it whatever variable you want in this parameter right here this G this is
going to be used to like set the color and we manipulate this object depending
on what we want to draw but don't forget that you need this method called pink
component this is built-in method arm that's inherited and this is the method
used to create all graphics on the screen so now that we have this method
we can automatically start creating graphics so let's go ahead and get to it
the first thing we need to do is just one other housekeeping thing we need to
put super paint component in just fill in G right there and what this is going
to do is it's going to call the super classes
remember this is how you call superclasses methods we want to call the
super classes pain component method and you just need to do this because their
stuff in the soup
class that we need to use just for housekeeping stuff and pass in your
parameter whatever was here in that's the only kind of confusing thing that
might not be self-explanatory
so don't forget that so now let's go ahead and get started the first thing we
want to do a set the background color for our screen so go ahead and write
this which means this object set background in band look at that now is a
parameter for background color you just take a color now java heart has built-in
constants of colors which is pretty much are your basic colors but for now in
order to get constant just put color . white because we just want a plain white
background so now we pretty much have on our screen a white background not very
exciting but we're going to change that soon in order to draw objects on the
screen you first need to tell your object or your graphic object what color
you want to use to draw with so let's go ahead and put G set color and is a
parameter just like set background it takes a color constant now let's go
ahead and set our color to color got blue and make sure blues in all caps and
that means constant java so now that we have a color for graphics object we can
begin drawing a rectangle honor screen so the first thing I'm going to tell you
guys how to draw a rectangle and to do that it's phil correct and what this is
going to do is it's going to give you four parameters and this is going to
draw a rectangle a solid rectangle on the screen so the first parameter it
takes is the expert under and why now this top left corner of the window is 00
in from left to right this is the X from left to right and why is up and down so
let's go ahead and make the coordinates x and y and you should know this if you
are ever took a math class in your life so at 25 25 which would be somewhere
around here 25 / $MONEY and twenty-five down
that is where we want to top left of the rectangle to be now how why do we want
the rectangle to be let's just go ahead and put a hundred pixels wide by 30
pixels high so now we got our color and our coordinates of our rectangle right
here so now we just have a blue rectangle chillin on our screen violent
tell you guys something else you can do
next we can go ahead and put set color and we can set the color again or pretty
much reset the color and if we want to have a custom color that's not a
constant like arm our own RGB values and RGB means red green and blue just go
ahead and put new color and as our parameters you type in the RGB value you
want
so let's put like 190 comments 80 1 comma 2 15 make sure none of these
values go above 255 and this pretty much means our how much red do we want it a
hu
...
En esta página del sitio puede ver el video en línea Java Programming Tutorial 84 Drawing Graphics de Duración hora minuto segunda en buena calidad , que subió el usuario Grow Book 24 septiembre 2016, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 139 veces y le gustó 0 a los espectadores. Disfruta viendo!