Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>But what are these Swing component methods that are labelled "thread safe"?</p> </blockquote> <p>Most Swing components' methods are NOT thread safe. But some are. To find out which ones, you have no option but to peruse the javadocs for your target components. <a href="http://www.google.com/search?q=%22is+thread+safe%22+site:http://java.sun.com/javase/6/docs/api/javax/swing&amp;hl=en&amp;filter=0" rel="nofollow noreferrer">A carefully constructed google search</a> might quicken the process.</p> <blockquote> <p>Are there actually any?</p> </blockquote> <p>Yes there are indeed. Generally speaking, if you are working with Swing components, it is likely that you are going to have to invoke both thread-safe and non-thread-safe methods. Since most methods are non-thread-safe, I prefer to err on the side of caution, and perform all actions on them in a thread-safe manner anyway.</p> <p>HTH</p> <hr> <p>Not exhaustive list.</p> <p>DefaultStyledDocument:</p> <ul> <li>protected void insert(int offset, DefaultStyledDocument.ElementSpec[] data) throws BadLocationException</li> <li>public void setLogicalStyle(int pos, Style s)</li> <li>public void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)</li> <li>public void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)</li> </ul> <p>javax.swing.text.AbstractDocument:</p> <ul> <li>public void render(Runnable r)</li> <li>public void remove(int offs, int len) throws BadLocationException</li> <li>public void insertString(int offs, String str, AttributeSet a) throws BadLocationException</li> <li>public Position createPosition(int offs) throws BadLocationException</li> </ul> <p>javax.swing.undo.UndoManager:<br> Class is threadsafe</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload