Details about the known misuse from the MUBench dataset.
| Description: | Creates swing UI component on the main thread.
|
| Fix Description: |
Use invokeLater() to displatch UI creation to the EDT.
|
| Violation Types: |
- missing/condition/environment
|
| In File: | CreateUI.java |
| In Method: | main(String[]) |
| Code with Misuse: |
class CreateUI {
public static void main(String[] args) {
JFrame f = new JFrame("Main Window");
// add components
f.pack();
f.setVisible(true);
}
}
|
| Code with Pattern(s): |
public class RunOnEDT {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame("Main Window");
// add components
f.pack();
f.setVisible(true);
}
});
}
}
|