내 새로 고침 및 새로 고침 메서드로 인해 새 창 jpanel이 표시됩니다. 내 텍스트 영역이 동일한 창에서 업데이트되기를 원합니다. 나는 내가 옳은 jpanel을 부를 것이라고 생각하지 않는다. 이 문제를 어떻게 해결할 수 있습니까? 또한 새로운 창을 만드는 이유는 무엇입니까?java gui textarea가 올바르게 업데이트되지 않습니다.
public static void main(String[] args) {
MPUComp frame = new MPUComp();
frame.setVisible(true);
}
public MPUComp() {
setTitle("Mpu Finder");
ImageIcon LoadIco = new ImageIcon(getClass().getResource("load.png"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 799, 680);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
btnFind1.setBounds(250, 27, 68, 23);
contentPane.add(btnFind1);
btnLoadMpu.setBounds(328, 27, 36, 22);
btnLoadMpu.setIcon(LoadIco);
contentPane.add(btnLoadMpu);
btnFind2.setBounds(642, 27, 68, 23);
contentPane.add(btnFind2);
btnLoadMpu2.setBounds(720, 28, 36, 22);
btnLoadMpu2.setIcon(LoadIco);
contentPane.add(btnLoadMpu2);
menu();
}
public void refresh(String pane1) {
textArea_1.append(pane1 + "\n");
contentPane.revalidate();
contentPane.repaint();
setVisible(true);
}
public void refresh2(String pane1) {
textArea_2.append(pane1 + "\n");
contentPane.revalidate();
contentPane.repaint();
setVisible(true);
}
전체 소스 코드를 올리십시오. 당신이 제공 한 것은'refresh' 메소드를 전혀 호출하지 않습니다 – mbatchkarov