コード例 #1
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
  @Override
  public void focusGained(final FocusEvent e) {
    final JTextComponent component = getComponent();
    if (!component.isEnabled() || !component.isEditable()) {
      super.focusGained(e);
      return;
    }

    mFocused = true;
    if (!shouldSelectAllOnFocus) {
      shouldSelectAllOnFocus = true;
      super.focusGained(e);
      return;
    }

    if (isMultiLineEditor) {
      super.focusGained(e);
      return;
    }

    final int end = component.getDocument().getLength();
    final int dot = getDot();
    final int mark = getMark();
    if (dot == mark) {
      if (dot == 0) {
        component.setCaretPosition(end);
        component.moveCaretPosition(0);
      } else if (dot == end) {
        component.setCaretPosition(0);
        component.moveCaretPosition(end);
      }
    }

    super.focusGained(e);
  }
コード例 #2
0
    DataPanel(@NotNull Project project, boolean multiRoot, @NotNull Disposable disposable) {
      super(UIUtil.HTML_MIME, "");
      myProject = project;
      myMultiRoot = multiRoot;
      setEditable(false);
      setOpaque(false);
      putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

      EditorColorsManager.getInstance()
          .addEditorColorsListener(
              new EditorColorsAdapter() {
                @Override
                public void globalSchemeChange(EditorColorsScheme scheme) {
                  update();
                }
              },
              disposable);

      DefaultCaret caret = (DefaultCaret) getCaret();
      caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

      addHyperlinkListener(
          new HyperlinkListener() {
            public void hyperlinkUpdate(HyperlinkEvent e) {
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED
                  && SHOW_OR_HIDE_BRANCHES.equals(e.getDescription())) {
                myExpanded = !myExpanded;
                update();
              } else {
                BrowserHyperlinkListener.INSTANCE.hyperlinkUpdate(e);
              }
            }
          });
    }
コード例 #3
0
  public PrinterStatusPanel(Executor exe) {
    this.exe = exe;
    myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.PAGE_AXIS));
    myPanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.black), "Printer Status"));

    // Temperature plot
    tempPanel = new TemperaturePanel(exe);

    // Text Area for Log Messages
    statusText.setEditable(false);
    statusText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, FONT_SIZE));
    statusText.setLineWrap(false);
    statusText.setText(OFFLINE_MESSAGE);
    final DefaultCaret caret = (DefaultCaret) statusText.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    scrollPane = new JScrollPane(statusText);
    scrollPane.setViewportView(statusText);

    final JSplitPane splitPane =
        new JSplitPane(JSplitPane.VERTICAL_SPLIT, tempPanel.getPanel(), scrollPane);
    splitPane.setDividerLocation(300);
    myPanel.add(splitPane);
    GuiAppender.setTextArea(statusText);
  }
コード例 #4
0
ファイル: GameWindow.java プロジェクト: WaffeFIN/WaffeGame2
  public GameWindow(GraphicalUI ui) {
    this.ui = ui;
    this.cardButtonMap = new HashMap();

    initComponents();
    DefaultCaret caret = (DefaultCaret) jTextAreaOutput.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    setup();
  }
コード例 #5
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frmAplicacaoHospital = new JFrame();
    frmAplicacaoHospital.setTitle("Aplicacao Hospital");
    frmAplicacaoHospital.setBounds(100, 100, 800, 400);
    frmAplicacaoHospital.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    GroupLayout groupLayout = new GroupLayout(frmAplicacaoHospital.getContentPane());
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addComponent(
                panel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE));
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addComponent(
                        panel, GroupLayout.PREFERRED_SIZE, 355, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    JScrollPane scrollPane = new JScrollPane();
    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_panel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 764, Short.MAX_VALUE)
                    .addContainerGap()));
    gl_panel.setVerticalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_panel
                    .createSequentialGroup()
                    .addGap(35)
                    .addComponent(
                        scrollPane, GroupLayout.PREFERRED_SIZE, 283, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(37, Short.MAX_VALUE)));

    textArea = new JTextArea();
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    scrollPane.setViewportView(textArea);
    panel.setLayout(gl_panel);
    frmAplicacaoHospital.getContentPane().setLayout(groupLayout);
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    try {
      app = new AplicacaoHospital(this);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #6
0
ファイル: DrawbotGUI.java プロジェクト: bertbalcaen/DrawBot
  public Container CreateContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // the log panel
    log = new JTextPane();
    log.setEditable(false);
    log.setBackground(Color.BLACK);
    logPane = new JScrollPane(log);
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    log.setEditorKit(kit);
    log.setDocument(doc);
    DefaultCaret c = (DefaultCaret) log.getCaret();
    c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ClearLog();

    // the preview panel
    previewPane = new DrawPanel();
    previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);

    // status bar
    statusBar = new StatusBar();
    Font f = statusBar.getFont();
    statusBar.setFont(f.deriveFont(Font.BOLD, 15));
    Dimension d = statusBar.getMinimumSize();
    d.setSize(d.getWidth(), d.getHeight() + 30);
    statusBar.setMinimumSize(d);

    // layout
    Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT);
    split.add(previewPane);
    split.add(logPane);
    split.setDividerSize(8);

    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(split, BorderLayout.CENTER);

    // open the file
    if (recentFiles[0].length() > 0) {
      OpenFileOnDemand(recentFiles[0]);
    }

    // connect to the last port
    ListSerialPorts();
    if (Arrays.asList(portsDetected).contains(recentPort)) {
      OpenPort(recentPort);
    }

    return contentPane;
  }
コード例 #7
0
 @Override
 public void addContent() {
   consolePane = new JTextArea();
   consolePane.setBackground(panelColor);
   consolePane.setForeground(Color.white);
   consolePane.setEditable(false);
   PrintStream out = new PrintStream(new TextAreaOutputStream(consolePane));
   System.setOut(out);
   System.setErr(out);
   scrollPane = new JScrollPane(consolePane);
   DefaultCaret caret = (DefaultCaret) consolePane.getCaret();
   caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
   this.add(scrollPane, BorderLayout.CENTER);
 }
コード例 #8
0
  /**
   * @param codep
   * @return
   */
  protected Caret installCaret(CodePoint codep) {
    // The caret will track the positions across the users' editings.
    final DefaultCaret place = new DefaultCaret();
    place.setUpdatePolicy(DefaultCaret.UPDATE_WHEN_ON_EDT);
    place.install(txtEditor);
    // remove mouse listeners from component, since we don't want the mouse to modify our caret
    txtEditor.removeMouseListener(place);
    txtEditor.removeMouseMotionListener(place);
    txtEditor.removeFocusListener(place);
    // configure visibility and set proper positions
    place.setVisible(false);
    place.setSelectionVisible(false);
    place.setDot(codep.y);
    place.moveDot(codep.x);
    log.info("Installed Caret for " + codep);
    place.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            log.fine(e.getSource() + " at " + e.toString());
            // when the caret changes, update the display
            updateName();
          }
        });
    return place;
  }
コード例 #9
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
  @Override
  protected void fireStateChanged() {
    // If we have focus the caret should only flash if the range length is zero
    if (mFocused) setVisible(getComponent().isEditable());

    super.fireStateChanged();
  }
コード例 #10
0
ファイル: VCaretEntry.java プロジェクト: timburrow/OpenVnmrJ
 public void focusGained(FocusEvent e) {
   inModalMode = true;
   if (debug) System.out.println("gained focus");
   setBlinkRate(500);
   // setCaretValue(caretValue);
   super.focusGained(e);
 }
コード例 #11
0
 /** {@inheritDoc} */
 public void paint(Graphics g) {
   if (isVisible() && overwriteMode) {
     Rectangle r = null;
     int pos = editor.getCaretPosition();
     try {
       r = editor.modelToView(pos);
     } catch (BadLocationException e) {
     }
     if (r != null && (r.width != 0 || r.height != 0)) {
       if ((x != r.x) || (y != r.y)) {
         repaint();
         x = r.x;
         y = r.y;
         height = r.height;
         width = editor.getFontMetrics(editor.getFont()).charWidth('W') + 1;
       } else {
         g.setColor(editor.getCaretColor());
         g.setXORMode(editor.getBackground());
         g.fillRect(x, y, width, height);
       }
     }
   } else {
     super.paint(g);
   }
 }
コード例 #12
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 // This fixes the problem where when on the mac you have to ctrl left click to
 // get popup triggers the caret has code that only looks at button number.
 // see radar # 3125390
 @Override
 public void mousePressed(final MouseEvent e) {
   if (!e.isPopupTrigger()) {
     super.mousePressed(e);
     shouldSelectAllOnFocus = false;
   }
 }
コード例 #13
0
ファイル: Consola.java プロジェクト: jaymdq/Evolutiva
 public Consola() {
   text = new WebTextArea();
   // false para que pueda escribir para la derecha.
   text.setLineWrap(false);
   text.setWrapStyleWord(true);
   text.setMargin(5);
   text.setFont(new Font("monospaced", Font.PLAIN, 16));
   text.setEditable(false);
   text.setDoubleBuffered(true);
   text.setSelectionColor(Color.YELLOW);
   scroll = new WebScrollPane(text, false, true);
   scroll.setPreferredSize(null);
   // Hacer que baje el documento a medida que se escribe
   DefaultCaret caret = (DefaultCaret) text.getCaret();
   caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
 }
コード例 #14
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 // See <rdar://problem/3833837> 1.4.2_05-141.3: JTextField performance with
 // Aqua L&F. We are getting into a circular condition with the BasicCaret
 // paint code since it doesn't know about the fact that our damage routine
 // above elminates the border. Sadly we can't easily change either one, so
 // we will add a painting flag and not damage during a repaint.
 @Override
 public void paint(final Graphics g) {
   if (isVisible()) {
     fPainting = true;
     super.paint(g);
     fPainting = false;
   }
 }
コード例 #15
0
ファイル: Debugger.java プロジェクト: koonem/RSBot
 public Debugger() {
   super("Debug console");
   debugField = new JTextArea();
   debugField.setEditable(false);
   debugField.setLineWrap(true);
   debugField.setFont(new Font("Arial", Font.PLAIN, 14));
   DefaultCaret c = ((DefaultCaret) debugField.getCaret());
   c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
   jps = new JScrollPane(debugField);
   add(jps);
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   setSize((int) d.getHeight(), (int) d.getWidth());
   setLocation(0, 0);
   setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   pack();
   setVisible(true);
 }
コード例 #16
0
ファイル: ChatArea.java プロジェクト: JoshuaEN/SEN632
  protected void textAreaAction(ActionEvent e) {
    JScrollBar scrollBar = textAreaScrollPane.getVerticalScrollBar();
    int extent = scrollBar.getModel().getExtent();
    boolean atBottom = scrollBar.getValue() + extent == scrollBar.getMaximum();

    if (atBottom) {
      caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    } else {
      caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    if (mainWindow.notifyTextEntered(ChatArea.this, e.getActionCommand())) {
      appendText(
          "%s > %s%n",
          (mainWindow != null ? mainWindow.getChatDisplayName() : ""), e.getActionCommand());
      textField.setText("");
    }
  }
コード例 #17
0
  public ProgressDialog(RuntimeGUI parent) {
    super(parent.myService.getFrame(), "new components");
    this.parent = parent;
    Container display = getContentPane();

    // north
    JPanel north = new JPanel();
    display.add(north, BorderLayout.NORTH);

    spinner = new JLabel();
    north.add(spinner);

    actionText = new JLabel("");
    north.add(actionText);

    // center
    reportArea = new JTextArea("details\n", 5, 10);
    reportArea.setLineWrap(true);
    reportArea.setEditable(false);
    reportArea.setBackground(SystemColor.control);

    scrollPane = new JScrollPane(reportArea);
    DefaultCaret caret = (DefaultCaret) reportArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    display.add(scrollPane, BorderLayout.CENTER);

    // south
    JPanel south = new JPanel();
    display.add(south, BorderLayout.SOUTH);
    okToUpdates.addActionListener(this);
    cancel.addActionListener(this);
    restart.addActionListener(this);
    noWorky.addActionListener(this);
    hideButtons();
    south.add(okToUpdates);
    south.add(cancel);
    south.add(restart);
    south.add(noWorky);
    south.add(buttonText);
    // setPreferredSize(new Dimension(350, 300));
    setSize(320, 300);
  }
コード例 #18
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 @Override
 public void focusLost(final FocusEvent e) {
   mFocused = false;
   shouldSelectAllOnFocus = true;
   if (isMultiLineEditor) {
     setVisible(false);
     getComponent().repaint();
   } else {
     super.focusLost(e);
   }
 }
コード例 #19
0
ファイル: ChatGUI.java プロジェクト: Ayoubane/chatsystem-og
  /**
   * Creates a new ChatGUI form
   *
   * @param gui
   */
  public ChatGUI(final GUI gui) {
    this.gui = gui;
    initComponents();
    // JTextArea automatically updates to scroll down ;)
    DefaultCaret caret = (DefaultCaret) jTextPane1.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    listSelectionListener =
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent listSelectionEvent) {
            try {
              gui.setRemoteIpAdress(jList1.getSelectedValue().toString());
              String username = jList1.getSelectedValue().toString();
              String[] ipadress = username.split("@");
              jLabel2.setText(ipadress[1]);
            } catch (UnknownHostException ex) {
              Logger.getLogger(ChatGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        };
    jList1.addListSelectionListener(listSelectionListener);
  }
コード例 #20
0
  /** Build the interface. */
  private void buildUI() {
    if (colorEnabled) {
      JTextPane text = new JTextPane();
      this.textComponent = text;
    } else {
      JTextArea text = new JTextArea();
      this.textComponent = text;
      text.setLineWrap(true);
    }
    textComponent.addMouseListener(this);
    textComponent.setFont(getMonospaceFont());
    textComponent.setEditable(false);
    DefaultCaret caret = (DefaultCaret) textComponent.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    document = textComponent.getDocument();
    document.addDocumentListener(new LimitLinesDocumentListener(numLines, true));

    JScrollPane scrollText = new JScrollPane(textComponent);
    scrollText.setBorder(null);
    scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    add(scrollText, BorderLayout.CENTER);
  }
コード例 #21
0
  /** {@inheritDoc} */
  protected synchronized void damage(Rectangle r) {
    if (overwriteMode) {
      if (r == null) {
        return;
      }

      x = r.x;
      y = r.y;
      height = r.height;
      repaint();
    } else {
      super.damage(r);
    }
  }
コード例 #22
0
ファイル: VCaretEntry.java プロジェクト: timburrow/OpenVnmrJ
  private void setCaretValue(int i) {

    caret.setVisible(true);

    caretValue = i;
    int min = 0;
    int max = getText().length();

    if (i < min) i = min;
    if (i > max) i = max;

    if (debug) System.out.println("setSelectionStart: " + i);
    setSelectionStart(i);
    setSelectionEnd(i);
  }
コード例 #23
0
  public void setUpGUI() {
    main_chat_panel = new JPanel(new BorderLayout());
    main_chat_panel.setPreferredSize(new Dimension(250, 530));

    message_area_panel = new JPanel(new BorderLayout());
    message_area_panel.setBorder(new EmptyBorder(5, 5, 0, 0));

    message_area = new JTextArea();
    message_area.setEditable(false);
    message_area.setLineWrap(true);

    message_area.setBackground(Color.WHITE);

    DefaultCaret caret = (DefaultCaret) message_area.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    message_area_panel.add(new JScrollPane(message_area), BorderLayout.CENTER);

    chat_area_panel = new JPanel(new BorderLayout());
    chat_area_panel.setBorder(new EmptyBorder(3, 0, 0, 0));

    chat_area = new JTextField(50);
    chat_area.setBackground(Color.WHITE);
    chat_area.addKeyListener(this);

    send_button = new JButton("SEND");
    send_button.addActionListener(this);

    chat_area_panel.add(chat_area, BorderLayout.CENTER);
    chat_area_panel.add(send_button, BorderLayout.EAST);

    main_chat_panel.add(message_area_panel, BorderLayout.CENTER);
    main_chat_panel.add(chat_area_panel, BorderLayout.SOUTH);

    this.add(main_chat_panel);
  }
コード例 #24
0
 public LineCursorTextArea() {
   super();
   caret =
       new DefaultCaret() {
         @Override
         protected synchronized void damage(Rectangle r) {
           if (r != null) {
             JTextComponent c = getComponent();
             x = 0;
             y = r.y;
             width = c.getSize().width;
             height = r.height;
             c.repaint();
           }
         }
       };
   caret.setBlinkRate(getCaret().getBlinkRate());
   setCaret(caret);
 }
コード例 #25
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 /** Only show the flashing caret if the selection range is zero */
 @Override
 public void setVisible(boolean e) {
   if (e) e = getDot() == getMark();
   super.setVisible(e);
 }
コード例 #26
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 @Override
 public void deinstall(final JTextComponent c) {
   c.removePropertyChangeListener(this);
   super.deinstall(c);
 }
コード例 #27
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 @Override
 public void install(final JTextComponent c) {
   super.install(c);
   isMultiLineEditor = c instanceof JTextArea || c instanceof JEditorPane;
   c.addPropertyChangeListener(this);
 }
コード例 #28
0
ファイル: ChatClient.java プロジェクト: bierus/Chat
  public ChatClient(String n) {
    super(n + "'s Client");
    name = n;

    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    this.addWindowListener(this);

    setSize(545, 345);

    JPanel panel = new JPanel();

    panel.add(active);
    panel.add(activelist);

    scrollactive.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollactive.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollactive.setViewportView(activelist);
    panel.add(scrollactive);

    activelist.addListSelectionListener(
        e -> {
          selectedIndex = activelist.getSelectedIndex();
          System.out.println(selectedIndex);
        });

    panel.add(history);

    JScrollPane scroll_bars =
        new JScrollPane(
            history,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    panel.add(scroll_bars);
    panel.add(msglab);
    panel.add(message);

    history.setEditable(false);

    DefaultCaret caret = (DefaultCaret) history.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    message.addActionListener(
        e -> {
          try {
            output = new PrintWriter(s.getOutputStream(), true);
          } catch (Exception e1) {

            e1.printStackTrace();
          }

          String tmp = message.getText();
          if (!tmp.equals("")) {
            if (!activelist.isSelectionEmpty()) {
              output.println("@#$PW@#$");
              output.println(selectedIndex);
              output.println(name + ": " + tmp);
              history.append("(PW) " + name + ": " + tmp + "\n");
            } else {
              output.println(name + ": " + tmp);
            }
          }

          message.setText("");
        });

    String[] test = {"Anonymous", "Anonymous"};
    activelist.setListData(test);

    this.setContentPane(panel);

    Thread t = new Thread(this);
    t.start();

    setVisible(true);
  }
コード例 #29
0
ファイル: Console.java プロジェクト: pitnice/myrobotlab
 public Console() { // TODO boolean JFrame or component
   textArea = new JTextArea();
   scrollPane = new JScrollPane(textArea);
   DefaultCaret caret = (DefaultCaret) textArea.getCaret();
   caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
 }
コード例 #30
0
ファイル: DialogMessageLogger.java プロジェクト: kullen/MRI
  /**
   * Construct the GUI for a logger.
   *
   * @param titleMessage for the title bar of the dialog box
   * @param width initial width of the resizeable dialog box
   * @param height initial height of the resizeable dialog box
   * @param exitApplicationOnClose if true, when the dialog box is closed (X-d out), will exit the
   *     application with success status
   * @param visible if true, will be made visible after construction
   */
  protected void createGUI(
      String titleMessage, int width, int height, boolean exitApplicationOnClose, boolean visible) {
    Border panelBorder = BorderFactory.createEtchedBorder();

    outputTextArea = new JTextArea();
    {
      // if one does not do this, the default behavior is scroll to end when append() on event
      // disptaching thread, but not from other threads
      Caret caret = outputTextArea.getCaret();
      if (caret != null && caret instanceof DefaultCaret) {
        ((DefaultCaret) caret)
            .setUpdatePolicy(
                DefaultCaret
                    .ALWAYS_UPDATE); // i.e. jump to end after append() regardless of whether in
                                     // same thread or not
      }
    }
    outputScrollPane = new JScrollPane(outputTextArea);
    outputScrollPane.setBorder(panelBorder);

    outputDialog = new JDialog();
    // outputDialog.setSize(width,height);
    outputDialog.setPreferredSize(new Dimension(width, height));
    outputDialog.setTitle(titleMessage);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.setBorder(panelBorder);

    JButton clearButton = new JButton("Clear");
    clearButton.setToolTipText("Clear log");
    buttonPanel.add(clearButton);
    clearButton.addActionListener(new ClearActionListener());

    Container mainPanel = outputDialog.getContentPane();
    {
      GridBagLayout mainPanelLayout = new GridBagLayout();
      mainPanel.setLayout(mainPanelLayout);
      {
        GridBagConstraints outputScrollPaneConstraints = new GridBagConstraints();
        outputScrollPaneConstraints.gridx = 0;
        outputScrollPaneConstraints.gridy = 0;
        outputScrollPaneConstraints.weightx = 1;
        outputScrollPaneConstraints.weighty = 1;
        outputScrollPaneConstraints.fill = GridBagConstraints.BOTH;
        mainPanelLayout.setConstraints(outputScrollPane, outputScrollPaneConstraints);
        mainPanel.add(outputScrollPane);
      }
      {
        GridBagConstraints buttonPanelConstraints = new GridBagConstraints();
        buttonPanelConstraints.gridx = 0;
        buttonPanelConstraints.gridy = 1;
        buttonPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
        mainPanelLayout.setConstraints(buttonPanel, buttonPanelConstraints);
        mainPanel.add(buttonPanel);
      }
    }

    outputDialog.pack();
    outputDialog.setVisible(visible);

    if (exitApplicationOnClose) {
      // Note that unlike for JFrame, EXIT_ON_CLOSE is NOT a valid value to pass to
      // setDefaultCloseOperation(), so have to do this with WindowListener
      outputDialog.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              // System.err.println("DialogMessageLogger.WindowAdapter.windowClosing()");
              // dispose();
              System.exit(0);
            }
          });
    }
  }