1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: How to display a certain char in a string as a polygon?

Discussion in 'Software Development' started by ElementOfMagic, Feb 3, 2013.

Thread Status:
Not open for further replies.
  1. ElementOfMagic

    ElementOfMagic Thread Starter

    Joined:
    Dec 30, 2012
    Messages:
    52
    Hello. :)

    Programming language I am using: Java (not JavaFX, Swing or anything else of that nature. Just regular Java).

    Here's how my program works:

    • A user is asked to enter some text into a textfield.
    • The entered text is then read in by the program.
    • The program checks whether a specific character (in my case 'h' or 'H') is present in the entered text.
    • If so, the program removes that character from the string and instead, displays it as a drawn polygon (not a Unicode character) and displays the rest of the string using the drawString() method.

    Basicially, what I'm stuck on is how I would go about coding step 4 in the above list. ^^

    So far, I have managed to remove the character I wish to replace (called 'sl1' )from the string when it occurs in the entered text (code below):

    Code:
    if(pr_word.indexOf(sl1)!=-1)
    		{
    		   pr_word = pr_word.replace(sl1, "");
    		   g.setColor(Color.red);
    		   g.drawPolygon(x,y,5);
    		}
    


    Any help/guidance will be greatly appreciated. :) (y)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1088058

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice