W
wee
i have this code:
public class ArrayUI extends JFrame {
public JPanel pane = new JPanel();
public JTextField[] item = new JTextField[20];
public ArrayUI() {
super("title");
FlowLayout fl = new FlowLayout();
setLayout(fl);
Handler handle = new Handler();
for (int i = 0; i < item.length; i++) {
item = new JTextField(("Text here " + i), 10);
item.addMouseListener(handle);
pane.add(item);
}
add(pane);
pack();
}
private class Handler extends MouseAdapter {
public void mouseClicked(MouseEvent e){
}
// i want to get the index of the array (item[]) of the JTextField
// object that received the mouseClicked action.
// any idea how i can do that?
// using the getSource() method returns the object itself,
// not the index of the array. help please..
}
}
public class ArrayUI extends JFrame {
public JPanel pane = new JPanel();
public JTextField[] item = new JTextField[20];
public ArrayUI() {
super("title");
FlowLayout fl = new FlowLayout();
setLayout(fl);
Handler handle = new Handler();
for (int i = 0; i < item.length; i++) {
item = new JTextField(("Text here " + i), 10);
item.addMouseListener(handle);
pane.add(item);
}
add(pane);
pack();
}
private class Handler extends MouseAdapter {
public void mouseClicked(MouseEvent e){
}
// i want to get the index of the array (item[]) of the JTextField
// object that received the mouseClicked action.
// any idea how i can do that?
// using the getSource() method returns the object itself,
// not the index of the array. help please..
}
}