public JFrame getFrame() { // Check if we've created the frame and do so if not if (frame == null) { log.debug("Creating frame for console"); // To avoid possible locks, frame layout should be // performed on the Swing thread if (SwingUtilities.isEventDispatchThread()) { createFrame(); } else { try { // Use invokeAndWait method as we don't want to // return until the frame layout is completed SwingUtilities.invokeAndWait(this::createFrame); } catch (InterruptedException | InvocationTargetException ex) { log.error("Exception creating system console frame: " + ex); } } log.debug("Frame created"); } return frame; }