0
public void actionPerformed(ActionEvent e) {
    Component[] Component = tabbedPane1.getComponents();
    for (int i = 0; i < 8; i++) {
        if (Component[i] instanceof JLabel) {
            JLabel Name = (JLabel)Component[i];
        } 
        if (Component[i] instanceof JTextField) {
            JTextField Data = (JTextField)Component[i];
        }
        WR.Write(Name.getText(), Data.getText());
    }
}

Помогите пожалуйста забрать с компонентов Jlabel и JTextField значения. Имена лейблов ingridient, а текст боксов data_ingridient. Каждого итема у меня 7 штук. Не получается...

1
  • Ваши ссылки Data и Name создаются и тут же удаляются. Думаю, что вы этот код даже не запускали ) 21 мар 2019 в 12:32

1 ответ 1

0

Например, вот так:

public void actionPerformed(ActionEvent e) {

    String labelString, textFieldString;       
    for(Component c: tabbedPane1.getComponents())
    {
        if (c instanceof JLabel) 
        {
            labelString = ((JLabel)c).getText();
        } 
        else if (c instanceof JTextField) 
        {
            textFieldString = ((JTextField)c).getText();
        }
        // ...
    }        
}

Что делает WR.Write() ?

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.