Results 1 to 4 of 4
  1. #1
    albi_87m is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

    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
    Java 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);
      }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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.

  3. #3
    albi_87m is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

    Default

    i found a solution now, sorry for this, u can send this 2 trash

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

Similar Threads

  1. String Exercise
    By carlodelmundo in forum New To Java
    Replies: 5
    Last Post: 03-06-2009, 12:59 PM
  2. Help with Beginner exercise.
    By Trunksten in forum New To Java
    Replies: 1
    Last Post: 07-10-2008, 05:40 AM
  3. I/O exercise
    By Feldom in forum New To Java
    Replies: 1
    Last Post: 10-28-2007, 04:48 PM
  4. help with exercise
    By e_as're in forum New To Java
    Replies: 3
    Last Post: 09-25-2007, 10:14 AM
  5. help with an exercise calcuting tax
    By e_as're in forum New To Java
    Replies: 7
    Last Post: 08-01-2007, 03:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •