Java Tutorial 28 (GUI) - Draw a Circle and Oval

preview_player
Показать описание
We will be learning on how to create a circle and oval by using Java GUI.
Рекомендации по теме
Комментарии
Автор

3:26 he says to paint with null, but that'll throw a null pointer. The explanation as to why this works is completely off base. This may have worked 8 years ago when this video was uploaded, but it throws a null pointer when you try to use the graphics object up on line 18 and 19. Better to replace line 27 with t.paint(t.getGraphics()) that should resolve the issue.

The correct explanation of what is going on is that you have to sent a graphics object to the paint function, because the paint function says it requires an object of type Graphics, and if you give it a null, when it tries to call a function off of a null object it will throw a null pointer.

makeyourspace
Автор

it wont let me do null, throws an error.

thecodeguide
Автор

Thanks a lot for this video! I was searching all over the web for this but only your video worked for me.

noblessus
Автор

Thank You for your efforts and time to make this video.

RobertParenton
Автор

thx for all the tutorials, they have been a lot of help

cpotdevin
Автор

can you increase the width of the border of the circle or any shape

MrTorsionist
Автор

Did you get the null pointer exception, with passing null into the paint method and just ignore it? It still drew the circle :P

BobDaManiac
Автор

how would u do 16 sections in a circle?? :O

sweetcherrii
Автор

How do you draw that if you use ContentPane above JFrame? Its not shown there and I'm only a beginner :(

xParcKx
Автор

lol you just saved a life bro. thank you!

dispuertorican
Автор

The circle works fine and everything but the only weird thing is that the cricle appears in front of a background that is not blank but a picture of my screen. Like you have the gui with a picture of my screen and the circle on it? Why is this so???

PlayerGamerXXX
Автор

that was an easy lesson :)
thanks man

borkan
Автор

PlayerGamerXXX yeah I get the same issue, I'm not sure why

brguelike
Автор

lol Yes, it still works but not a good practice. :P I have another tutorial on this on Java Tutorial 50 where I show you how to do it with a good practice.

JohnGizdich
Автор

There are no errors its just not showing what I drew, that was when I did the GUI and everything I had made a JFrame and a JPanel why didn't it work then?

MrJohnboyofsj
Автор

anyone know how to do this in jraster?

hdpasdlol
Автор

you should summarize in the end of your videos, it would make it even better.

bobbyjones