| // |
| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| // |
| |
| = DevFaqImagesForDarkLaf |
| :jbake-type: wiki |
| :jbake-tags: wiki, devfaq, needsreview |
| :jbake-status: published |
| :keywords: Apache NetBeans wiki DevFaqImagesForDarkLaf |
| :description: Apache NetBeans wiki DevFaqImagesForDarkLaf |
| :toc: left |
| :toc-title: |
| :syntax: true |
| |
| = How to provide non-inverted images for dark LookAndFeels like DarkMetal/Darcula? |
| |
| == In short |
| |
| * All images will be inverted, when using a DarkLaF with an image filter applied and ImageUtilities is used |
| * If you don't like the inverted image/icon, then provide a image using "_dark" in its name. It will be used without any filter applied. |
| |
| == Details |
| |
| LaFs like DarkMetal/Darcula "invert" the colors of all the images/icons via an image filter set like `UIManager.put("nb.imageicon.filter", new DarkIconFilter())` |
| |
| This filter is used when loading images/icons via |
| `org.openide.util.ImageUtilities#loadImageIcon` and `org.openide.util.ImageUtilities#loadImage`. |
| |
| === You do not like the inverted colors? Provide your own images! |
| |
| But there are cases, you don't want to get your image inverted. |
| |
| For example in the following screenshot you do not want the NB logo in the about dialog to be inverted! |
| image:YouDontwantyourImageinverted.jpg[] |
| |
| In this case provide an image with a specific name scheme. Add "`_dark`" to the name. This image is taken as it is and no filter will be applied. |
| |
| *Scheme:* |
| |
| * `about.png` -> `about_dark.png` |
| * But be aware of brandings! Then it must be `about_dark_BRANDING.png` |
| |
| === It still does not work? Migrate from ImageIcon... |
| |
| Check that your code really loads the images via `org.openide.util.ImageUtilities#loadImageIcon` and `org.openide.util.ImageUtilities#loadImage`! |
| |
| Dialogs built using the Mantisse GUI Builder often use `new javax.swing.ImageIcon` constructs. |
| |
| So here some replacements patterns to migrate such dialogs. |
| |
| [source,xml] |
| ---- |
| |
| |
| // within *.java |
| new javax\.swing\.ImageIcon\(getClass\(\)\.getResource\("(.+?)"\)\) |
| // with |
| org.openide.util.ImageUtilities.loadImageIcon\("$1", false\) |
| |
| // within *.form |
| <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> |
| // with |
| <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
| |
| // within *.form |
| <Image iconType="3" name="(.*?)"/> |
| with |
| <Connection code="org.openide.util.ImageUtilities.loadImageIcon\(&amp;quot;$1&amp;quot;, false\)" type="code"/> |
| |
| ---- |
| |
| === Examples |
| |
| Without Invert: |
| |
| image:LafWithoutInvert.png[] |
| |
| With Invert enabled and *_dark.png for the logo and startpage images: |
| |
| image:LafWithInvert.png[] |
| |
| == Related issues |
| |
| === Handling Branding |
| |
| Platform applications using Dark Look And Feels require the following for branding-related image adjustments (as discussed in link:http://forums.netbeans.org/topic66964.html[http://forums.netbeans.org/topic66964.html]): |
| |
| 1. For frame images, the images must be named using the _dark suffix (frame_dark.gif, frame32_dark.gif, and frame48_dark.gif). |
| 2. For splash images, both a dark and non-dark version are required (splash.gif, splash_dark.gif). |
| |
| These images are typically found in the branding/core/core.jar/org/netbeans/core/startup folder for the application. |
| |
| As of Netbeans 8.2, the Branding dialog within the Netbeans IDE is not designed for these dark theme image requirements. Users using a dark theme will want to make image name changes directly within the filesystem to meet these requirements. |
| |
| === Handling textareas/textfields |
| |
| If you have displaying issues with your controls, try to set the `HONOR_DISPLAY_PROPERTIES`-clientproperty. |
| |
| ` |
| |
| [source,java] |
| ---- |
| |
| pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); |
| //and/or |
| pane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); |
| ---- |
| |
| ` |
| |
| === Apache Migration Information |
| |
| The content in this page was kindly donated by Oracle Corp. to the |
| Apache Software Foundation. |
| |
| This page was exported from link:http://wiki.netbeans.org/DevFaqImagesForDarkLaf[http://wiki.netbeans.org/DevFaqImagesForDarkLaf] , |
| that was last modified by NetBeans user Markiewb |
| on 2016-12-19T22:06:17Z. |
| |
| |
| *NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed. |