javax.swing.JEditorPane#setEditable ( )源码实例Demo

下面列出了javax.swing.JEditorPane#setEditable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: triplea   文件: ObjectivePanel.java
EditorPaneCellEditor() {
  super(new JTextField());
  final JEditorPane textArea = new JEditorPane();
  textArea.setEditable(false);
  textArea.setContentType("text/html");
  final JScrollPane scrollPane = new JScrollPane(textArea);
  scrollPane.setBorder(null);
  editorComponent = scrollPane;
  delegate =
      new DefaultCellEditor.EditorDelegate() {
        private static final long serialVersionUID = 5746645959173385516L;

        @Override
        public void setValue(final Object value) {
          textArea.setText((value != null) ? value.toString() : "");
        }

        @Override
        public Object getCellEditorValue() {
          return textArea.getText();
        }
      };
}
 
源代码2 项目: Briss-2.0   文件: HelpDialog.java
public HelpDialog(final Frame owner, final String title, final Dialog.ModalityType modalityType) {
    super(owner, title, modalityType);
    setBounds(232, 232, 500, 800);

    String helpText = "";

    InputStream is = getClass().getResourceAsStream(HELP_FILE_PATH);
    byte[] buf = new byte[1024 * 100];
    try {
        int cnt = is.read(buf);
        helpText = new String(buf, 0, cnt);
    } catch (IOException e) {
        helpText = "Couldn't read the help file... Please contact [email protected]";
    }

    JEditorPane jEditorPane = new JEditorPane("text/html", helpText);
    jEditorPane.setEditable(false);
    jEditorPane.setVisible(true);

    JScrollPane scroller = new JScrollPane(jEditorPane);
    getContentPane().add(scroller);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setVisible(true);
}
 
源代码3 项目: jpexs-decompiler   文件: GenericTagPanel.java
public GenericTagPanel(MainPanel mainPanel) {
    super(new BorderLayout());

    this.mainPanel = mainPanel;
    hdr = new HeaderLabel("");
    add(hdr, BorderLayout.NORTH);
    genericTagPropertiesEditorPane = new JEditorPane() {
        @Override
        public boolean getScrollableTracksViewportWidth() {
            return true;
        }
    };
    genericTagPropertiesEditorPane.setEditable(false);
    genericTagPropertiesEditorPaneScrollPanel = new JScrollPane(genericTagPropertiesEditorPane);
    add(genericTagPropertiesEditorPaneScrollPanel, BorderLayout.CENTER);

    genericTagPropertiesEditPanel = new JPanel();
    genericTagPropertiesEditPanel.setLayout(new SpringLayout());
    JPanel edPanel = new JPanel(new BorderLayout());
    edPanel.add(genericTagPropertiesEditPanel, BorderLayout.NORTH);
    genericTagPropertiesEditPanelScrollPanel = new JScrollPane(edPanel);
}
 
源代码4 项目: megamek   文件: CommonHelpDialog.java
/**
 * Create a help dialog for the given <code>parentFrame</code> by reading
 * from the indicated <code>File</code>.
 */
public CommonHelpDialog(JFrame parentFrame, File helpfile) {
    super(parentFrame);

    setLayout(new BorderLayout());
    JEditorPane helpPane = new JEditorPane();
    helpPane.setEditable(false);

    // Get the help content file if possible
    try {
        helpPane.setPage(helpfile.toURI().toURL());
        setTitle(Messages.getString("CommonHelpDialog.helpFile") + helpfile.getName()); //$NON-NLS-1$
    } catch (Exception exc) {
        helpPane.setText(Messages.getString("CommonHelpDialog.errorReading") //$NON-NLS-1$
                + exc.getMessage());
        setTitle(Messages.getString("CommonHelpDialog.noHelp.title")); //$NON-NLS-1$
        exc.printStackTrace();
    }

    // Close Button
    JButton butClose = new ButtonEsc(new CloseAction(this));

    // Add all to the dialog
    getContentPane().add(new JScrollPane(helpPane), BorderLayout.CENTER);
    getContentPane().add(butClose, BorderLayout.SOUTH);
    
    // Make the window half the screensize and center on screen
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    Dimension windowSize = new Dimension(gd.getDisplayMode().getWidth() / 2,
            gd.getDisplayMode().getHeight() / 2);
    pack();
    setSize(windowSize);
    setLocationRelativeTo(null);
}
 
源代码5 项目: CodeChickenCore   文件: CodeChickenCorePlugin.java
public static void versionCheck(String reqVersion, String mod) {
    String mcVersion = (String) FMLInjectionData.data()[4];
    if (!VersionParser.parseRange(reqVersion).containsVersion(new DefaultArtifactVersion(mcVersion))) {
        String err = "This version of " + mod + " does not support minecraft version " + mcVersion;
        logger.error(err);

        JEditorPane ep = new JEditorPane("text/html",
                "<html>" +
                        err +
                        "<br>Remove it from your coremods folder and check <a href=\"http://www.minecraftforum.net/topic/909223-\">here</a> for updates" +
                        "</html>");

        ep.setEditable(false);
        ep.setOpaque(false);
        ep.addHyperlinkListener(new HyperlinkListener()
        {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent event) {
                try {
                    if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                        Desktop.getDesktop().browse(event.getURL().toURI());
                } catch (Exception ignored) {}
            }
        });

        JOptionPane.showMessageDialog(null, ep, "Fatal error", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
 
源代码6 项目: FancyBing   文件: Help.java
public Help(URL contents, MessageDialogs messageDialogs,
            String title)
{
    m_messageDialogs = messageDialogs;
    m_contents = contents;
    Container contentPane;
    if (Platform.isMac())
    {
        JDialog dialog = new JDialog((Frame)null, title);
        contentPane = dialog.getContentPane();
        m_window = dialog;
    }
    else
    {
        JFrame frame = new JFrame(title);
        GuiUtil.setGoIcon(frame);
        contentPane = frame.getContentPane();
        m_window = frame;
    }
    JPanel panel = new JPanel(new BorderLayout());
    contentPane.add(panel);
    panel.add(createButtons(), BorderLayout.NORTH);
    m_editorPane = new JEditorPane();
    m_editorPane.setEditable(false);
    m_editorPane.addHyperlinkListener(this);
    int width = GuiUtil.getDefaultMonoFontSize() * 50;
    int height = GuiUtil.getDefaultMonoFontSize() * 60;
    JScrollPane scrollPane =
        new JScrollPane(m_editorPane,
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    if (Platform.isMac())
        // Default Apple L&F uses no border, but Quaqua 3.7.4 does
        scrollPane.setBorder(null);
    scrollPane.setPreferredSize(new Dimension(width, height));
    panel.add(scrollPane, BorderLayout.CENTER);
    m_window.pack();
    loadURL(m_contents);
    appendHistory(m_contents);
}
 
源代码7 项目: libreveris   文件: MainGui.java
/**
 * Allow to display a modal dialog with an html content.
 *
 * @param htmlStr the HTML string
 */
public void displayMessage (String htmlStr)
{
    JEditorPane htmlPane = new JEditorPane("text/html", htmlStr);
    htmlPane.setEditable(false);
    JOptionPane.showMessageDialog(
            frame,
            htmlPane,
            appName,
            JOptionPane.INFORMATION_MESSAGE);
}
 
源代码8 项目: aion-germany   文件: InflateReader.java
public void actionPerformed(ActionEvent e) {
	JDialog dlg = new JDialog(((Main) PacketSamurai.getUserInterface()).getMainFrame(), "Text");
	dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	dlg.setSize(350, 400);
	dlg.setLocationRelativeTo(((Main) PacketSamurai.getUserInterface()).getMainFrame());

	JEditorPane sourceDisplay = new JEditorPane();
	sourceDisplay.setEditable(false);
	sourceDisplay.setContentType("text/plain");
	sourceDisplay.setText(_xml);

	dlg.add(new JScrollPane(sourceDisplay));
	dlg.setVisible(true);
}
 
源代码9 项目: MtgDesktopCompanion   文件: JEditorPaneBrowser.java
public JEditorPaneBrowser() {
	setLayout(new BorderLayout());
	browse = new JEditorPane() ;
	browse.setContentType("text/html");
	HTMLEditorKit kit = new HTMLEditorKit();
	browse.setEditorKit(kit);
	browse.setEditable(false);
	add(browse,BorderLayout.CENTER);
	client = URLTools.newClient();
	
}
 
源代码10 项目: MtgDesktopCompanion   文件: HelpCompononent.java
public HelpCompononent() {
	pane = new JEditorPane();
	pane.setContentType("text/html");
	setLayout(new BorderLayout());
	pane.setEditable(false);
	add(new JScrollPane(pane),BorderLayout.CENTER);
}
 
源代码11 项目: netbeans   文件: FoldView.java
@Override
public JComponent getToolTip(double x, double y, Shape allocation) {
    Container container = getContainer();
    if (container instanceof JEditorPane) {
        JEditorPane editorPane = (JEditorPane) getContainer();
        JEditorPane tooltipPane = new JEditorPane();
        EditorKit kit = editorPane.getEditorKit();
        Document doc = getDocument();
        if (kit != null && doc != null) {
            Element lineRootElement = doc.getDefaultRootElement();
            tooltipPane.putClientProperty(FoldViewFactory.DISPLAY_ALL_FOLDS_EXPANDED_PROPERTY, true);
            try {
                // Start-offset of the fold => line start => position
                int lineIndex = lineRootElement.getElementIndex(fold.getStartOffset());
                Position pos = doc.createPosition(
                        lineRootElement.getElement(lineIndex).getStartOffset());
                // DocumentView.START_POSITION_PROPERTY
                tooltipPane.putClientProperty("document-view-start-position", pos); // NOI18N
                // End-offset of the fold => line end => position
                lineIndex = lineRootElement.getElementIndex(fold.getEndOffset());
                pos = doc.createPosition(lineRootElement.getElement(lineIndex).getEndOffset());
                // DocumentView.END_POSITION_PROPERTY
                tooltipPane.putClientProperty("document-view-end-position", pos); // NOI18N
                tooltipPane.putClientProperty("document-view-accurate-span", true); // NOI18N
                // Set the same kit and document
                tooltipPane.setEditorKit(kit);
                tooltipPane.setDocument(doc);
                tooltipPane.setEditable(false);
                return new FoldToolTip(editorPane, tooltipPane, getBorderColor());
            } catch (BadLocationException e) {
                // => return null
            }
        }
    }
    return null;
}
 
源代码12 项目: dragonwell8_jdk   文件: XArrayDataViewer.java
public static Component loadArray(Object value) {
    Component comp = null;
    if (isViewableValue(value)) {
        Object[] arr;
        if (value instanceof Collection) {
            arr = ((Collection<?>) value).toArray();
        } else if (value instanceof Map) {
            arr = ((Map<?,?>) value).entrySet().toArray();
        } else if (value instanceof Object[]) {
            arr = (Object[]) value;
        } else {
            int length = Array.getLength(value);
            arr = new Object[length];
            for (int i = 0; i < length; i++) {
                arr[i] = Array.get(value, i);
            }
        }
        JEditorPane arrayEditor = new JEditorPane();
        arrayEditor.setContentType("text/html");
        arrayEditor.setEditable(false);
        Color evenRowColor = arrayEditor.getBackground();
        int red = evenRowColor.getRed();
        int green = evenRowColor.getGreen();
        int blue = evenRowColor.getBlue();
        String evenRowColorStr =
                "rgb(" + red + "," + green + "," + blue + ")";
        Color oddRowColor = new Color(
                red < 20 ? red + 20 : red - 20,
                green < 20 ? green + 20 : green - 20,
                blue < 20 ? blue + 20 : blue - 20);
        String oddRowColorStr =
                "rgb(" + oddRowColor.getRed() + "," +
                oddRowColor.getGreen() + "," +
                oddRowColor.getBlue() + ")";
        Color foreground = arrayEditor.getForeground();
        String textColor = String.format("%06x",
                                         foreground.getRGB() & 0xFFFFFF);
        StringBuilder sb = new StringBuilder();
        sb.append("<html><body text=#"+textColor+"><table width=\"100%\">");
        for (int i = 0; i < arr.length; i++) {
            if (i % 2 == 0) {
                sb.append("<tr style=\"background-color: " +
                        evenRowColorStr + "\"><td><pre>" +
                        (arr[i] == null ?
                            arr[i] : htmlize(arr[i].toString())) +
                        "</pre></td></tr>");
            } else {
                sb.append("<tr style=\"background-color: " +
                        oddRowColorStr + "\"><td><pre>" +
                        (arr[i] == null ?
                            arr[i] : htmlize(arr[i].toString())) +
                        "</pre></td></tr>");
            }
        }
        if (arr.length == 0) {
            sb.append("<tr style=\"background-color: " +
                    evenRowColorStr + "\"><td></td></tr>");
        }
        sb.append("</table></body></html>");
        arrayEditor.setText(sb.toString());
        JScrollPane scrollp = new JScrollPane(arrayEditor);
        comp = scrollp;
    }
    return comp;
}
 
源代码13 项目: openjdk-8   文件: XArrayDataViewer.java
public static Component loadArray(Object value) {
    Component comp = null;
    if (isViewableValue(value)) {
        Object[] arr;
        if (value instanceof Collection) {
            arr = ((Collection<?>) value).toArray();
        } else if (value instanceof Map) {
            arr = ((Map<?,?>) value).entrySet().toArray();
        } else if (value instanceof Object[]) {
            arr = (Object[]) value;
        } else {
            int length = Array.getLength(value);
            arr = new Object[length];
            for (int i = 0; i < length; i++) {
                arr[i] = Array.get(value, i);
            }
        }
        JEditorPane arrayEditor = new JEditorPane();
        arrayEditor.setContentType("text/html");
        arrayEditor.setEditable(false);
        Color evenRowColor = arrayEditor.getBackground();
        int red = evenRowColor.getRed();
        int green = evenRowColor.getGreen();
        int blue = evenRowColor.getBlue();
        String evenRowColorStr =
                "rgb(" + red + "," + green + "," + blue + ")";
        Color oddRowColor = new Color(
                red < 20 ? red + 20 : red - 20,
                green < 20 ? green + 20 : green - 20,
                blue < 20 ? blue + 20 : blue - 20);
        String oddRowColorStr =
                "rgb(" + oddRowColor.getRed() + "," +
                oddRowColor.getGreen() + "," +
                oddRowColor.getBlue() + ")";
        Color foreground = arrayEditor.getForeground();
        String textColor = String.format("%06x",
                                         foreground.getRGB() & 0xFFFFFF);
        StringBuilder sb = new StringBuilder();
        sb.append("<html><body text=#"+textColor+"><table width=\"100%\">");
        for (int i = 0; i < arr.length; i++) {
            if (i % 2 == 0) {
                sb.append("<tr style=\"background-color: " +
                        evenRowColorStr + "\"><td><pre>" +
                        (arr[i] == null ?
                            arr[i] : htmlize(arr[i].toString())) +
                        "</pre></td></tr>");
            } else {
                sb.append("<tr style=\"background-color: " +
                        oddRowColorStr + "\"><td><pre>" +
                        (arr[i] == null ?
                            arr[i] : htmlize(arr[i].toString())) +
                        "</pre></td></tr>");
            }
        }
        if (arr.length == 0) {
            sb.append("<tr style=\"background-color: " +
                    evenRowColorStr + "\"><td></td></tr>");
        }
        sb.append("</table></body></html>");
        arrayEditor.setText(sb.toString());
        JScrollPane scrollp = new JScrollPane(arrayEditor);
        comp = scrollp;
    }
    return comp;
}
 
源代码14 项目: triplea   文件: SwingComponents.java
public static JEditorPane newHtmlJEditorPane() {
  final JEditorPane descriptionPane = new JEditorPane();
  descriptionPane.setEditable(false);
  descriptionPane.setContentType("text/html");
  return descriptionPane;
}
 
源代码15 项目: azure-devops-intellij   文件: EULADialog.java
private EULADialog(@Nullable Project project, @NotNull String title, @Nullable String eulaText, boolean isPlainText, OnEulaAccepted onAccept) {
    super(project);
    this.onAccept = onAccept;
    myEulaTextFound = eulaText != null;

    JComponent component;
    if (isPlainText) {
        JTextArea textArea = new JTextArea();
        textArea.setText(eulaText);
        textArea.setMinimumSize(null);
        textArea.setEditable(false);
        textArea.setCaretPosition(0);
        textArea.setBackground(null);
        textArea.setBorder(JBUI.Borders.empty());

        component = textArea;
    } else {
        JEditorPane editor = new JEditorPane();
        editor.setContentType("text/html");
        editor.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); // work around <meta> tag
        editor.setText(eulaText);
        editor.setEditable(false);
        editor.setCaretPosition(0);
        editor.setMinimumSize(null);
        editor.setBorder(JBUI.Borders.empty());

        component = editor;
    }

    myScrollPane = new JBScrollPane(component);
    myScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    setModal(true);
    setTitle(title);

    setOKButtonText("Accept");
    getOKAction().putValue(DEFAULT_ACTION, null);

    setCancelButtonText("Decline");
    getCancelAction().putValue(DEFAULT_ACTION, Boolean.TRUE);

    init();
}
 
源代码16 项目: RegexReplacer   文件: HelpFrame.java
private HelpFrame() {
	setTitle(StrUtils.getStr("HelpFrame.title"));
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	jtp = new JTabbedPane();
	try {
		JEditorPane regexPane = new JEditorPane(RegexReplacer.class
				.getClassLoader().getResource(
						StrUtils.getStr("html.JavaRegex")));
		regexPane.setEditable(false);
		// regexPane.addHyperlinkListener(new HyperlinkListener() {
		// @Override
		// public void hyperlinkUpdate(HyperlinkEvent e) {
		// if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
		// URL url = e.getURL();
		// try {
		// ((JEditorPane) e.getSource()).setPage(url);
		// } catch (IOException e1) {
		// e1.printStackTrace();
		// }
		// }
		// }
		// });
		jtp.addTab(regexHelp, new JScrollPane(regexPane));

		JEditorPane helpPane = new JEditorPane(RegexReplacer.class
				.getClassLoader().getResource(StrUtils.getStr("html.Help")));
		helpPane.setEditable(false);
		jtp.addTab(help, new JScrollPane(helpPane));
		JEditorPane functionsPane = new JEditorPane(RegexReplacer.class
				.getClassLoader().getResource(
						StrUtils.getStr("html.Functions")));
		functionsPane.setEditable(false);
		jtp.addTab(functionsHelp, new JScrollPane(functionsPane));
		JEditorPane newFunctionPane = new JEditorPane(RegexReplacer.class
				.getClassLoader().getResource(
						StrUtils.getStr("html.NewFunction")));
		newFunctionPane.setEditable(false);
		jtp.addTab(newFunctionHelp, new JScrollPane(newFunctionPane));
	} catch (IOException e) {
		e.printStackTrace();
	}
	add(jtp);
	setSize(700, 500);
	setLocationRelativeTo(null);
}
 
源代码17 项目: marathonv5   文件: TreeIconDemo.java
public TreeIconDemo() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Set the icon for leaf nodes.
    ImageIcon leafIcon = createImageIcon("images/middle.gif");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    } else {
        System.err.println("Leaf icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
                                       // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
源代码18 项目: marathonv5   文件: TreeIconDemo2.java
public TreeIconDemo2() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Enable tool tips.
    ToolTipManager.sharedInstance().registerComponent(tree);

    // Set the icon for leaf nodes.
    ImageIcon tutorialIcon = createImageIcon("images/middle.gif");
    if (tutorialIcon != null) {
        tree.setCellRenderer(new MyRenderer(tutorialIcon));
    } else {
        System.err.println("Tutorial icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
                                       // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
源代码19 项目: mzmine3   文件: GUIUtils.java
/**
 * Add a new editorpane to a given component
 *
 * @param component Component to add the label to
 * @param text Label's text
 * @return Created EditorPane
 */
public static JEditorPane addEditorPane(String text) {
  JEditorPane result = new JEditorPane("text/html", text);
  result.setEditable(false);
  return result;
}
 
源代码20 项目: netbeans   文件: PreviewMultiViewElement.java
/**
 *  Sets CloneableEditor instance not editable, according to component specification.
 *  CloneableEditor isn't working properly with MultiViewComponent and part of editor 
 *  functionality couldn't work, otherwise.
 */
public void setEditableDisabled() {
    JEditorPane prev = this.getEditorPane();
    prev.setEditable(false);
}