File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes need help with string array using methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

need help with string array using methods

Jere Johnson

Joined: Mar 29, 2003
Posts: 28
This program compiles correctly, but
i cant seem to get anything to appear on my applet screen except for the textField with the current program down below. Can anyone see a problem, i cant?
i think im seeing doubles, since ive been looking at
this program for 30 hours.

private TextField input;
private String [] stringArray = new String [10];
public void init(){
input = new TextField (20);
add (input);
input.addActionListener (this);}
public void paint(Graphics g){
display(stringArray, g);}
public void actionPerformed (ActionEvent e){
repaint ();}

// This section below contains the methods
public void getData (String [] array)
for (int z=0; z < array.length; z++){
array [z] = input.getText();}}
public void display(String [] array, Graphics g){
int yValue=100;
for (int w=0; w < array.length; w++)
g.drawString("Index "+w+"is "+array[w], 100, yValue*15);}
}//end of program

Diapers are the best invention
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
This is being continued elsewhere.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: need help with string array using methods
jQuery in Action, 3rd edition