Tableau JComponent[], lire les JTextfield et JComboBox qui le compose
Bonjour,
j'ai créé un tableau de JComponent, qui contient des JtextField, et des JComboBox.
par exemple :
Code:
1 2 3
| _Quantity = new JTextField();
_Quantity.setColumns(10);
_Component[14] = _Quantity; |
cepandant, si j'appelle :
Code:
_strQuantity = _Component[14].getText();
bim, j'ai l'erreur : gettext not applicable for the type JComponent (normal)
donc, comment faire pour récuperer mes valeur dans les JtextrField ?
idem, Pour les JComobox :
:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| public String getComboBoxValue (JComboBox c)
{
String a = c.getItemAt(c.getSelectedIndex()).toString();
return a;
}
// içi je vais rappeler la méthode pour connaitre la valeur dans la Jcombobox "_TowerHeightList" :
String[] _TowerHeightStrings = { "5", "10", "15", "20", "25", "30"};
_TowerHeightList = new JComboBox(_TowerHeightStrings);
_Component[3] = _TowerHeightList;
String _strTowerHeight = getComboBoxValue (_Component[3]); // j'obtient la mème erreur !
// pourtant _Component[3] est bien une Jcombobox ! |
comment faire ? on me parle de Cast, mais je ne comprends pas grand chose, hélas.
merci d'avance les développeurs !
gdlbb.