Java Code Examples for javax.swing.JEditorPane#setForeground()
The following examples show how to use
javax.swing.JEditorPane#setForeground() .
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: BrokenProjectInfo.java From netbeans with Apache License 2.0 | 6 votes |
static JEditorPane getErrorPane(String reason) { JEditorPane errorLabel = new JEditorPane(); JLabel infoLabel = new JLabel(); errorLabel.setContentType("text/html"); // NOI18N errorLabel.setEditable(false); errorLabel.setForeground(UIManager.getDefaults().getColor("nb.errorForeground")); errorLabel.setRequestFocusEnabled(false); errorLabel.setBackground(infoLabel.getBackground()); errorLabel.setFont(infoLabel.getFont()); errorLabel.addHyperlinkListener(new BrokenProjectInfo()); errorLabel.setText(reason); return errorLabel; }
Example 2
Source File: AboutDialog.java From FancyBing with GNU General Public License v3.0 | 5 votes |
private JPanel createPanel(String text) { JPanel panel = new JPanel(new GridLayout(1, 1)); JEditorPane editorPane = new JEditorPane(); editorPane.setBorder(GuiUtil.createEmptyBorder()); editorPane.setEditable(false); if (Platform.isMac()) { editorPane.setForeground(UIManager.getColor("Label.foreground")); editorPane.setBackground(UIManager.getColor("Label.background")); } else { editorPane.setForeground(Color.black); editorPane.setBackground(Color.white); } panel.add(editorPane); EditorKit editorKit = JEditorPane.createEditorKitForContentType("text/html"); editorPane.setEditorKit(editorKit); editorPane.setText(text); editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { HyperlinkEvent.EventType type = event.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { URL url = event.getURL(); if (! Platform.openInExternalBrowser(url)) m_messageDialogs.showError(null, i18n("MSG_ABOUT_OPEN_URL_FAIL"), "", false); } } }); return panel; }
Example 3
Source File: RubyConsole.java From ramus with GNU General Public License v3.0 | 5 votes |
public JComponent createComponent() { JPanel panel = new JPanel(); JPanel console = new JPanel(); panel.setLayout(new BorderLayout()); final JEditorPane text = new JTextPane(); text.setMargin(new Insets(8, 8, 8, 8)); text.setCaretColor(new Color(0xa4, 0x00, 0x00)); text.setBackground(new Color(0xf2, 0xf2, 0xf2)); text.setForeground(new Color(0xa4, 0x00, 0x00)); Font font = findFont("Monospaced", Font.PLAIN, 14, new String[]{ "Monaco", "Andale Mono"}); text.setFont(font); JScrollPane pane = new JScrollPane(); pane.setViewportView(text); pane.setBorder(BorderFactory.createLineBorder(Color.darkGray)); panel.add(pane, BorderLayout.CENTER); console.validate(); final TextAreaReadline tar = new TextAreaReadline(text, getString("Wellcom") + " \n\n"); RubyInstanceConfig config = new RubyInstanceConfig() { { //setInput(tar.getInputStream()); //setOutput(new PrintStream(tar.getOutputStream())); //setError(new PrintStream(tar.getOutputStream())); setObjectSpaceEnabled(false); } }; Ruby runtime = Ruby.newInstance(config); tar.hookIntoRuntimeWithStreams(runtime); run(runtime); return panel; }
Example 4
Source File: DocumentationUI.java From whyline with MIT License | 5 votes |
public DocumentationUI(WhylineUI whylineUI) { super("documentation", whylineUI); doc = new JEditorPane("text/html", ""); // This makes the pane respect the background, foreground, font. doc.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); doc.setBackground(UI.getControlBackColor()); doc.setForeground(UI.getControlTextColor()); doc.setOpaque(true); doc.setFont(UI.getMediumFont()); doc.setEditable(false); WhylineScrollPane pane = new WhylineScrollPane(doc); pane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); pane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); pane.setBorder(new WhylineControlBorder()); setContent(pane); setMinimumSize(new Dimension(UI.getDefaultInfoPaneWidth(whylineUI), 0)); doc.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) Util.openURL(e.getURL().toString()); } }); }
Example 5
Source File: NotesPanel.java From triplea with GNU General Public License v3.0 | 5 votes |
private static JEditorPane createNotesPane(final String html) { final JEditorPane gameNotesPane = new JEditorPane("text/html", html); gameNotesPane.setEditable(false); gameNotesPane.setForeground(Color.BLACK); gameNotesPane.setCaretPosition(0); return gameNotesPane; }
Example 6
Source File: ToolTipSupport.java From netbeans with Apache License 2.0 | 4 votes |
private JEditorPane createHtmlTextToolTip() { class HtmlTextToolTip extends JEditorPane { public @Override void setSize(int width, int height) { Dimension prefSize = getPreferredSize(); if (width >= prefSize.width) { width = prefSize.width; } else { // smaller available width super.setSize(width, 10000); // the height is unimportant prefSize = getPreferredSize(); // re-read new pref width } if (height >= prefSize.height) { // enough height height = prefSize.height; } super.setSize(width, height); } @Override public void setKeymap(Keymap map) { //#181722: keymaps are shared among components with the same UI //a default action will be set to the Keymap of this component below, //so it is necessary to use a Keymap that is not shared with other components super.setKeymap(addKeymap(null, map)); } } JEditorPane tt = new HtmlTextToolTip(); /* See NETBEANS-403. It still appears possible to use Escape to close the popup when the focus is in the editor. */ tt.putClientProperty(SUPPRESS_POPUP_KEYBOARD_FORWARDING_CLIENT_PROPERTY_KEY, true); // setup tooltip keybindings filterBindings(tt.getActionMap()); tt.getActionMap().put(HIDE_ACTION.getValue(Action.NAME), HIDE_ACTION); tt.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), HIDE_ACTION.getValue(Action.NAME)); tt.getKeymap().setDefaultAction(NO_ACTION); Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N if (font != null) { tt.setFont(font); } if (foreColor != null) { tt.setForeground(foreColor); } if (backColor != null) { tt.setBackground(backColor); } tt.setOpaque(true); tt.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(tt.getForeground()), BorderFactory.createEmptyBorder(0, 3, 0, 3) )); tt.setContentType("text/html"); //NOI18N return tt; }