当前位置: 首页>>代码示例>>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;未经允许,请勿转载。