Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // constantly overrides the value the user types in so every second character is reverted
- protected void setComponent(final String t)
- {
- SwingUtilities.invokeLater(new Runnable(){
- @Override
- public void run()
- {
- try {
- document.remove(0,document.getLength());
- document.insertString(0,t,null);
- } catch (BadLocationException e) {
- LGM.showDefaultExceptionHandler(e);
- }
- }
- });
- }
- // errors like a mother and so does invokeAndWait which complains about not be allowed to be called from the Event Dispatch Thread
- private void setComponentUnsafe(String t) {
- try {
- document.remove(0,document.getLength());
- document.insertString(0,t,null);
- } catch (BadLocationException e) {
- LGM.showDefaultExceptionHandler(e);
- }
- }
- protected void setComponent(final String t)
- {
- if (!SwingUtilities.isEventDispatchThread()) {
- SwingUtilities.invokeLater(new Runnable(){
- @Override
- public void run()
- {
- setComponentUnsafe(t);
- }
- });
- } else {
- setComponentUnsafe(t);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement