|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with character parameter
I am a newbie. I have the following problem and I just can't get it right.............
Here it goes. I am to create the square out of whatever character is contained in character parameter fillcharacter. Thus, if side is 5 and fillcharacter is "#", the method should display ##### ##### ##### ##### ##### This is what I have so far: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Square extends JApplet { int size; public void init() { String input = JOptionPane.showInputDialog( "Enter square size:"); size = Integer.parseInt( input ); } public void squareOfCharacters( Graphics g ) { String input = JOptionPane.showInputDialog( "Enter Character:"); int y = 50, x = 5; for ( int a = 1; a <= size * size; a++ ) { g.drawString( "\n%s!\n", x += 5, y ); } } public void paint( Graphics g ) { squareOfCharacters( g ); } } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Help with character parameter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|