Java Code Examples for javax.swing.JEditorPane#repaint()
The following examples show how to use
javax.swing.JEditorPane#repaint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MiscEditorUtil.java From netbeans with Apache License 2.0 | 6 votes |
private static void setupUI(final JEditorPane editorPane) { Runnable runnable = new Runnable() { public void run() { EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane); if (eui == null) { return ; } editorPane.putClientProperty( "HighlightsLayerExcludes", //NOI18N "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.CaretRowHighlighting$" //NOI18N ); // Do not draw text limit line try { java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N textLimitLineField.setAccessible(true); textLimitLineField.set(eui, false); } catch (Exception ex) {} editorPane.repaint(); } }; if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } }
Example 2
Source File: ColumnModels.java From netbeans with Apache License 2.0 | 6 votes |
private void setupUI(JEditorPane editorPane) { EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane); if (eui == null) { return; } editorPane.putClientProperty( "HighlightsLayerExcludes", //NOI18N "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.CaretRowHighlighting$" //NOI18N ); // Do not draw text limit line try { java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N textLimitLineField.setAccessible(true); textLimitLineField.set(eui, false); } catch (Exception ex) {} editorPane.repaint(); }
Example 3
Source File: HyperlinkListener.java From netbeans with Apache License 2.0 | 5 votes |
public void mouseMoved (MouseEvent e) { JEditorPane c = (JEditorPane) e.getComponent (); final NbEditorDocument doc = (NbEditorDocument) c.getDocument (); if (highlight != null) highlight.remove (); highlight = null; runnable = null; if (((e.getModifiers() | e.getModifiersEx()) & InputEvent.CTRL_DOWN_MASK) != InputEvent.CTRL_DOWN_MASK) { return; } int offset = c.viewToModel (e.getPoint ()); highlight (doc, offset); c.repaint (); }
Example 4
Source File: FmtOptions.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void refreshPreview() { JEditorPane pane = (JEditorPane) getPreviewComponent(); try { int rm = previewPrefs.getInt(rightMargin, provider.getDefaultAsInt(rightMargin)); pane.putClientProperty("TextLimitLine", rm); //NOI18N } catch( NumberFormatException e ) { // Ignore it } Rectangle visibleRectangle = pane.getVisibleRect(); pane.setText(previewText); pane.setIgnoreRepaint(true); final Document doc = pane.getDocument(); if (doc instanceof BaseDocument) { final Reformat reformat = Reformat.get(doc); reformat.lock(); try { ((BaseDocument) doc).runAtomic(new Runnable() { @Override public void run() { try { reformat.reformat(0, doc.getLength()); } catch (BadLocationException ble) { LOGGER.log(Level.WARNING, null, ble); } } }); } finally { reformat.unlock(); } } else { LOGGER.warning(String.format("Can't format %s; it's not BaseDocument.", doc)); //NOI18N } pane.setIgnoreRepaint(false); pane.scrollRectToVisible(visibleRectangle); pane.repaint(100); }
Example 5
Source File: FmtOptions.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void refreshPreview() { JEditorPane pane = (JEditorPane) getPreviewComponent(); try { int rm = previewPrefs.getInt(RIGHT_MARGIN, getDefaultAsInt(RIGHT_MARGIN)); pane.putClientProperty("TextLimitLine", rm); //NOI18N } catch (NumberFormatException e) { // Ignore it } Rectangle visibleRectangle = pane.getVisibleRect(); pane.setText(previewText); pane.setIgnoreRepaint(true); final Document doc = pane.getDocument(); if (doc instanceof BaseDocument) { final Reformat reformat = Reformat.get(doc); reformat.lock(); try { ((BaseDocument) doc).runAtomic(new Runnable() { @Override public void run() { try { reformat.reformat(0, doc.getLength()); } catch (BadLocationException ble) { LOGGER.log(Level.WARNING, null, ble); } } }); } finally { reformat.unlock(); } } else { LOGGER.warning(String.format("Can't format %s; it's not BaseDocument.", doc)); //NOI18N } pane.setIgnoreRepaint(false); pane.scrollRectToVisible(visibleRectangle); pane.repaint(100); }
Example 6
Source File: FmtOptions.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void refreshPreview() { JEditorPane pane = (JEditorPane) getPreviewComponent(); try { int rm = previewPrefs.getInt(rightMargin, getDefaultAsInt(rightMargin)); pane.putClientProperty("TextLimitLine", rm); //NOI18N } catch( NumberFormatException e ) { // Ignore it } Rectangle visibleRectangle = pane.getVisibleRect(); pane.setText(previewText); pane.setIgnoreRepaint(true); final Document doc = pane.getDocument(); if (doc instanceof BaseDocument) { final Reformat reformat = Reformat.get(doc); reformat.lock(); try { ((BaseDocument) doc).runAtomic(new Runnable() { @Override public void run() { try { reformat.reformat(0, doc.getLength()); } catch (BadLocationException ble) { LOGGER.log(Level.WARNING, null, ble); } } }); } finally { reformat.unlock(); } } else { LOGGER.warning(String.format("Can't format %s; it's not BaseDocument.", doc)); //NOI18N } pane.setIgnoreRepaint(false); pane.scrollRectToVisible(visibleRectangle); pane.repaint(100); }
Example 7
Source File: BugReportService.java From Shuffle-Move with GNU General Public License v3.0 | 4 votes |
/** * @return */ @SuppressWarnings("serial") private JComponent getInstructionPanel() { ConfigManager preferencesManager = getUser().getPreferencesManager(); final int width = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH); JEditorPane textPane = new JEditorPane() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width = width - 40; return d; } }; textPane.setFocusable(false); textPane.setEditable(false); textPane.setContentType("text/html"); textPane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException | NullPointerException e1) { LOG.severe(getString(KEY_BAD_LINK, e1.getMessage())); } } } } }); JScrollPane jsp = new JScrollPane(textPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jsp.getVerticalScrollBar().setUnitIncrement(30); String text = getUser().getPathManager().readEntireDocument(getFilePath(), getDefaultFileKey()); textPane.setText(text); textPane.setSelectionStart(0); textPane.setSelectionEnd(0); textPane.repaint(); jsp.validate(); return jsp; }