M
Mike Bosschaert
Hi,
For my small application I want to use tabs. On one tab I display 'default
values' in JTextFields. On another tab I have a button which should do some
actions, based on the default values. I tried to write a method to collect
the desired default value, but I can't seem to find the right way. I see
why it does not work but I'm on the wrong track and can't see which way I
should go. The method I tried is given below.
Thanks for you help!
Mike
public static String getValueFromPanel(String panelName, String fieldName) {
String fieldValue="";
try {
Class cl = Class.forName("MyMusic");
Field[] f = cl.getFields();
for (int j = 0; j < f.length; j++) {
if (f[j].getType().toString().equals("class javax.swing.JPanel")) {
for (int i = 0; i < f[j].getComponentCount(); i++) {
if (f[j].getComponent(i).getName() == fieldName) {
fieldValue = f[j].getComponent(i).toString();
}
}
} else {
return "object: " + f[j].getType() + " not handled by method";
}
}
} catch (Exception ex){System.out.println(ex);};
return fieldValue;
}
For my small application I want to use tabs. On one tab I display 'default
values' in JTextFields. On another tab I have a button which should do some
actions, based on the default values. I tried to write a method to collect
the desired default value, but I can't seem to find the right way. I see
why it does not work but I'm on the wrong track and can't see which way I
should go. The method I tried is given below.
Thanks for you help!
Mike
public static String getValueFromPanel(String panelName, String fieldName) {
String fieldValue="";
try {
Class cl = Class.forName("MyMusic");
Field[] f = cl.getFields();
for (int j = 0; j < f.length; j++) {
if (f[j].getType().toString().equals("class javax.swing.JPanel")) {
for (int i = 0; i < f[j].getComponentCount(); i++) {
if (f[j].getComponent(i).getName() == fieldName) {
fieldValue = f[j].getComponent(i).toString();
}
}
} else {
return "object: " + f[j].getType() + " not handled by method";
}
}
} catch (Exception ex){System.out.println(ex);};
return fieldValue;
}