javax.swing.JEditorPane.putClientProperty()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中javax.swing.JEditorPane.putClientProperty()方法的一些代码示例,展示了JEditorPane.putClientProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.putClientProperty()方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:putClientProperty

JEditorPane.putClientProperty介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JEditorPane pane = new JEditorPane();
pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
pane.setFont(SOME_FONT);

代码示例来源:origin: stackoverflow.com

JEditorPane pane = new JEditorPane();
pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
pane.setFont(someOrdinaryLabel.getFont());

代码示例来源:origin: org.netbeans.api/org-openide-text

private void releasePane() {
  if (pane != null) {
    pane.putClientProperty("usedByCloneableEditor", false);
  }
  pane = null;
}

代码示例来源:origin: org.jodd/jodd-wot

/**
 * Enforces JEditorPane font.
 * Once the content type of a JEditorPane is set to text/html the font on the Pane starts to be managed by Swing.
 * This method forces using provided font.
 */
public static void enforceJEditorPaneFont(JEditorPane jEditorPane, Font font) {
  jEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
  jEditorPane.setFont(font);
}

代码示例来源:origin: stackoverflow.com

JEditorPane area = new JEditorPane();
Color bgColor = Color.BLACK;
UIDefaults defaults = new UIDefaults();
defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
area.putClientProperty("Nimbus.Overrides", defaults);
area.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
area.setBackground(bgColor);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui

private static void setupUI(final JEditorPane editorPane) {
  assert SwingUtilities.isEventDispatchThread();
  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();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd

public ExtensionsElements(MIMEExtensions es) {
  this.es = es;
  update();
  textfield.setContentType("text/html");  // NOI18N
  textfield.setEditable(false);
  // bug 233412, fix for dark theme
  textfield.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
  
  updateTextField();
  button.setText(getMessage("CndOtherOptionsPanel.Extensions.EditButton"));
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation

/** Creates new form MacroExpansionPanel. */
public MacroExpansionPanel(boolean isView) {
  initComponents();
  autoRefresh.setSelected(MacroExpansionTopComponent.isSyncCaretAndContext());
  localContext.setSelected(MacroExpansionTopComponent.isLocalContext());
  fileContext.setSelected(!MacroExpansionTopComponent.isLocalContext());
  jCodeExpansionEditorPane.putClientProperty(MacroExpansionViewUtils.CND_EDITOR_COMPONENT, Boolean.TRUE);
  setName(NbBundle.getMessage(getClass(), "CTL_MacroExpansionTopComponent")); // NOI18N
  setToolTipText(NbBundle.getMessage(getClass(), "HINT_MacroExpansionTopComponent")); // NOI18N
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby

public JComponent getPreviewComponent() {
  if (previewPane == null) {
    previewPane = new JEditorPane();
    previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(FmtOptions.class, "AN_Preview")); //NOI18N
    previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FmtOptions.class, "AD_Preview")); //NOI18N
    previewPane.putClientProperty("HighlightsLayerIncludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.SyntaxHighlighting$"); //NOI18N
    previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(RubyInstallation.RUBY_MIME_TYPE));
    previewPane.setEditable(false);
  }
  return previewPane;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor

@Override
public JComponent getPreviewComponent() {
  if (previewPane == null) {
    previewPane = new JEditorPane();
    previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(FmtOptions.class, "AN_Preview")); //NOI18N
    previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FmtOptions.class, "AD_Preview")); //NOI18N
    previewPane.putClientProperty("HighlightsLayerIncludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.SyntaxHighlighting$"); //NOI18N
    previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(MIMENames.FORTRAN_MIME_TYPE));
    previewPane.setEditable(false);
  }
  return previewPane;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

private void initSourceEditor() {
  sourceEditorPane.setEditorKit(MimeLookup.getLookup(HTML_CONTENT_TYPE).lookup(EditorKit.class));
  // ui
  Font font = new JLabel().getFont();
  sourceEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
  sourceEditorPane.setFont(font);
  previewTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
  previewTextPane.setFont(font);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor

@Override
public JComponent getPreviewComponent() {
  if (previewPane == null) {
    previewPane = new JEditorPane();
    previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(EditorOptionsPanelController.class, "AN_Preview")); //NOI18N
    previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(EditorOptionsPanelController.class, "AD_Preview")); //NOI18N
    previewPane.putClientProperty("HighlightsLayerIncludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.SyntaxHighlighting$"); //NOI18N
    previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(language.toMime()));
    previewPane.setEditable(false);
  }
  return previewPane;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-dlight-util

public static JEditorPane createJEditorPane(String text, boolean needHTMLTags, Color color){
  JEditorPane editorPane = new JEditorPane("text/html", needHTMLTags || !text.startsWith("<html>") ?  "<html><center>" + text + "</center></html>" : text);//NOI18N
  editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
  editorPane.addHyperlinkListener(new HyperlinkListener() {
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
        HtmlBrowser.URLDisplayer.getDefault().showURL(e.getURL());
      }
    }
  });
   Font font = UIManager.getFont("Label.font");//NOI18N
  String bodyRule = "body { font-family: " + font.getFamily() + "; " + //NOI18N
      "font-size: " + font.getSize() + "pt; color: " + Integer.toHexString( color.getRGB() & 0x00ffffff )+ "; }"; //NOI18N
  ((HTMLDocument)editorPane.getDocument()).getStyleSheet().addRule(bodyRule);
  editorPane.setOpaque(false);
  editorPane.setEditable(false);
  return editorPane;
}

代码示例来源:origin: freeplane/freeplane

private void setLineWrap() {
  if(null != textfield.getClientProperty("EditNodeTextField.linewrap") || inputMethodInUseListener.isIMEInUse()){
    return;
  }
  final HTMLDocument document = (HTMLDocument) textfield.getDocument();
  document.getStyleSheet().addRule("body { width: " + (maxWidth - 1) + "}");
  // bad hack: call "setEditable" only to update view
  textfield.setEditable(false);
  textfield.setEditable(true);
  textfield.putClientProperty("EditNodeTextField.linewrap", true);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void deinstall(JEditorPane c) {
  executeDeinstallActions(c);
  c.updateUI();
  
  // #41209: reset ancestor override flag if previously set
  if (c.getClientProperty("ancestorOverride") != null) { // NOI18N
    c.putClientProperty("ancestorOverride", Boolean.FALSE); // NOI18N
  }
}

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

PluginDetailPanel()
{
  setLayout(new BorderLayout());
  pluginDetail = new JEditorPane();
  pluginDetail.setEditable(false);
  pluginDetail.setContentType("text/html");
  pluginDetail.setBackground(jEdit.getColorProperty("view.bgColor"));
  pluginDetail.setForeground(jEdit.getColorProperty("view.fgColor"));
  pluginDetail.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
  title = new JLabel();
  add(title, BorderLayout.NORTH);
  JScrollPane scroll = new JScrollPane(pluginDetail);
  scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  add(scroll);
} //}}}

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra

static protected void addUndoRedoSupport(JEditorPane editor) {
  UndoManager undo = (UndoManager) editor.getClientProperty(UNDO_MANAGER);
  if (undo == null) {
    undo = new UndoManager();
    editor.putClientProperty(UNDO_MANAGER, undo);
    Action undoAction = new UndoAction(undo);
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
                        Event.CTRL_MASK);
    editor.getInputMap().put(key, "undo");
    editor.getActionMap().put("undo", undoAction);
    Action redoAction = new RedoAction(undo);
    key = KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_MASK
        + KeyEvent.SHIFT_DOWN_MASK);
    editor.getInputMap().put(key, "redo");
    editor.getActionMap().put("redo", redoAction);
  }
  Document doc = editor.getDocument();
  doc.addUndoableEditListener(undo);
}

代码示例来源:origin: org.nuiton/nuiton-widgets

static protected void addUndoRedoSupport(JEditorPane editor) {
  UndoManager undo = (UndoManager) editor.getClientProperty(UNDO_MANAGER);
  if (undo == null) {
    undo = new UndoManager();
    editor.putClientProperty(UNDO_MANAGER, undo);
    Action undoAction = new UndoAction(undo);
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
        Event.CTRL_MASK);
    editor.getInputMap().put(key, "undo");
    editor.getActionMap().put("undo", undoAction);
    Action redoAction = new RedoAction(undo);
    key = KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_MASK
        + KeyEvent.SHIFT_DOWN_MASK);
    editor.getInputMap().put(key, "redo");
    editor.getActionMap().put("redo", redoAction);
  }
  Document doc = editor.getDocument();
  doc.addUndoableEditListener(undo);
}

代码示例来源:origin: freeplane/freeplane

@SuppressWarnings("unchecked")
  public void actionPerformed(ActionEvent e) {
    final DefaultMutableTreeNode menuEntryTree = MenuUtils.createAcceleratebleMenuEntryTree("main_menu");
    final String title = TextUtils.getText("hot_keys_table");
    final String html = formatAsHtml(menuEntryTree.children());
    JEditorPane refPane = new JEditorPane("text/html", html);
    refPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false);
    refPane.setCaretPosition(0);
    refPane.setEditable(false);
    final Dimension preferredSize = refPane.getPreferredSize();
    JScrollPane scrollPane = new JScrollPane(refPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(preferredSize.width, 600));
    JOptionPane pane = new JOptionPane(scrollPane, JOptionPane.INFORMATION_MESSAGE);
    JDialog dialog = pane.createDialog(UITools.getMenuComponent(), title);
     // the line below is added to the example from the docs
     dialog.setModal(false); // this says not to block background components
    dialog.setResizable(true);
    dialog.setVisible(true);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation

/**
 * Initializes document of expanded context pane.
 *
 * @param doc - document
 */
public void setContextExpansionDocument(Document doc) {
  String mimeType = DocumentUtilities.getMimeType(doc);
  if (mimeType == null) {
    mimeType = MIMENames.CPLUSPLUS_MIME_TYPE;
  }
  jCodeExpansionEditorPane.setCaretPosition(0);
  jCodeExpansionEditorPane.setContentType(mimeType);
  jCodeExpansionEditorPane.setDocument(doc);
  jCodeExpansionEditorPane.putClientProperty("HelpID","MacroExpansionWindow"); //NOI18N
  doc.putProperty(JEditorPane.class, jCodeExpansionEditorPane);
}

相关文章

JEditorPane类方法