Results 1 to 7 of 7
  1. #1
    vimalaranjan is offline Member
    Join Date
    May 2011
    Posts
    8
    Rep Power
    0

    Default Replacing Image for a String

    please have a look my code

    public void draw(Graphics g)
    {
    final int x = 20;
    final int y = 40;
    final int width = 40;
    if(getColor())
    {
    g.setColor(Color.WHITE);
    g.setFont(new Font("Courier", g.getFont().getStyle(), width));
    g.fillOval(10, 10, width, width);
    g.setColor(Color.BLACK);
    }
    else
    {
    g.setColor(Color.BLACK);
    g.setFont(new Font("Courier", g.getFont().getStyle(), width));
    g.fillOval(10, 10, width, width);
    g.setColor(Color.WHITE);
    }
    g.drawString("+", x, y);
    }



    in this code "g.fillOval(10, 10, width, width);" line will displays a Oval, now i have to replace the Oval with an image (png) from one folder.
    how can i do this?

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    7

    Default

    Applet or application?
    Swastik

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

  4. #4
    vimalaranjan is offline Member
    Join Date
    May 2011
    Posts
    8
    Rep Power
    0

    Default

    Application

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default

    Read the API for Graphics, looking for methods that accept an Image as one of the parameters.

    db

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

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Read the API for Graphics, looking for methods that accept an Image as one of the parameters.

    db
    He's already been told this here in a previous thread (which he has ignored) and in cross-posts. I think he's actively trying to get on everyone's do not help list.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default

    I think he's actively trying to get on everyone's do not help list.
    Added to mine. Thanks for the heads-up!

    db

Similar Threads

  1. replacing text in jTextArea by image
    By Pain in forum AWT / Swing
    Replies: 2
    Last Post: 03-06-2010, 06:59 PM
  2. Replacing char in string help
    By jimmy-lin in forum New To Java
    Replies: 3
    Last Post: 10-12-2009, 07:01 AM
  3. Replacing the chars within a string.
    By Mayur in forum New To Java
    Replies: 2
    Last Post: 03-27-2009, 05:00 AM
  4. Help Replacing String
    By 7oclock in forum New To Java
    Replies: 5
    Last Post: 02-14-2009, 08:31 AM
  5. splitting string and replacing
    By itsme in forum New To Java
    Replies: 1
    Last Post: 12-11-2007, 04:08 PM

Posting Permissions

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