The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Replace specific char in string with fillPolygon()
Discuss Replace specific char in string with fillPolygon() in the Java Help forum on Dev Shed. Replace specific char in string with fillPolygon() Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 26th, 2013, 08:02 AM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 3
Time spent in forums: 45 m 49 sec
Reputation Power: 0
|
|
|
Moving(translate) a g.fillPolygon()
Ok, so I have limited coding experience and have only done basic stuff in VB
So basically i convert my string to char then loop through each char if a char is S i want it to display my own poly.
I think my problem is calling the method(?) to draw it. If i comment out the loop and just display the chars it works fine.
===========================================
edit:
I have figured it out, my poly was an invalid shape thus not displaying.
now after drawing a poly how do i "translate" (move it) in my applet window?
|

February 26th, 2013, 03:46 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
Can you explain what the problem is?
If letter is a char[], then you can test one of its elements directly using the == operator:
letter[i] == 'S'
and not have to convert it to a String.
|

February 26th, 2013, 03:54 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 3
Time spent in forums: 45 m 49 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by NormR Can you explain what the problem is?
If letter is a char[], then you can test one of its elements directly using the == operator:
letter[i] == 'S'
and not have to convert it to a String. |
The problem is that my polygon doesnt replace my "S" char.
basically
the user enters a word
i then add the word to a char array
i then use a loop to check each char in the array and display it exept when the char is "S" i want to display an "S" shaped poly using " fillPolygon(); ".
all my code for this so far is good exept displaying my own "S" shaped fillPolygon(); instead of the single char "S"
my code above takes each char and displays each one in a horizontal line exactly 20px away. my hope were that if my if statement sees and S it was draw my drawS polygon
|

February 26th, 2013, 04:00 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
Quote: | my polygon doesnt replace my "S" char. |
Do you want to clear the graphics area before each time you draw?
Call the super.paint() method.
Where does the code change the location of where the polygon will be drawn?
|

February 26th, 2013, 05:03 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 3
Time spent in forums: 45 m 49 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by NormR Do you want to clear the graphics area before each time you draw?
Call the super.paint() method.
Where does the code change the location of where the polygon will be drawn? |
I have figured it out, my poly was an invalid shape thus not displaying.
now after drawing a poly how do i "translate" (move it) in my applet window?
|

February 26th, 2013, 06:40 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
Change the x,y values that define its location.
|

April 8th, 2013, 12:55 PM
|
|
Registered User
|
|
Join Date: Apr 2013
Posts: 1
Time spent in forums: 4 m 16 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by javanewkid I have figured it out, my poly was an invalid shape thus not displaying.
now after drawing a poly how do i "translate" (move it) in my applet window? |
Hey, how did you go about this issue?.. i have the same problem but for mine, i have drawn out the polygon, but instead of the letter being replaced, the polygon is drawn underneath the entered text.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|