Я не могу одолжить внутри, если проверить keyTyped метод. Существует followiing часть кода:проверить на редактируемые jcombobox
здесь я инициализацию COMBOBOX:
private void initComponents()
{
this.cboDayModel = new DefaultComboBoxModel<ListItem>();
this.cboDay = new JComboBox<ListItem>(this.cboDayModel);
this.cboDay.addItemListener(this);
this.cboDay.setName("cboDay");
this.cboDay.setBackground(this.einAusClass.hPHB.btnColor);
this.cboDay.setEditable(true);
this.cboDay.getEditor().getEditorComponent().addKeyListener(this);
this.cboDay.getEditor().getEditorComponent().addFocusListener(this);
this.add(this.cboDay);
}
в этот момент я проверить, что было напечатано в:
@Override
public void keyTyped(KeyEvent e)
{
if (!(Character.isDigit(e.getKeyChar())))
{
e.consume();
return;
}
if (e.getSource() instanceof JComboBox) // <-------*************
{
System.out.println("zz2");
this.cbo = (JComboBox<ListItem>) e.getSource();
String str = ((JTextField) cbo.getEditor().
getEditorComponent()).getText();
int zahl = Integer.parseInt("0" + str);
System.out.println(str + "" + zahl);
if (this.cbo == cboDay)
{
if (zahl < 1 || zahl > 31)
{
e.consume();
return;
}
}
}
}
В методе keyTyped я проверить
if (e.getSource() instanceof JComboBox)
Почему он не входит внутрь этого заявления?