我有兩個JFrames A和B. B有一個textArea。我想 添加一些文字在B中的TextArea點擊這裏A.一個按鈕是我的代碼:如何通過另一個JFrame修改JFrame?
JButton btn = new JButton("Text");
btnButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
b.textArea.setText("Button clicked");
}
});
btnButton_1.setBounds(10, 45, 89, 23);
frmA.getContentPane().add(btnButton_1);
- b爲B類的對象
- textarea裏的JTextArea變量名B級
嘗試調用'重繪()''中添加B'文本到JTextArea中 – 2014-10-27 11:50:54
不重繪anythign,爲更好地幫助越早張貼SSCCE後/ MCVE短,可運行,編譯 – mKorbel 2014-10-27 11:51:32
也可以使用b。 textArea.append(「你的文字」); – AJJ 2014-10-27 12:00:43