aspose file tools*
The moose likes Beginning Java and the fly likes APPLETS: How to replace a character within a string with fillPolygon using array's. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "APPLETS: How to replace a character within a string with fillPolygon using array Watch "APPLETS: How to replace a character within a string with fillPolygon using array New topic
Author

APPLETS: How to replace a character within a string with fillPolygon using array's.

Harman Bunder
Greenhorn

Joined: Feb 27, 2013
Posts: 2
Hello
I am required to enter a word/sentence into a text box and then print out what I have input, however when I have a special character (in my case 'H' or 'h') it will print out my fillPolygon shape.
I have used an array to try and replace the character H/h with the polygon using an If statement, however I keep on getting the error message: "[line: 49]
Error: method drawH in class Stringpoly cannot be applied to given types;
required: java.awt.Graphics,int,int
found: java.awt.Graphics,int[],int[]
reason: actual argument int[] cannot be converted to int by method invocation conversion



Thanks in advance. I have literally spent hours trying to work out the problem.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
Making the display class implement a Listener interface is usually poor practice, and I think this is no exception. Create a class which implements the Listener.
As for the compiler error: if you read the message it is quite clear. You must pass an int, not an int[].
Why do you need to use fillPolygon? Why are you using that particular technique?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
And welcome to the Ranch
Harman Bunder
Greenhorn

Joined: Feb 27, 2013
Posts: 2
I have changed the code now that my special character 'h' is now printed, however it appears in the top corners where I initially plotted it with the co-ordinates to create the shape.
For example, when I print "elephant", the H is missing but is instead in the top left hand corner, and when I type in 'Morning' a'h' won't appear.

Also in regards to the previous answer, I am using fillpolygon because I need it to be a block of the letter to replace the original special character.
Also, thanks!

Here is my current code:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: APPLETS: How to replace a character within a string with fillPolygon using array's.