當前位置: 首頁>>代碼示例>>Java>>正文


Java JEditorPane.setBackground方法代碼示例

本文整理匯總了Java中javax.swing.JEditorPane.setBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.setBackground方法的具體用法?Java JEditorPane.setBackground怎麽用?Java JEditorPane.setBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.setBackground方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setEditable

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void setEditable(boolean b) {
    JEditorPane editor = editor();
    if (editor.isEditable() == b) return;
    
    editor.setEditable(b);

    if (b) {
        if (lastBgColor != null) editor.setBackground(lastBgColor);
        if (lastCaret != null) editor.setCaret(lastCaret);
    } else {
        lastBgColor = editor.getBackground();
        lastCaret = editor.getCaret();
        editor.setBackground(disabledBgColor);
        editor.setCaret(nullCaret);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:OQLEditor.java

示例2: getErrorMessage

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private JEditorPane getErrorMessage() {
    JEditorPane errorMsg = new JEditorPane();

    errorMsg.setEditable(false);
    errorMsg.setPreferredSize(new Dimension(700, 130));
    errorMsg.setBackground(null);
    // Text font
    Font font = new Font("Sans", Font.PLAIN, 6);
    errorMsg.setFont(font);
    // Handle HTML
    errorMsg.setEditorKit(new HTMLEditorKit());
    errorMsg.addHyperlinkListener(this);

    errorMsg.setText(ERROR_MSG);

    return errorMsg;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:18,代碼來源:BugReportDialog.java

示例3: ResultPanelOutput

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * Creates a new instance of ResultPanelOutput
 */
ResultPanelOutput(ResultDisplayHandler displayHandler) {
    super();
    if (LOG) {
        System.out.println("ResultPanelOutput.<init>");
    }
    
    textPane = new JEditorPane();
    textPane.setFont(new Font("monospaced", Font.PLAIN, getFont().getSize()));
    textPane.setEditorKit(new OutputEditorKit());
    textPane.setEditable(false);
    textPane.getCaret().setVisible(true);
    textPane.getCaret().setBlinkRate(0);
    textPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    setViewportView(textPane);

    /*
     * On GTK L&F, background of the text pane is gray, even though it is
     * white on a JTextArea. The following is a hack to fix it:
     */
    Color background = UIManager.getColor("TextPane.background");   //NOI18N
    if (background != null) {
        textPane.setBackground(background);
    }

    doc = textPane.getDocument();

    AccessibleContext ac = textPane.getAccessibleContext();
    ac.setAccessibleName(NbBundle.getMessage(getClass(),
                                            "ACSN_OutputTextPane"));//NOI18N
    ac.setAccessibleDescription(NbBundle.getMessage(getClass(),
                                            "ACSD_OutputTextPane"));//NOI18N
    
    this.displayHandler = displayHandler;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:ResultPanelOutput.java

示例4: SwingSpyPanel

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
	 * Initialization.
	 */
	public SwingSpyPanel() {
		setPreferredSize(new Dimension(INITIAL_WIDTH, INITIAL_HEIGHT));
		setLayout(new BorderLayout());

		root = new DefaultMutableTreeNode();
		componentTree = new JTree(root);
		componentTree.setRootVisible(false);
		componentTree.setCellRenderer(new SwingComponentRenderer());
		componentTree.addTreeSelectionListener(new CustomSelectionListener());
//		add(new JScrollPane(componentTree), BorderLayout.CENTER);

		detailsData = new JEditorPane();
		detailsData.setBackground(new Color(250, 250, 250));
		detailsData.setForeground(new Color(33, 33, 33));
		detailsData.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 244), 1));
		detailsData.setPreferredSize(new Dimension(150, INITIAL_HEIGHT));
		detailsData.setEditable(false);
		detailsData.setContentType("text/html");
		SwingUtil.enforceJEditorPaneFont(detailsData, font);
		detailsScrollPane = new JScrollPane(detailsData);
//		add(detailsScrollPane, BorderLayout.EAST);

		JSplitPane hPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(componentTree), detailsScrollPane);
		hPane.setContinuousLayout(true);
		hPane.setOneTouchExpandable(true);
		hPane.setDividerLocation(INITIAL_WIDTH - 200);
		add(hPane, BorderLayout.CENTER);

		componentData = new JEditorPane();
		componentData.setBackground(new Color(250, 250, 250));
		componentData.setForeground(new Color(33, 33, 33));
		componentData.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 244), 1));
		componentData.setPreferredSize(new Dimension(INITIAL_WIDTH, 36));
		componentData.setEditable(false);
		componentData.setContentType("text/html");
		SwingUtil.enforceJEditorPaneFont(componentData, font);
		add(componentData, BorderLayout.SOUTH);

	}
 
開發者ID:igr,項目名稱:swingspy,代碼行數:43,代碼來源:SwingSpyPanel.java

示例5: FlickrSettingsPanel

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public FlickrSettingsPanel()
{
	apiKey = new JTextField();
	apiSharedSecret = new JTextField();

	// Yuck, this seems to be the minimal amount of code to get a clickable
	// and styled link
	// (copied from the Cron link in the scheduler)
	JEditorPane apiKeyHelp = new JEditorPane();
	apiKeyHelp.setEditorKit(new HTMLEditorKit());
	apiKeyHelp.setDocument(new HTMLDocument());
	apiKeyHelp.setEditable(false);
	apiKeyHelp.setText("<html><head><style>" + "<!--a{color:#0000cc;text-decoration: none;}//--></style></head>"
		+ "<body>" + getString("settings.label.apikeyhelp"));
	apiKeyHelp.addHyperlinkListener(new HyperlinkListener()
	{
		@Override
		public void hyperlinkUpdate(HyperlinkEvent e)
		{
			if( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED )
			{
				getClientService().showDocument(e.getURL(), null);
			}
		}
	});
	apiKeyHelp.setBackground(new JPanel().getBackground());

	add(apiKeyHelp, "span 2");

	add(new JLabel(getString("settings.label.apikey")));
	add(apiKey);
	add(new JLabel(getString("settings.label.apisharedsecret")));
	add(apiSharedSecret);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:FlickrSettingsPanel.java

示例6: createComponent

import javax.swing.JEditorPane; //導入方法依賴的package包/類
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;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:39,代碼來源:RubyConsole.java

示例7: mxCellEditor

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * 
 */
public mxCellEditor(mxGraphComponent graphComponent)
{
	this.graphComponent = graphComponent;

	// Creates the plain text editor
	textArea = new JTextArea();
	textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
	textArea.setOpaque(false);

	// Creates the HTML editor
	editorPane = new JEditorPane();
	editorPane.setOpaque(false);
	editorPane.setBackground(new Color(0,0,0,0));
	editorPane.setContentType("text/html");

	// Workaround for inserted linefeeds in HTML markup with
	// lines that are longar than 80 chars
	editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());

	// Creates the scollpane that contains the editor
	// FIXME: Cursor not visible when scrolling
	scrollPane = new JScrollPane();
	scrollPane.setBorder(BorderFactory.createEmptyBorder());
	scrollPane.getViewport().setOpaque(false);
	scrollPane.setVisible(false);
	scrollPane.setOpaque(false);

	// Installs custom actions
	editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
	textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);

	// Remembers the action map key for the enter keystroke
	editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
	textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:41,代碼來源:mxCellEditor.java

示例8: mxCellEditor

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * 
 */
public mxCellEditor(mxGraphComponent graphComponent) {
  this.graphComponent = graphComponent;

  // Creates the plain text editor
  textArea = new JTextArea();
  textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
  textArea.setOpaque(false);

  // Creates the HTML editor
  editorPane = new JEditorPane();
  editorPane.setOpaque(false);
  editorPane.setBackground(new Color(0, 0, 0, 0));
  editorPane.setContentType("text/html");

  // Workaround for inserted linefeeds in HTML markup with
  // lines that are longar than 80 chars
  editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());

  // Creates the scollpane that contains the editor
  // FIXME: Cursor not visible when scrolling
  scrollPane = new JScrollPane();
  scrollPane.setBorder(BorderFactory.createEmptyBorder());
  scrollPane.getViewport().setOpaque(false);
  scrollPane.setVisible(false);
  scrollPane.setOpaque(false);

  // Installs custom actions
  editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
  textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
  editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
  textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);

  // Remembers the action map key for the enter keystroke
  editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
  textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:40,代碼來源:mxCellEditor.java

示例9: makeEditorPane

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * Create a JEditorPane that will convert the text into html with working hyperlinks.
 * This can be included in a messageDialog with, e.g.
 * JOptionPane.showMessageDialog(null, ep)
 * @param text
 * @return
 */
public static JEditorPane makeEditorPane(String text) {
    // for copying style
    JLabel label = new JLabel();
    Font font = label.getFont();

    // create some css from the label's font
    StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
    style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
    style.append("font-size:" + font.getSize() + "pt;");
	
    //need to use editor pane and hyperlink listener so that we can include hyperlinks in help text
    JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
            + text //
            + "</body></html>");

    ep.addHyperlinkListener(new HyperlinkListener()
    {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e)
        {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
            	BrowseURL.browseURL(e.getURL().toString());
        }
    });
	ep.setEditable(false);
	ep.setBackground(label.getBackground());
	
	return ep;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:37,代碼來源:GeneralUtils.java

示例10: aboutMenuItemActionPerformed

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
Font font = new JLabel().getFont();

// Load HTML and set style to match the application's style
String html
	= Translations.get(
		"RaceFrame.help.about",
		font.getFamily(),
		(font.isBold() ? "bold" : "normal"),
		"" + font.getSize() + "pt");

// Create HTML content pane
JEditorPane ep = new JEditorPane("text/html", html);

// Handle link clicks
ep.addHyperlinkListener((HyperlinkEvent e) -> {
    if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
	try {
	    Desktop.getDesktop().browse(e.getURL().toURI());
	} catch (IOException | URISyntaxException ex) {
	    Logger.getLogger(RaceFrame.class.getName()).log(Level.SEVERE, null, ex);
	}
    }
});
ep.setEditable(false);
ep.setBackground(new JOptionPane().getBackground());

// Show dialog
JOptionPane.showMessageDialog(null, ep);
   }
 
開發者ID:Follpvosten,項目名稱:schneckenrennen,代碼行數:31,代碼來源:RaceFrame.java

示例11: createHtmlTextToolTip

import javax.swing.JEditorPane; //導入方法依賴的package包/類
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();

    // 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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:56,代碼來源:ToolTipSupport.java

示例12: showErrorMessage

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private void showErrorMessage() {
		 // for copying style
	    JLabel label = new JLabel();
	    Font font = label.getFont();

	    // create some css from the label's font
	    StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
	    style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
	    style.append("font-size:" + font.getSize() + "pt;");
		 JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">"//
		            + "TextToSpeech executable not found."
		            + "<br>Please make sure that the path variable leads to the espeak executable!"
		            + "<br>If you do not have espeak installed yet, please download it from <a href=http://espeak.sourceforge.net\">http://espeak.sourceforge.net</a>."
		            + "<br>Linux users can use the following command: 'sudo apt-get install espeak' " //
		            + "</body></html>");

		    // handle link events
		    ep.addHyperlinkListener(new HyperlinkListener()
		    {
		        @Override
		        public void hyperlinkUpdate(HyperlinkEvent e)
		        {
		            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
		            	if (Desktop.isDesktopSupported()) {
		            	      Desktop desktop = Desktop.getDesktop();
		            	      try {
		            	        desktop.browse(e.getURL().toURI());
		            	      } catch (IOException f) {
		            	        JOptionPane.showMessageDialog(null,
		            	            "Failed to launch the link, your computer is likely misconfigured.",
		            	            "Cannot Launch Link",JOptionPane.WARNING_MESSAGE);
		            	      } catch (URISyntaxException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
		            	    } else {
		            	      JOptionPane.showMessageDialog(null,
		            	          "Java is not able to launch links on your computer.",
		            	          "Cannot Launch Link", JOptionPane.WARNING_MESSAGE);
		            	    }
//		                ProcessHandler.launchUrl(e.getURL().toString()); // roll your own link launcher or use Desktop if J6+
		        }
		    });
		    ep.setEditable(false);
		    ep.setBackground(label.getBackground());

//
//		JOptionPane.showMessageDialog(PlayRelease.startGui, "TextToSpeech executable not found.\nPlease make sure that the path variable leads to the espeak executable!\nIf you do not have espeak installed yet, please downlaod it from '<HTML>http://espeak.sourceforge.net/</HTML>'."
//				+ "\n Linux users can use the following command: sudo apt-get install espeak","Error occurred",JOptionPane.ERROR_MESSAGE);
		JOptionPane.showMessageDialog(PlayRelease.startGui, ep,"Error occurred",JOptionPane.ERROR_MESSAGE);
	}
 
開發者ID:CognitiveModeling,項目名稱:BrainControl,代碼行數:52,代碼來源:TextToSpeech.java


注:本文中的javax.swing.JEditorPane.setBackground方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。