• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Harman Bunder
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Harman Bunder
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic