CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Threaded View

  1. #1
    Join Date
    Feb 2010
    Posts
    121

    Controlling the display of text in a JTextField

    I have the following routine:

    Code:
      private void getEngineOutput(Process engine) {
        try {
          BufferedReader reader =
            new BufferedReader(new InputStreamReader(engine.getInputStream()), 1);
          String lineRead = null;
          while((lineRead = reader.readLine()) != null) {
        	
            textArea.append(lineRead);
            textArea.append("\n");
            textArea.setCaretPosition(textArea.getDocument().getLength() - 0);
            System.out.println(lineRead);
    
          }
        
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
    It produces lines of data as follows:

    Code:
    	5     31       0   2250  1. e4 Nc6 2. Nc3 Nf6 3. d4
    	5     31       0   2853  1. e4 Nc6 2. Nc3 Nf6 3. d4
    	6      9       0   3192  1. e4 Nc6 2. Nc3 Nf6 3. d4 Bd6
    	6      9       2   4298  1. e4 Nc6 2. Nc3 Nf6 3. d4 Bd6
    	7     49       2   6336  1. e4!
    Is it possible to 'reverse' the output routine so that data outputs/prints at the top of the JTextField as opposed to outputting at the bottom? Using the above, I would like the data to print out as follows...

    Code:
    	7     49       2   6336  1. e4!
    	6      9       2   4298  1. e4 Nc6 2. Nc3 Nf6 3. d4 Bd6
    	6      9       0   3192  1. e4 Nc6 2. Nc3 Nf6 3. d4 Bd6
    	5     31       0   2853  1. e4 Nc6 2. Nc3 Nf6 3. d4
    	5     31       0   2250  1. e4 Nc6 2. Nc3 Nf6 3. d4
    Last edited by peahead; July 27th, 2011 at 02:52 PM. Reason: typo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured