Question

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;
}
Was it helpful?

Solution

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top