2d graphics

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: 2d graphics

  1. #1
    Join Date
    Sep 2004

    2d graphics

    Hi, i have a question about 2d programming, i must make a "tv test picture" and i don;t know howto make it because of all the variety in the picture.

    Ive been told that i must work in layers?

    but what about the circle and the color thats "īnvisible" outside the circle?

    and howto to make the white/black border outside?

    like this figure:


    this is also the same picture that i have to make in java.

    Thank you .

    this my code:
    the file called: Main and MyFrame

    i know it it isnt much but thats the best that i can do right now.

    i also have problem drawing the circle in the middle of the screen.
    My own java video tutorials, feel free to watch it.
    http://www.engineeringserver.com/for...amming-b311.0/ Need java help? For beginning and intermediate java coders!

  2. #2
    Join Date
    Nov 2004
    By working in layers, it means you need to build things on top of each other. For example, start with a white background, then draw gray boxes and a black border (using for loops), then the circle on top of that... and so on.
    In your code, you don't have a main method. That's why it won't run. You need a main method to call all of your other methods. They don't just happen automatically.
    Try starting with this code:

    import java.awt.*;
    import java.awt.event.*;

    public class TVTest
    public static void main(String[] args)
    // create Frame
    Frame myFrame = new Frame();
    myFrame.setSize(500, 450);
    myFrame.setTitle("TV Test");

    // create graphics object
    Graphics myGraphics = myFrame.getGraphics();

    // add listener to close frame
    myFrame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)

    I hope that helps, at least to get the basic format for making frames (and being able to close them).

    For the circle in the middle of the screen:

    myGraphics.drawOval(0, 0, myFrame.getWidth(), myFrame.getHeight())

    that'll do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center