Пример #1
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    File f = new File("Data.txt");

    try {

      textArea.setText("");
      reader = new BufferedReader(new FileReader(f));

      String str = "";
      while (!(str = reader.readLine()).equals("")) {
        textArea.append(str + "\n");
      }
      reader.close();

    } catch (Exception e) {
      System.out.println(e);
    }

    repaint();
  }
 // called by the Client to append text in the TextArea
 void append(String str) {
   chatArea.append(str);
   chatArea.setCaretPosition(chatArea.getText().length() - 1);
 }