Java JEditorPane setJEditorPaneBackground(javax.swing.JEditorPane jEditorPane, Color color)

Here you can find the source of setJEditorPaneBackground(javax.swing.JEditorPane jEditorPane, Color color)

Description

Set background colour of a JEditorPane.

License

Open Source License

Parameter

Parameter Description
JEditorPane the pane to apply the background colour to
color the colour to be applied to the panel.

Declaration

public static void setJEditorPaneBackground(javax.swing.JEditorPane jEditorPane, Color color) 

Method Source Code


//package com.java2s;
/*/*  w ww .  j ava2  s . c om*/
 This file is part of the BlueJ program. 
 Copyright (C) 1999-2009,2011,2012,2013,2014  Michael Kolling and John Rosenberg 
     
 This program is free software; you can redistribute it and/or 
 modify it under the terms of the GNU General Public License 
 as published by the Free Software Foundation; either version 2 
 of the License, or (at your option) any later version. 
     
 This program is distributed in the hope that it will be useful, 
 but WITHOUT ANY WARRANTY; without even the implied warranty of 
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 GNU General Public License for more details. 
     
 You should have received a copy of the GNU General Public License 
 along with this program; if not, write to the Free Software 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
     
 This file is subject to the Classpath exception as provided in the  
 LICENSE.txt file that accompanied this code.
 */

import java.awt.Color;

import javax.swing.UIDefaults;

public class Main {
    /**
     * Set background colour of a JEditorPane.
     * based on fix from: https://community.oracle.com/thread/1356459
     * @param JEditorPane     the pane to apply the background colour to
     * @param color           the colour to be applied to the panel.
     */
    public static void setJEditorPaneBackground(javax.swing.JEditorPane jEditorPane, Color color) {
        Color bgColor = new Color(250, 246, 229);
        UIDefaults defaults = new UIDefaults();
        defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
        jEditorPane.putClientProperty("Nimbus.Overrides", defaults);
        jEditorPane.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
        jEditorPane.setBackground(bgColor);
    }
}

Related

  1. panelForHtml(JEditorPane editorPane)
  2. scrollToTop(final JEditorPane editor)
  3. scrollToTop(JEditorPane editor)
  4. setDefaultFontToEditorPane(JEditorPane editor, boolean justify)
  5. SetEditorProperties(JEditorPane editor, String text)
  6. setParagraphAttributes(final AttributeSet attr, final boolean replace, final JEditorPane editorPane, final StyledDocument doc)
  7. start(JEditorPane textPane)