### Build and Show FXTrayIcon Immediately in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md This example demonstrates how to use the `.show()` option within the FXTrayIcon builder chain. This allows the tray icon to be displayed immediately after it's built, eliminating the need for a separate `.show()` method call. It also shows how to add multiple menu items and separators. ```java new FXTrayIcon.Builder(stage,icon) .menuItem("My Menu 1", e -> myMenuMethod1()) .menuItem("My Menu 2", e -> myMenuMethod2()) .separator() .menuItem("My Menu 3", e -> myMenuMethod3()) .separator() .menuItem("My Menu 4", e -> myMenuMethod4()) .addExitMenuItem() .show() .build(); ``` -------------------------------- ### Configure FXTrayIcon using Builder Pattern in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This example shows how to configure an FXTrayIcon using its fluent builder pattern. It allows chaining multiple configuration options like adding menu items and showing the icon before building the final object. ```Java FXTrayIcon icon = new FXTrayIcon.Builder(stage, iconURL).menuItem("Menu 1", e-> myMethod()).addExitItem().show().build(); ``` -------------------------------- ### Control FXTrayIcon Animation Playback in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This API documentation lists the methods available for controlling the playback of an FXTrayIcon animation. These methods allow starting, stopping, pausing, and resetting the animation. ```APIDOC trayIcon.play(); trayIcon.playFromStart(); trayIcon.stop(); trayIcon.pause(); trayIcon.pauseResume(); trayIcon.stopReset(); trayIcon.resetIcon(); ``` -------------------------------- ### Add Exit Menu Item to FXTrayIcon in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md These examples illustrate different ways to add an 'Exit' menu item to the FXTrayIcon. This special MenuItem is always placed at the bottom of the menu list and will close the application when invoked. Options include using the default label, a custom label, or providing a custom event handler for application closure. ```java new FXTrayIcon.Builder(stage,icon).addExitMenuItem().build(); ``` ```java new FXTrayIcon.Builder(stage,icon).addExitMenuItem("My Exit Menu Label").build(); ``` ```java new FXTrayIcon.Builder(stage,icon).addExitMenuItem("My Exit Label", e -> myExitMethod()).build(); ``` -------------------------------- ### Constructing FXTrayIcon Builder with various icon sources Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Demonstrates different ways to initialize the FXTrayIcon Builder, accepting various image sources like URL, File, JavaFX Image, or AWT Image, with or without specified dimensions. ```Java FXTrayIcon trayIcon = new FXTrayIcon.Builder(primaryStage, URL iconImagePath) FXTrayIcon trayIcon = new FXTrayIcon.Builder(primaryStage, java.io.File iconImageFile) FXTrayIcon trayIcon = new FXTrayIcon.Builder(primaryStage, javafx.scene.image.Image iconJavaFXImage) FXTrayIcon trayIcon = new FXTrayIcon.Builder(primaryStage, java.awt.Image iconJavaAWTImage) ``` ```Java FXTrayIcon trayIcon = new FXTrayIcon.Builder(primaryStage, URL iconImagePath, int width, int height) ``` -------------------------------- ### Adding a pre-built Menu as a sub-menu to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Explains how to integrate an entire pre-built `Menu` object, containing its own menu items, as a branched sub-menu within the FXTrayIcon. ```Java Menu menu = new Menu("My Sub Menu"); MenuItem myMenuItem1 = new MenuItem(); myMenuItem1.setOnAction(e-> myMenuMethod1()); MenuItem myMenuItem2 = new MenuItem(); myMenuItem2.setOnAction(e-> myMenuMethod2()); menu.getItems().addAll(myMenuItem1, myMenuItem2); new FXTrayIcon.Builder(stage,icon).menu(menu).build(); ``` -------------------------------- ### Adding a tooltip to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Demonstrates how to add a tooltip string that will appear when the mouse pointer hovers over the tray icon. ```Java new FXTrayIcon.Builder(stage,icon) .menuItem("My Menu 1", e -> myMenuMethod1()) .tooltip("This is your Tray Icon") .build(); ``` -------------------------------- ### Adding a dynamic sub-menu with MenuItems to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Shows how to create a branched sub-menu dynamically by providing a label for the sub-menu and a list of `MenuItem` objects directly to the builder's `menu` method. ```Java MenuItem myMenuItem1 = new MenuItem(); myMenuItem1.setOnAction(e-> myMenuMethod1()); MenuItem myMenuItem2 = new MenuItem(); myMenuItem2.setOnAction(e-> myMenuMethod2()); new FXTrayIcon.Builder(stage,icon).menu("My Sub Menu", menuItem1, menuItem2).build(); ``` -------------------------------- ### Adding a pre-built single MenuItem to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Illustrates how to add an already instantiated MenuItem object to the FXTrayIcon Builder, providing flexibility for pre-configured menu items. ```Java MenuItem myMenuItem = new MenuItem(); myMenuItem.setOnAction(e-> myMenuMethod()); new FXTrayIcon.Builder(stage,icon).menuItem(myMenuItem).build(); ``` -------------------------------- ### Adding multiple pre-built MenuItems to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Shows how to add multiple pre-instantiated MenuItem objects to the FXTrayIcon Builder using the `menuItems` method, useful for adding a collection of existing menu items. ```Java MenuItem myMenuItem1 = new MenuItem(); myMenuItem1.setOnAction(e-> myMenuMethod1()); MenuItem myMenuItem2 = new MenuItem(); myMenuItem2.setOnAction(e-> myMenuMethod2()); new FXTrayIcon.Builder(stage,icon).menuItems(myMenuItem1, myMenuItem2).build(); ``` -------------------------------- ### Adding multiple menu items dynamically to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Demonstrates how to chain multiple menuItem calls to add several menu items with their labels and actions in a single builder statement. ```Java new FXTrayIcon.Builder(stage,icon) .menuItem("My Menu 1", e -> myMenuMethod1()) .menuItem("My Menu 2", e -> myMenuMethod2()) .build(); ``` -------------------------------- ### Adding menu separator lines to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Illustrates how to insert separator lines within the tray icon's menu using the `separator()` method, maintaining the order of items as defined in the build chain. ```Java new FXTrayIcon.Builder(stage,icon) .menuItem("My Menu 1", e -> myMenuMethod1()) .menuItem("My Menu 2", e -> myMenuMethod2()) .separator() .menuItem("My Menu 3", e -> myMenuMethod3()) .checkMenuItem("Selection", e -> myCheckMenuMethod()) .separator() .menuItem("My Menu 4", e -> myMenuMethod4()) .build(); ``` -------------------------------- ### Adding CheckMenuItems within a sub-menu to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Demonstrates how to include `CheckMenuItem` objects alongside regular `MenuItem`s within a pre-built `Menu` that is then added as a sub-menu to the FXTrayIcon. ```Java Menu menu = new Menu("My Sub Menu"); MenuItem myMenuItem1 = new MenuItem(); CheckMenuItem myCheckMenuItem = new CheckMenuItem(); myMenuItem1.setOnAction(e-> myMenuMethod1()); myCheckMenuItem.setOnAction(e-> myCheckMenuMethod()); MenuItem myMenuItem2 = new MenuItem(); myMenuItem2.setOnAction(e-> myMenuMethod2()); menu.getItems().addAll(myMenuItem1, myMenuItem2); new FXTrayIcon.Builder(stage,icon).menu(menu).checkMenuItem(myCheckMenuItem).build(); ``` -------------------------------- ### Prepare Image Files for FXTrayIcon Animation in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This Java code demonstrates how to load image files from a directory into a sorted LinkedList, which can then be used as frames for an animated FXTrayIcon. It's recommended to number files sequentially for proper sorting. ```Java File[] files = new File("path/to/my/imageFiles").listFiles(); LinkedList fileList = new LinkedList<>(Arrays.asList(files)); fileList.sort(Comparator.comparing(File::getName)); ``` -------------------------------- ### Adding a custom application title item to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Illustrates how to add a custom application title string as the top menu item, which, when clicked, will bring the main stage into view. ```Java new FXTrayIcon.Builder(stage,icon).applicationTitle("My Application Title").build(); ``` -------------------------------- ### Adding a single menu item dynamically to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Shows how to add a single menu item to the FXTrayIcon Builder by providing its label and an action event, allowing for dynamic menu creation. ```Java new FXTrayIcon.Builder(stage,icon).menuItem("My Menu", e -> myMenuMethod()).build(); ``` -------------------------------- ### Initialize and Show FXTrayIcon in JavaFX Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This snippet demonstrates the simplest way to initialize and display a system tray icon in a JavaFX application. It requires passing the main stage of the application and the path to the icon image. ```Java // Pass in the app's main stage, and path to the icon image FXTrayIcon icon = new FXTrayIcon(stage, getClass().getResource("someImageFile.png")); icon.show(); ``` -------------------------------- ### Adding an automatic application title item to FXTrayIcon Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md Shows how to add a special 'TitleItem' to the top of the menu, which automatically uses the application's title and brings the main stage into view when clicked. ```Java new FXTrayIcon.Builder(stage,icon).addTitleItem(true).build(); ``` -------------------------------- ### Animate FXTrayIcon using Builder Pattern in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This Java snippet shows how to integrate an animation into an FXTrayIcon using the builder pattern. It takes a list of image files and a frame delay in milliseconds to create a dynamic tray icon. ```Java trayIcon = new FXTrayIcon.Builder(primaryStage, iconFile) .animate(fileList, 75) .addExitMenuItem("Exit", e -> Main.stopRunning()) .show() .build(); ``` -------------------------------- ### FXTrayIcon System Tray Support Check Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md Method to check if the current operating system platform supports the system tray functionality provided by FXTrayIcon. Note that this method might not be entirely reliable on all Linux desktop environments. ```APIDOC FXTrayIcon.isSupported() ``` -------------------------------- ### Add FXTrayIcon Dependency to Gradle Project Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This Groovy snippet demonstrates how to include the FXTrayIcon library as a dependency in a Gradle build file. The version placeholder should be updated with the latest stable release. ```Groovy compile group: 'com.dustinredmond.fxtrayicon', name: 'FXTrayIcon', version: '' ``` -------------------------------- ### Handle FXTrayIcon Left Click Action in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/BuilderTutorial.md This snippet demonstrates how to attach an event handler to the FXTrayIcon builder. The specified method will be invoked upon a left-click action on the tray icon. Note that on macOS, both left and right mouse buttons must be clicked simultaneously to trigger the event. ```java new FXTrayIcon.Builder(stage,icon).onAction(e -> myMethod()).build(); ``` -------------------------------- ### Add FXTrayIcon Dependency to Groovy Script using Grapes Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This Groovy snippet illustrates how to add the FXTrayIcon library as a dependency directly within a Groovy script using Grapes. This is useful for quick scripting without a full build system. ```Groovy @Grapes( @Grab(group='com.dustinredmond.fxtrayicon', module='FXTrayIcon', version='') ) ``` -------------------------------- ### Add FXTrayIcon Dependency to Maven Project Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This XML snippet shows how to add the FXTrayIcon library as a dependency to a Maven project. Users should replace the version placeholder with the current stable version number. ```XML com.dustinredmond.fxtrayicon FXTrayIcon ``` -------------------------------- ### Change FXTrayIcon Animation After Instantiation in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This Java code demonstrates how to apply or replace an animation on an already instantiated FXTrayIcon object. It accepts a list of image files and the desired frame duration in milliseconds. ```Java trayIcon.newAnimation(fileList, 75); ``` -------------------------------- ### FXTrayIcon Notification Methods Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md Methods available in FXTrayIcon for displaying various types of system tray notifications, including default, informational, warning, and error messages. These methods use the FXTrayIcon's icon or specific severity icons. ```APIDOC FXTrayIcon Notification Methods: - showMessage(String caption, String content) - showMessage(String content) - showInfoMessage(String caption, String content) - showInfoMessage(String content) - showWarnMessage(String caption, String content) - showWarnMessage(String content) - showErrorMessage(String caption, String content) - showErrorMessage(String content) ``` -------------------------------- ### Query FXTrayIcon Animation State in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This API documentation outlines the methods used to check the current state of an FXTrayIcon animation. These boolean methods indicate whether the animation is running, paused, or stopped. ```APIDOC trayIcon.isRunning(); trayIcon.isPaused(); trayIcon.isStopped(); ``` -------------------------------- ### Access FXTrayIcon Animation Timeline in Java Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md This API documentation provides the method to retrieve the underlying Timeline object of the FXTrayIcon animation. This allows advanced control or inspection of the animation's timing. ```APIDOC trayIcon.getTimeline() ``` -------------------------------- ### Accessing Underlying AWT TrayIcon Object Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md Methods to gain access to the underlying java.awt.TrayIcon object from an FXTrayIcon instance. This is useful for scenarios requiring direct interaction with AWT components. ```APIDOC FXTrayIcon: - getTrayIcon(): Protected method, accessible by extending FXTrayIcon. - getRestricted(): Provides access to the TrayIcon object after instantiation. ``` -------------------------------- ### Setting FXTrayIcon Default Icon Size Source: https://github.com/dustinkredmond/fxtrayicon/blob/main/README.md Methods to override the default icon size used by FXTrayIcon. These values will be applied where an icon size is not explicitly required, including for animation features. Can be set during build or after instantiation. ```Java .setIconSize(width, height); .setIconSize(oneValueWH); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.