Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-07-2007, 07:23 PM
Member
 
Join Date: Jul 2007
Posts: 3
Godzilla is on a distinguished road
Basic graphics applet
Hi I have written this code:

Code:
g.setColor(Color.white); g.fillRect(0,0,500,300); g.setStroke(new BasicStroke(60)); g.setColor(Color.green); g.drawLine(0,0,500,300); g.setStroke(new BasicStroke(60)); g.setColor(Color.green); g.drawLine(500,0,0,300); g.setStroke(new BasicStroke(60)); g.setColor(Color.red); g.drawLine(250,0,250,300); g.setStroke(new BasicStroke(60)); g.setColor(Color.red); g.drawLine(0,150,500,150);
Can anyone help me make an applet from this code that draws a flag and keeps its aspect ratio 2:1. Thanks for any help
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-08-2007, 01:27 AM
Senior Member
 
Join Date: Mar 2007
Posts: 136
goldhouse is on a distinguished road
Ok I will help you to make it in an easy download netbeans , and drag and drop whatever you want , just click on the Play '>' button you will have what you want. Just play around with the colors as you please you will have no trouble if you are sure you dont want to add any functionalities
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-08-2007, 02:53 AM
Member
 
Join Date: Jul 2007
Posts: 3
Godzilla is on a distinguished road
Hey goldhouse, thanks for the reply but I don't understand what you want me to do. I have Netbeans IDE 5.0.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-08-2007, 10:50 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,144
hardwired is on a distinguished road
Here's something to get you started. Your code has an aspect ratio of 5:3.
Code:
// <applet code="FlagApplet" width="500" height="300"></applet> import java.awt.*; import javax.swing.*; public class FlagApplet extends JApplet { public void init() { getContentPane().add(new FlagPanel()); } private class FlagPanel extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g.setColor(Color.white); g.fillRect(0,0,500,300); g2.setStroke(new BasicStroke(60)); g.setColor(Color.green); g.drawLine(0,0,500,300); // g.setStroke(new BasicStroke(60)); g.setColor(Color.green); g.drawLine(500,0,0,300); // g.setStroke(new BasicStroke(60)); g.setColor(Color.red); g.drawLine(250,0,250,300); // g.setStroke(new BasicStroke(60)); g.setColor(Color.red); g.drawLine(0,150,500,150); } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse Applet Viewer not showing graphics? sjchase Java Applets 1 04-17-2008 05:16 PM
Graphics Joe2003 Advanced Java 1 01-25-2008 07:24 PM
graphics Joe2003 Advanced Java 4 01-18-2008 08:44 PM
Basic Applet jkswebsite Java Applets 4 01-13-2008 10:14 PM
Graphics feniger New To Java 1 12-29-2007 05:22 PM


All times are GMT +3. The time now is 09:46 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org