List of usage examples for javax.swing JTextPane setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:op.FrmMain.java
public void afterLogin() { OPDE.getDisplayManager().touch();/*from ww w . j ava2 s.c o m*/ dlgLogin = null; if (OPDE.isTraining()) { JTextPane txtMessage = new JTextPane(); txtMessage.setFont(new Font("Arial", Font.PLAIN, 18)); txtMessage.setEditable(false); txtMessage.setContentType("text/html"); txtMessage.setText(SYSTools.toHTMLForScreen(SYSTools.xx("opde.general.training.version.message"))); JOptionPane.showConfirmDialog(this, txtMessage, SYSTools.xx("opde.general.training.version.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); } if (specialities != null) { synchronized (specialities) { SYSTools.clear(specialities); } } specialities = Collections.synchronizedMap(new HashMap<Integer, Set<Resident>>()); synchronized (specialities) { specialities.put(ResInfoTypeTools.TYPE_ABSENCE, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_INFECTION, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_WARNING, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_ALLERGY, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_DIABETES, new HashSet<Resident>()); for (ResInfo info : ResInfoTools.getSpecialInfos()) { specialities.get(info.getResInfoType().getType()).add(info.getResident()); } } prepareSearchArea(); labelUSER.setText(OPDE.getLogin().getUser().getFullname()); Runnable runnable = new Runnable() { @Override public void run() { initPhase = true; double pos; try { pos = Double.parseDouble( OPDE.getProps().getProperty("opde.mainframe:splitPaneLeftDividerLocation")); } catch (Exception e) { pos = 0.5d; } splitPaneLeft.setDividerLocation(0, SYSTools.getDividerInAbsolutePosition(splitPaneLeft, pos)); initPhase = false; homeButton.doClick(); } }; SwingUtilities.invokeLater(runnable); }
From source file:org.cagrid.installer.steps.PresentLicenseStep.java
public void init(WizardModel m) { this.model = (CaGridInstallerModel) m; setLayout(new BorderLayout()); setSize(new Dimension(475, 161)); JPanel licensePanel = new JPanel(); licensePanel.setBackground(Color.WHITE); JTextPane textPane = new JTextPane(); licensePanel.add(textPane);/*from w ww . j a v a2 s . c o m*/ JScrollPane scrollPane = new JScrollPane(licensePanel); scrollPane.setPreferredSize(new Dimension(475, 150)); add(scrollPane, BorderLayout.CENTER); try { StringBuilder sb = new StringBuilder(); BufferedReader r = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream("/cagrid_license.txt"))); String line = null; while ((line = r.readLine()) != null) { sb.append(line).append("\n"); } textPane.setText(sb.toString()); textPane.setFont(textPane.getFont().deriveFont((float) 10)); } catch (Exception ex) { String msg = "Error loading license: " + ex.getMessage(); logger.error(msg, ex); JOptionPane.showMessageDialog(null, msg, this.model.getMessage("error"), JOptionPane.ERROR_MESSAGE); } JPanel controlPanel = new JPanel(); controlPanel.setLayout(new GridBagLayout()); add(controlPanel, BorderLayout.SOUTH); JLabel label = new JLabel(this.model.getMessage("accept.license")); controlPanel.add(label); JCheckBox checkBox = new JCheckBox(); checkBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { PresentLicenseStep.this.setComplete(evt.getStateChange() == ItemEvent.SELECTED); } }); controlPanel.add(checkBox); }
From source file:org.echocat.velma.dialogs.AboutDialog.java
protected void createIntroduction(@Nonnull Resources resources) { final URL iconUrl = resources.getIconUrl(48); final StringBuilder body = new StringBuilder(); body.append("<html>"); body.append("<head><style>" + "td { margin-right: 10px; }" + "</style></head>"); body.append("<body style='font-family: sans; font-size: 1em'><table><tr>"); body.append("<td valign='top'><img src='").append(iconUrl).append("' /></td>"); body.append("<td valign='top'>"); body.append("<h2>").append(escapeHtml4(resources.getApplicationName())); final String version = resources.getVersion(); if (!isEmpty(version)) { body.append("<br/><span style='font-size: 0.6em'>") .append(resources.formatEscaped("versionText", version)).append("</span>"); }//from www . j a va 2 s .c o m body.append("</h2>"); body.append("<p>Copyright 2011-2012 <a href='https://echocat.org'>echocat</a></p>"); body.append("<p><a href='http://mozilla.org/MPL/2.0/'>") .append(resources.formatEscaped("licensedUnder", "MPL 2.0")).append("</a></p>"); body.append("<p><table cellpadding='0' cellspacing='0'>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "echocat")) .append(":</td><td><a href='https://echocat.org'>echocat.org</a></td></tr>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "Velma")) .append(":</td><td><a href='https://velma.echocat.org'>velma.echocat.org</a></td></tr>"); body.append("</table></p>"); body.append("<h4>").append(resources.formatEscaped("developers")) .append("</h4><table cellpadding='0' cellspacing='0'>"); body.append( "<tr><td>Gregor Noczinski</td><td><a href='mailto:gregor@noczinski.eu'>gregor@noczinski.eu</a></td><td><a href='https://github.com/blaubaer'>github.com/blaubaer</a></td></tr>"); body.append("</table>"); body.append("</td>"); body.append("</tr></table></body></html>"); final JTextPane text = new JTextPane(); text.setMargin(new Insets(0, 0, 0, 0)); text.setContentType("text/html"); text.setText(body.toString()); text.setFont(new Font(DIALOG, PLAIN, 12)); text.setBackground(new Color(255, 255, 255, 0)); text.setEditable(false); text.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == ACTIVATED && isDesktopSupported()) { final Desktop desktop = getDesktop(); if (desktop.isSupported(BROWSE)) { try { desktop.browse(e.getURL().toURI()); } catch (IOException | URISyntaxException exception) { LOG.error("Could not open " + e.getURL() + " because of an exception.", exception); } } else { LOG.error("Could not open " + e.getURL() + " because browse is not supported by desktop."); } } repaint(); } }); text.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { repaint(); } @Override public void mousePressed(MouseEvent e) { repaint(); } @Override public void mouseReleased(MouseEvent e) { repaint(); } @Override public void mouseEntered(MouseEvent e) { repaint(); } @Override public void mouseExited(MouseEvent e) { repaint(); } }); add(text, new CC().spanX(2).growX().minWidth("10px")); }
From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java
private JTextPane createEditablePane() { JTextPane textPane = new JTextPane(); // Get the preferences for wrapping lines of text final boolean wrapText = JBroFuzz.PREFS.getBoolean(JBroFuzzPrefs.FUZZING[2].getId(), false); if (wrapText) { textPane = new JTextPane(); } else {//from w w w. j a v a2s. c o m textPane = new NonWrappingTextPane(); } textPane.putClientProperty("charset", "UTF-8"); textPane.setEditable(true); textPane.setVisible(true); textPane.setFont(new Font("Verdana", Font.PLAIN, 12)); textPane.setMargin(new Insets(1, 1, 1, 1)); textPane.setBackground(Color.WHITE); textPane.setForeground(Color.BLACK); // Set the editor kit responsible for highlighting textPane.setEditorKit(new StyledEditorKit() { private static final long serialVersionUID = -6085642347022880064L; public Document createDefaultDocument() { return new TextHighlighter(); } }); // Right click: Cut, Copy, Paste, Select All RightClickPopups.rightClickRequestTextComponent(this, textPane); return textPane; }
From source file:org.zaproxy.zap.extension.customFire.ExtensionCustomFire.java
private AbstractPanel getStatusPanel() { if (statusPanel == null) { statusPanel = new AbstractPanel(); statusPanel.setLayout(new CardLayout()); statusPanel.setName(Constant.messages.getString(PREFIX + ".panel.title")); statusPanel.setIcon(ICON);//from w w w. j a v a 2 s. c om JTextPane pane = new JTextPane(); pane.setEditable(false); pane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); pane.setContentType("text/html"); pane.setText(Constant.messages.getString(PREFIX + ".panel.msg")); statusPanel.add(pane); } return statusPanel; }