Follow us on Twitter!
The important thing is not to stop questioning. - Albert Einstein
Sunday, April 20, 2014
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Members Online
Total Online: 31
Guests Online: 30
Members Online: 1

Registered Members: 82847
Newest Member: Zanjux
Latest Articles

Drawing with java...

Arrow Image Tired of paint? Try this.....

Ok, first off there are two types graphics facilities in Java, Drawing, and Graphical User Interfaces(GUI's).
Graphic Options are only allowed within certain context, JFrames and JApplets.

A JFrame is simply a window that our program creates and a JApplet is simply a window that can be displayed from another application like a web browser.

Usually you add JPanels to your JFrame and in JPanels there are two important things that we can do draw figures and such and add other GUI components.

The graphics skeleton would look something like this
import java.awt.*;
import javax.swing.*;

public class GraphicsSkeleton
   private static final int X_SIZE = 100, Y_SIZE = 100;   

   public static void main(String[ ] args)
      JFrame frame = new JFrame();
      frame.setSize(X_SIZE, Y_SIZE);
      GraphicsPanel panel = new GraphicsPanel();
   private static class GraphicsPanel extends JPanel
      public void paintComponent(Graphics g)
         // Add drawing code here.

For your drawing code there are many things you can do. A simple one would be drawing a line so here is how that would look.

g.drawLine(20, 20, 40, 40);

Ok, so the g.setColor(Color.BLUE); is just simply telling the program to make that line blue, and the g.drawLine(20,20,40,40); makes that line. The first two digits the 20, 20 are the first x , y.

It starts at your left top window then x goes right, then the y goes down (backwards from what you normally do because y is positive) and the same thing with the 40, 40.

When you minimize sometimes the program doesnt re-paint itself so you would add the panel.repaint(); command so if it somehow gets minimized it will basically save your paint you have on there and when maximized it will restore it.

If you would like to add words in your drawings you can do it the same as you did the drawings, just follow the example below...

   g.setFont(new Font("Chicago",
      Font.ITALIC + Font.BOLD, 40));
   g.drawString("Whoo Hoo!", 40, 290);

the g.setColor(Color.RED); sets it to color red, g.setFont(new Font("Chicago", 40<-- we have the new Font in there because Java does not have that font and the first 40 tells how big to make the font, so you set your own, the Font.ITALIC + Font.BOLD tells it to be Italic and Bold and the 40 is the x coordinate, the 290 is the y coordinate so just like i said before, it starts at the very top left corner and goes right 40, then goes down 290, and starts the begining letter there then finishes it on the string.

Thanks for reading, sorry for errors
comment please :)


LiveFastDieFunon June 17 2006 - 20:01:35
Same goes for this articel. Nice.
z3r0phr34kon June 17 2006 - 20:15:41
there...i commented. happy now?! (i voted 'Awsome!' Grin)
aenman123on June 18 2006 - 02:05:29
so fucking hard to read, put stuff in [code] tags and indent!!!!
pyrodude0303on June 18 2006 - 04:16:30
it was indented before i hit post.....thats why i put formatting will be off....
system_meltdownon June 18 2006 - 13:04:11
I edited the formatting, nice article by the way
system_meltdownon June 18 2006 - 13:05:44
It also has code tags there now too, happy aenman123 Pfft
hackerWoFon June 21 2006 - 04:51:33
Well i would have to say nice article.
pyrodude0303on June 21 2006 - 06:54:57
Thanks system....maybe some people can "read" it
godon June 25 2006 - 17:13:09
nice!! Grin top notch
Post Comment


You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.