Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-02-2009, 04:07 PM
Member
 
Join Date: Apr 2009
Posts: 8
Rep Power: 0
albi_87m is on a distinguished road
Default HELP Homework exercise
book >> Computer.Graphics.Using.Java.2D.and.3D


i've got to finish it till 23:59 (today) so plz help me
Code:
/**  
3.5 Swing contains the class JColorChooser that allows 
    interactive color selections through a dialog box. 
    Modify the program in Exercise 3.2 to allow the 
    selection of drawing colors using the JColorChooser 
    class.  */


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.geom.*;

public class Ex2 extends JApplet {
  public static void main(String s[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JApplet applet = new Ex2();
    applet.init();
    frame.getContentPane().add(applet);
    frame.pack();
    frame.setVisible(true);
  }
  
  public void init() {
    JPanel panel = new Ex2Panel();
    getContentPane().add(panel);
  }
}

class Ex2Panel extends JPanel{          
  public Ex2Panel() {
    setPreferredSize(new Dimension(400, 400));
    setBackground(Color.white);
  }

  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    int w = this.getWidth();
    int h = this.getHeight();
    int r = Math.min(w, h) - 100;
    Area a = new Area(new Rectangle(r, r));
    a.subtract(new Area(new Ellipse2D.Double(r/4, r/4, r/2, r/2)));
    g2.translate((w-r)/2, (h-r)/2);
    g2.setColor(Color.green);
    g2.fill(a);
    g2.setColor(Color.black);
    g2.draw(a);
  }
}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-03-2009, 03:16 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,478
Rep Power: 8
Fubarable is on a distinguished road
Default
so how many places are you posting this question? Multiposting and stepping on other's threads will likely upset folks here, and I don't think that this is your goal. Also, it may help you get answers if you ask a specific question.

Best of luck.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-04-2009, 01:54 AM
Member
 
Join Date: Apr 2009
Posts: 8
Rep Power: 0
albi_87m is on a distinguished road
Default
i found a solution now, sorry for this, u can send this 2 trash
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-04-2009, 06:10 AM
Darryl.Burke's Avatar
Senior Member
 
Join Date: Sep 2008
Location: Madgaon, Goa, India
Posts: 736
Rep Power: 2
Darryl.Burke is on a distinguished road
Default
The post or the poster?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
String Exercise carlodelmundo New To Java 5 03-06-2009 01:59 PM
Help with Beginner exercise. Trunksten New To Java 1 07-10-2008 06:40 AM
I/O exercise Feldom New To Java 1 10-28-2007 05:48 PM
help with exercise e_as're New To Java 3 09-25-2007 11:14 AM
help with an exercise calcuting tax e_as're New To Java 7 08-01-2007 04:17 AM


All times are GMT +2. The time now is 10:09 PM.



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