All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javafx.application.PlatformPreferences Maven / Gradle / Ivy

/*
 * Copyright (c) 2022, JFXcore. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  JFXcore designates this
 * particular file as subject to the "Classpath" exception as provided
 * in the LICENSE file that accompanied this code.
 *
 * This code 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
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package javafx.application;

import javafx.scene.paint.Color;
import javafx.util.Incubating;
import java.util.Map;

/**
 * Contains UI preferences of the current platform.
 * 

* {@code PlatformPreferences} implements {@link Map} to expose platform preferences as key-value pairs. * For convenience, {@link #getString}, {@link #getBoolean} and {@link #getColor} are provided as typed * alternatives to the untyped {@link #get} method. *

* An application should not expect all preferences to be available on a particular platform. * For example, the {@code Windows.UIColor.*} preferences are only available starting with Windows 10 build 10240. *

* The following list contains all preferences that are potentially available on the specified platforms: *

    *
  1. Windows *

    *

    * * * *
    High contrast color scheme, reported by {@code SystemParametersInfo}
    {@code Windows.SPI.HighContrastOn}{@link Boolean}
    {@code Windows.SPI.HighContrastColorScheme}{@link String}
    *

    *

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    System colors, reported by {@code GetSysColor}
    {@code Windows.SysColor.COLOR_3DDKSHADOW}{@link Color}
    {@code Windows.SysColor.COLOR_3DFACE}{@link Color}
    {@code Windows.SysColor.COLOR_3DHIGHLIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_3DHILIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_3DLIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_3DSHADOW}{@link Color}
    {@code Windows.SysColor.COLOR_ACTIVEBORDER}{@link Color}
    {@code Windows.SysColor.COLOR_ACTIVECAPTION}{@link Color}
    {@code Windows.SysColor.COLOR_APPWORKSPACE}{@link Color}
    {@code Windows.SysColor.COLOR_BACKGROUND}{@link Color}
    {@code Windows.SysColor.COLOR_BTNFACE}{@link Color}
    {@code Windows.SysColor.COLOR_BTNHIGHLIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_BTNHILIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_BTNSHADOW}{@link Color}
    {@code Windows.SysColor.COLOR_BTNTEXT}{@link Color}
    {@code Windows.SysColor.COLOR_CAPTIONTEXT}{@link Color}
    {@code Windows.SysColor.COLOR_DESKTOP}{@link Color}
    {@code Windows.SysColor.COLOR_GRADIENTACTIVECAPTION}{@link Color}
    {@code Windows.SysColor.COLOR_GRADIENTINACTIVECAPTION}{@link Color}
    {@code Windows.SysColor.COLOR_GRAYTEXT}{@link Color}
    {@code Windows.SysColor.COLOR_HIGHLIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_HIGHLIGHTTEXT}{@link Color}
    {@code Windows.SysColor.COLOR_HOTLIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_INACTIVEBORDER}{@link Color}
    {@code Windows.SysColor.COLOR_INACTIVECAPTION}{@link Color}
    {@code Windows.SysColor.COLOR_INACTIVECAPTIONTEXT}{@link Color}
    {@code Windows.SysColor.COLOR_INFOBK}{@link Color}
    {@code Windows.SysColor.COLOR_INFOTEXT}{@link Color}
    {@code Windows.SysColor.COLOR_MENU}{@link Color}
    {@code Windows.SysColor.COLOR_MENUHILIGHT}{@link Color}
    {@code Windows.SysColor.COLOR_MENUBAR}{@link Color}
    {@code Windows.SysColor.COLOR_MENUTEXT}{@link Color}
    {@code Windows.SysColor.COLOR_SCROLLBAR}{@link Color}
    {@code Windows.SysColor.COLOR_WINDOW}{@link Color}
    {@code Windows.SysColor.COLOR_WINDOWFRAME}{@link Color}
    {@code Windows.SysColor.COLOR_WINDOWTEXT}{@link Color}
    *

    *

    * * * * * * * * * * *
    Theme colors, reported by {@code Windows.UI.ViewManagement.UISettings}
    {@code Windows.UIColor.Background}{@link Color}
    {@code Windows.UIColor.Foreground}{@link Color}
    {@code Windows.UIColor.AccentDark3}{@link Color}
    {@code Windows.UIColor.AccentDark2}{@link Color}
    {@code Windows.UIColor.AccentDark1}{@link Color}
    {@code Windows.UIColor.Accent}{@link Color}
    {@code Windows.UIColor.AccentLight1}{@link Color}
    {@code Windows.UIColor.AccentLight2}{@link Color}
    {@code Windows.UIColor.AccentLight3}{@link Color}
    * Note that {@code Windows.UI.ViewManagement.UISettings} is available since Windows 10 build 10240. *

    * *

  2. macOS *

    Platform preferences are currently not reported on macOS. * *

  3. Linux *

    Platform preferences are currently not reported on Linux. *

* * @since JFXcore 18 */ @Incubating public interface PlatformPreferences extends Map { /** * Returns the {@link String} instance to which the specified key is mapped. * * @param key the key * @return the {@code String} instance to which the {@code key} is mapped, or * {@code null} if the key is not mapped to a {@code String} instance */ String getString(String key); /** * Returns the {@link String} instance to which the specified key is mapped, * or a fallback value if the key is not mapped to a {@code String} instance. * * @param key the key * @return the {@code String} instance to which the {@code key} is mapped, or * {@code fallbackValue} if the key is not mapped to a {@code String} * instance */ String getString(String key, String fallbackValue); /** * Returns the {@link Boolean} instance to which the specified key is mapped. * * @param key the key * @return the {@code Boolean} instance to which the {@code key} is mapped, or * {@code null} if the key is not mapped to a {@code Boolean} instance */ Boolean getBoolean(String key); /** * Returns the {@code boolean} value to which the specified key is mapped, * or a fallback value if the key is not mapped to a {@code boolean} value. * * @param key the key * @return the {@code boolean} value to which the {@code key} is mapped, or * {@code fallbackValue} if the key is not mapped to a {@code boolean} * value */ boolean getBoolean(String key, boolean fallbackValue); /** * Returns the {@link Color} instance to which the specified key is mapped. * * @param key the key * @return the {@code Color} instance to which the {@code key} is mapped, or * {@code null} if the key is not mapped to a {@code Color} instance */ Color getColor(String key); /** * Returns the {@link Color} instance to which the specified key is mapped, * or a fallback value if the key is not mapped to a {@code Color} instance. * * @param key the key * @return the {@code Color} instance to which the {@code key} is mapped, or * {@code fallbackValue} if the key is not mapped to a {@code Color} * instance */ Color getColor(String key, Color fallbackValue); /** * Adds the specified listener to this {@code PlatformPreferences} instance. * * @param listener the {@code PlatformPreferencesListener} */ void addListener(PlatformPreferencesListener listener); /** * Removes the specified listener from this {@code PlatformPreferences} instance. * * @param listener the {@code PlatformPreferencesListener} */ void removeListener(PlatformPreferencesListener listener); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy