Class JXTipOfTheDay

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, AlphaPaintable, BackgroundPaintable

@JavaBean public class JXTipOfTheDay extends JXPanel
Provides the "Tip of The Day" pane and dialog.

Tips are retrieved from the TipOfTheDayModel. In the most common usage, a tip (as returned by TipOfTheDayModel.Tip.getTip()) is just a String. However, the return type of this method is actually Object. Its interpretation depends on its type:

Component
The Component is displayed in the dialog.
Icon
The Icon is wrapped in a JLabel and displayed in the dialog.
others
The object is converted to a String by calling its toString method. The result is wrapped in a JEditorPane or JTextArea and displayed.

JXTipOfTheDay finds its tips in its TipOfTheDayModel. Such model can be programmatically built using DefaultTipOfTheDayModel and DefaultTip but the TipLoader provides a convenient method to build a model and its tips from a Properties object.

Example:

Let's consider a file tips.properties with the following content:

 
 tip.1.description=This is the first time! Plain text.
 tip.2.description=<html>This is <b>another tip</b>, it uses HTML!
 tip.3.description=A third one
 
 
To load and display the tips:
 
 Properties tips = new Properties();
 tips.load(new FileInputStream("tips.properties"));
 
 TipOfTheDayModel model = TipLoader.load(tips);
 JXTipOfTheDay totd = new JXTipOfTheDay(model);
 
 totd.showDialog(someParentComponent);
 
 

Additionally, JXTipOfTheDay features an option enabling the end-user to choose to not display the "Tip Of The Day" dialog. This user choice can be stored in the user Preferences but JXTipOfTheDay also supports custom storage through the JXTipOfTheDay.ShowOnStartupChoice interface.

 
 Preferences userPreferences = Preferences.userRoot().node("myApp");
 totd.showDialog(someParentComponent, userPreferences);
 
 
In this code, the first time showDialog is called, the dialog will be made visible and the user will have the choice to not display it again in the future (usually this is controlled by a checkbox "Show tips on startup"). If the user unchecks the option, subsequent calls to showDialog will not display the dialog. As the choice is saved in the user Preferences, it will persist when the application is relaunched.
See Also:
  • Field Details

    • uiClassID

      public static final String uiClassID
      JXTipOfTheDay pluggable UI key swingx/TipOfTheDayUI
      See Also:
    • PREFERENCE_KEY

      public static final String PREFERENCE_KEY
      Key used to store the status of the "Show tip on startup" checkbox"
      See Also:
    • CURRENT_TIP_CHANGED_KEY

      public static final String CURRENT_TIP_CHANGED_KEY
      Used when generating PropertyChangeEvents for the "currentTip" property
      See Also:
    • model

      private TipOfTheDayModel model
    • currentTip

      private int currentTip
  • Constructor Details

    • JXTipOfTheDay

      public JXTipOfTheDay()
      Constructs a new JXTipOfTheDay with an empty TipOfTheDayModel
    • JXTipOfTheDay

      public JXTipOfTheDay(TipOfTheDayModel model)
      Constructs a new JXTipOfTheDay showing tips from the given TipOfTheDayModel.
      Parameters:
      model -
  • Method Details