Ignore:
Timestamp:
2013-05-09T22:04:25+02:00 (11 years ago)
Author:
zverik
Message:

[josm_geochat] fixed autoscroll

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/geochat/src/geochat/ChatPaneManager.java

    r29571 r29574  
    7272    }
    7373
    74     public void addLineToChatPane( String userName, String line ) {
     74    private void addLineToChatPane( String userName, String line, boolean italic ) {
    7575        if( line.length() == 0 )
    7676            return;
     
    8181        Document doc = chatPanes.get(userName).pane.getDocument();
    8282        try {
    83             doc.insertString(doc.getLength(), line, null);
    84         } catch( BadLocationException ex ) {
    85             // whatever
    86         }
    87     }
    88 
    89     public void addLineToPublic( String line ) {
    90         addLineToChatPane(PUBLIC_PANE, line);
    91     }
    92 
    93     /**
    94      * Special case: the line contains username, so it must be highlighted.
    95      */
    96     public void addLineToPublicEm( String line ) {
    97         if( !line.startsWith("\n") )
    98             line = "\n" + line;
    99         Document doc = chatPanes.get(PUBLIC_PANE).pane.getDocument();
    100         try {
    101             SimpleAttributeSet attrs = new SimpleAttributeSet();
    102             StyleConstants.setItalic(attrs, true);
     83            SimpleAttributeSet attrs = null;
     84            if( italic ) {
     85                attrs = new SimpleAttributeSet();
     86                StyleConstants.setItalic(attrs, true);
     87            }
    10388            doc.insertString(doc.getLength(), line, attrs);
    10489        } catch( BadLocationException ex ) {
    10590            // whatever
    10691        }
     92        chatPanes.get(userName).pane.setCaretPosition(doc.getLength());
     93    }
     94
     95    public void addLineToChatPane( String userName, String line ) {
     96        addLineToChatPane(userName, line, false);
     97    }
     98
     99    public void addLineToPublic( String line ) {
     100        addLineToChatPane(PUBLIC_PANE, line);
    107101    }
    108102
     
    140134        Font font = chatPane.getFont();
    141135        chatPane.setFont(font.deriveFont(font.getSize2D() - 2));
    142         DefaultCaret caret = (DefaultCaret)chatPane.getCaret();
    143         caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
     136//        DefaultCaret caret = (DefaultCaret)chatPane.getCaret(); // does not work
     137//        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    144138        JScrollPane scrollPane = new JScrollPane(chatPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    145139        chatPane.addMouseListener(new GeoChatPopupAdapter(panel));
Note: See TracChangeset for help on using the changeset viewer.