Guest User

Untitled

a guest
Oct 18th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. private JTextArea text;
  2. private JScrollPane scroll;
  3.  
  4. text = new JTextArea(15, 50);
  5. text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, text.getFont().getSize()));
  6. text.setEditable(false);
  7.  
  8. scroll = new JScrollPane(text);
  9. scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  10.  
  11. public void updateText(final String value) {
  12. if (text != null) {
  13. DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  14. Date date = new Date();
  15.  
  16. text.append(dateFormat.format(date) + " " + value + "n");
  17.  
  18. JScrollBar vertical = scroll.getVerticalScrollBar();
  19. vertical.setValue(vertical.getMaximum());
  20. }
  21. }
Add Comment
Please, Sign In to add comment