Draw a point or a dot.

Could anyone explain me as to how to draw a dot on a JPanel?
Will, [fillRect(x,y,1,1)], this method draw a dot?
If no, please help me with this. Thank you.

It will.

It will. By the way, why don’t you test this?

Because i am away from my system, and coding with a pen and paper. And surprisingly realised, that i never tried such a thing ever before.

From what I recall, drawLine(x,y,x,y) is the preferred way of drawing just a single pixel through the general purpose rendering pipeline.
Obviously if you’re doing a lot of individual pixels, then you should bypass the pipeline, and manipulate an Image’s Raster directly

Usually when I am away from my computer I just program on my iPad in pages (because I need an iPad for school although I would much prefer and Android Tablet)…
My handwriting is really messy but sometimes I have been desperate enough to write code in the sand at the beach…

And I wonder why I don’t have any friends… (Kidding, i do, somehow…)

(This is a bit off topic tho…)

Uh, wrong thread matanui?

I believe that he was referring to this: [quote]Because i am away from my system, and coding with a pen and paper. And surprisingly realised, that i never tried such a thing ever before.
[/quote]
CopyableCougar4

Ha, alright, forgot about that. Just seemed so out of the blue.

And to at least contribute something to this thread:

get/set individual pixels in a bufferedimage:


int colorVal = image.getRGB(x, y);

colorVal = someColor.getRGB(); // includes any alpha
image.setRGB(x, y, colorVal);

Can be done faster in bulk via a trick, but that should set you on your way if you’re ever using BufferedImage and need this.