/** * Convert to HTML and Calculate Size * * @param message message */ private void setInfoMessage(final String message) { final StringBuilder sb = new StringBuilder(message.length() + 20); sb.append("<b>"); String html = Util.maskHTML(message); char[] chars = html.toCharArray(); boolean first = true; int paras = 0; for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (c == '\n') { if (first) { sb.append("</b>"); first = false; } if (paras > 1) sb.append("<br>"); else sb.append("<p>"); paras++; } else sb.append(c); } info.setText(sb.toString()); Dimension size = info.getPreferredSize(); size.width = 450; size.height = (Math.max(paras, message.length() / 60) + 1) * 30; size.height = Math.min(size.height, 600); info.setPreferredSize(size); info.setRequestFocusEnabled(false); info.setReadWrite(false); info.setOpaque(false); info.setBorder(null); // info.setCaretPosition(0); } // calculateSize
/** * ************************************************************************ ActionListener * * @param e */ @Override public void actionPerformed(ActionEvent e) { // log.finest( "ADialogDialog.actionPerformed - " + e); if (e.getActionCommand().equals(ConfirmPanel.A_OK)) { m_returnCode = A_OK; dispose(); } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL) || e.getSource() == mEnd) { m_returnCode = A_CANCEL; dispose(); } else if (e.getSource() == mEMail) { String title = getTitle(); String text = info.getText(); dispose(); // otherwise locking ADialog.createSupportEMail(this, title, text); } else if (e.getSource() == mPreference) { if (Env.getUserRolePermissions().isShowPreference()) { final Preference p = new Preference(null, 0); p.setVisible(true); } } }