GUI 클래스 (JButton이 GUI 클래스에서 호출)에 두 개의 GUI GUI (주 JFrame을 렌더)와 인쇄 클래스가 있습니다. 이제 내 GUI 클래스에 내가 가지고 JTextArea에 및 방법 :정적이 아닌 변수를 할당하는 정적 메서드
void setOutput(String data)
{
// output is JTextArea
output.setText(data);
}
데이터가 난 액션 청취자와의 JButton을 가지고있는 인쇄 JFrame의를 제공하지만 :
sizOpt.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent event)
{
// textfield is a JTextField component
String data = textfield.getText();
// My problem is here i need to invoke the setOutput
// method in GUI to output the string however i cant call that method in
// any way but making it static or calling new GUI which will create a new
// Instance of GUI class
GUI.setOutput(data);
}
});
그래서 ... 질문이 뭐니? Ah OK 죄송합니다. 실제로 코드 샘플의 주석에 실제 질문을 넣어서는 안됩니다. –
죄송합니다. 오전 5시에 눈이 피로 해지고 내 마음이 깨지기 시작합니다. –