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
    Posts
    59

    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:

    http://AnimeXclusive.no-ip.com/java/test.gif

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



    Thank you .



    this my code:
    http://AnimeXclusive.no-ip.com/java/
    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
    Posts
    13
    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.setVisible(true);
    myFrame.setTitle("TV Test");
    myFrame.setBackground(Color.white);

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

    // add listener to close frame
    myFrame.addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent e)
    {
    System.exit(0);
    }
    });
    }
    }

    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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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