Changeset 6935 in josm for trunk


Ignore:
Timestamp:
2014-03-27T23:07:34+01:00 (6 years ago)
Author:
Don-vip
Message:

see #3764 - special handling for Nimbus

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/GettingStarted.java

    r6897 r6935  
    5757            setOpaque(false);
    5858            addHyperlinkListener(this);
     59            adaptForNimbus(this);
    5960        }
    6061
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java

    r6932 r6935  
    22package org.openstreetmap.josm.gui.widgets;
    33
     4import java.awt.Color;
    45import java.awt.Font;
    56import java.io.IOException;
     
    1011
    1112import javax.swing.JEditorPane;
     13import javax.swing.LookAndFeel;
     14import javax.swing.UIDefaults;
    1215import javax.swing.UIManager;
    1316import javax.swing.text.html.StyleSheet;
     
    8083        return result;
    8184    }
    82 
     85   
    8386    /**
    84      * Adapts an {@link JEditorPane} to be used as a powerful replacement of {@link javax.swing.JLabel}.
     87     * Adapts a {@link JEditorPane} to be used as a powerful replacement of {@link javax.swing.JLabel}.
    8588     * @param pane The editor pane to adapt
    8689     * @param allBold If {@code true}, makes all text to be displayed in bold
     
    9093        pane.setOpaque(false);
    9194        pane.setEditable(false);
     95        adaptForNimbus(pane);
    9296
    9397        JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
     
    103107    }
    104108
     109    /**
     110     * Adapts a {@link JEditorPane} for Nimbus look and feel.
     111     * See <a href="https://stackoverflow.com/q/15228336/2257172">this StackOverflow question</a>.
     112     * @param pane The editor pane to adapt
     113     * @since 6935
     114     */
     115    public static void adaptForNimbus(JEditorPane pane) {
     116        LookAndFeel currentLAF = UIManager.getLookAndFeel();
     117        if (currentLAF != null && "Nimbus".equals(currentLAF.getName())) {
     118            Color bgColor = UIManager.getColor("Label.background");
     119            UIDefaults defaults = new UIDefaults();
     120            defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
     121            pane.putClientProperty("Nimbus.Overrides", defaults);
     122            pane.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
     123            pane.setBackground(bgColor);
     124        }
     125    }
     126
    105127    private static String getFontRule(Font f) {
    106128        return MessageFormat.format(
Note: See TracChangeset for help on using the changeset viewer.