Using an array as parameter to a class.
Posted
by Gabriel A. Zorrilla
on Stack Overflow
See other posts from Stack Overflow
or by Gabriel A. Zorrilla
Published on 2010-04-18T01:44:32Z
Indexed on
2010/04/18
1:53 UTC
Read the original article
Hit count: 480
I have created an array Man:
public main blah blah{ man = man[10]; }
Man has fields such as
Man.name; Man.age; ...
In Man class, there is a OnClick method that opens a new window showing its name and age.
public Man(){ Onclick(){ InfoWindow showinfo = new InfoWindow(this.getid()) // If this is Man[2] the id would be 2. }
And in InfoWindow class:
public class InfoWindow extends JFrame{ public InfoWindow(Man selectedMan){ setSize(300, 200); JLabel info = new JLabel(selectedMan.getname()); add(info); info.setVisible(true); } }
Basically, that's wanna acomplish (show in pseudocode), pass a Man[i] into a class that when a window is created, shows the info related to that man. This is how i'm actualy trying to implement it but it's not working, i'm pretty sure there is a misconception from me in some part.
Any help?
© Stack Overflow or respective owner