سؤال

I have one JFrame and it has one JTextArea.Now I want set text for this JTextArea to show some infomation.I use MVC with pure entity model.Can I use this function in this JFrame class

 public JTextArea getTxaTicket() {
    return txaTicket;
}

public void setTxaTicket(JTextArea txaTicket) {
    this.txaTicket = txaTicket;
}
هل كانت مفيدة؟

المحلول

I really think you should set and get only the content of the JTextArea. Not the JTextArea it self.

public String getTxaTicket() {
    return txaTicket.getText();
}

public void setTxaTicket(String txaTicket) {
    this.txaTicket.setText(txaTicket);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top