Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private JTextArea text;
- private JScrollPane scroll;
- text = new JTextArea(15, 50);
- text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, text.getFont().getSize()));
- text.setEditable(false);
- scroll = new JScrollPane(text);
- scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- public void updateText(final String value) {
- if (text != null) {
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- Date date = new Date();
- text.append(dateFormat.format(date) + " " + value + "n");
- JScrollBar vertical = scroll.getVerticalScrollBar();
- vertical.setValue(vertical.getMaximum());
- }
- }
Add Comment
Please, Sign In to add comment