Output not getting redirecting to proper Jtextarea

前端 未结 1 323
南笙
南笙 2021-01-27 02:36
MainFrame.java

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.GridLayout;
import java.awt.ev         


        
1条回答
  •  醉梦人生
    2021-01-27 03:18

    In JumpHosts:

    TextPanel textPanel = new TextPanel();

    you create an instance of TextPanel which is referenced by no other object in the program. This is not either of the TextPanels you created in MainFrame.

    You need to pass the TextPanels created in MainFrame, namely:

    private TextPanel textPanel;
    private TextPanel textPanel2;
    

    into your JumpHosts constructor:

    JumpHosts(TextPanel textPanel1, TextPanel textPanel2)

    to be able to reference the same TextPanel as MainFrame does.

    Response to Followup: You will need to pass your TextPanel first to your FormPanel constructor from within your MainFrame constructor. You will then need to modify your FormPanel contructor to pass the TextPanel to your JumpHosts constructor.

    0 讨论(0)
提交回复
热议问题