-
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.
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks