Changeset 10617 in josm for trunk


Ignore:
Timestamp:
2016-07-23T22:09:41+02:00 (8 years ago)
Author:
Don-vip
Message:

remove unused code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/jdesktop/swinghelper/debug/CheckThreadViolationRepaintManager.java

    r4728 r10617  
    1919import java.lang.ref.WeakReference;
    2020
    21 import javax.swing.JButton;
    2221import javax.swing.JComponent;
    23 import javax.swing.JEditorPane;
    24 import javax.swing.JFrame;
    2522import javax.swing.RepaintManager;
    2623import javax.swing.SwingUtilities;
     
    5249    public CheckThreadViolationRepaintManager() {
    5350        this(true);
    54     }
    55 
    56     public boolean isCompleteCheck() {
    57         return completeCheck;
    58     }
    59 
    60     public void setCompleteCheck(boolean completeCheck) {
    61         this.completeCheck = completeCheck;
    6251    }
    6352
     
    10594            if (lastComponent != null && c == lastComponent.get())
    10695                return;
    107             lastComponent = new WeakReference<JComponent>(c);
     96            lastComponent = new WeakReference<>(c);
    10897            violationFound(c, stackTrace);
    10998        }
     
    118107        }
    119108    }
    120 
    121     public static void main(String[] args) throws Exception {
    122         //set CheckThreadViolationRepaintManager
    123         RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
    124         //Valid code
    125         SwingUtilities.invokeAndWait(new Runnable() {
    126             public void run() {
    127                 test();
    128             }
    129         });
    130         System.out.println("Valid code passed...");
    131         repaintTest();
    132         System.out.println("Repaint test - correct code");
    133         //Invalide code (stack trace expected)
    134         test();
    135     }
    136 
    137     static void test() {
    138         JFrame frame = new JFrame("Am I on EDT?");
    139         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    140         frame.add(new JButton("JButton"));
    141         frame.pack();
    142         frame.setVisible(true);
    143         frame.dispose();
    144     }
    145 
    146     //this test must pass
    147     static void imageUpdateTest() {
    148         JFrame frame = new JFrame();
    149         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    150         JEditorPane editor = new JEditorPane();
    151         frame.setContentPane(editor);
    152         editor.setContentType("text/html");
    153         //it works with no valid image as well
    154         editor.setText("<html><img src=\"file:\\lala.png\"></html>");
    155         frame.setSize(300, 200);
    156         frame.setVisible(true);
    157     }
    158 
    159     private static JButton test;
    160     static void repaintTest() {
    161         try {
    162             SwingUtilities.invokeAndWait(new Runnable() {
    163                 public void run() {
    164                     test = new JButton();
    165                     test.setSize(100, 100);
    166                 }
    167             });
    168         } catch (Exception e) {
    169             e.printStackTrace();
    170         }
    171         // repaint(Rectangle) should be ok
    172         test.repaint(test.getBounds());
    173         test.repaint(0, 0, 100, 100);
    174         test.repaint();
    175     }
    176109}
Note: See TracChangeset for help on using the changeset viewer.