JTextArea.getText();



  • Hello. Somehow the method getText() doesn't work. Please tell me what the problem is. Something doesn't even googling.

    public class ClickListener implements ActionListener{
    Integer ids;
    Socket s = new Socket();
    ClientRegistrator cm = new ClientRegistrator();
    VisualFrame vf = new VisualFrame();
    String line1 = null;
    String line2 = null;
    public void variable(Socket socket, Integer id) {
        ids = id;
        s = socket;
    

    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
    try {
    DataOutputStream dout = new DataOutputStream(new BufferedOutputStream(s.getOutputStream()));
    System.out.println("OutStream on start");
    System.out.println(line1);
    System.out.println(line2);
    Thread.sleep(100);
    line1 = vf.JTA1.getText();
    line2 = vf.JTA2.getText();
    System.out.println(line1);
    System.out.println(line2);

                dout.writeUTF(line1);
                dout.writeUTF(line2);
                dout.flush();
    
            } catch (IOException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
        }
    

    }

    public class VisualFrame {
    JFrame jf = new JFrame();
    JTextArea JTA3 = new JTextArea(30, 100);
    JTextArea JTA2 = new JTextArea();
    JTextArea JTA1 = new JTextArea(12, 1);
    JScrollBar JSB = new JScrollBar();
    public void visual() {
    jf.setDefaultLookAndFeelDecorated(true);
    jf.setLayout(null);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.setSize(1500, 1500);
    jf.setVisible(true);
    ClientRegistrator cm = new ClientRegistrator();
    ModifyFrame mf = new ModifyFrame();
    JTA1.setVisible(true);
    JTA1.setBounds(515, 0, 100, 30);
    JTA1.setWrapStyleWord(true);
    JTA1.setLineWrap(true);
    JTA1.setBorder(BorderFactory.createTitledBorder(
    BorderFactory.createEtchedBorder(),
    "",
    TitledBorder.RIGHT,
    TitledBorder.BOTTOM,
    null,
    Color.blue));
    JTA2.setBounds(515, 35, 100, 100);
    JTA2.setVisible(true);
    JTA2.setBorder(BorderFactory.createTitledBorder(
    BorderFactory.createEtchedBorder(),
    "",
    TitledBorder.RIGHT,
    TitledBorder.BOTTOM,
    null,
    Color.blue));
    JTA3.setBounds(625, 0, 500, 500);
    JTA3.setVisible(true);
    JTA3.setBorder(BorderFactory.createTitledBorder(
    BorderFactory.createEtchedBorder(),
    "",
    TitledBorder.RIGHT,
    TitledBorder.BOTTOM,
    null,
    Color.blue));
    JTA3.setBackground(Color.GRAY);
    JTA2.setEditable(true);
    JTA3.setEditable(true);
    JTA2.setWrapStyleWord(true);
    JTA2.setLineWrap(true);
    JTA3.setWrapStyleWord(true);
    JTA3.setLineWrap(true);
    jf.add(JTA3);
    jf.add(JTA2);
    jf.add(JTA1);
    jf.add(cm.JCP);
    jf.repaint();

    cm.worker1();
    

    }



  • And why do you have VisualFrame created in Listener? That sounds like a problem. From@kff The problem was solved. Thank you very much for the answer.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2