| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jdesktop.swingx.JXPanel
org.jdesktop.swingx.JXTipOfTheDay
public class JXTipOfTheDay
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 is displayed in the dialog.
 Icon is wrapped in a JLabel and
 displayed in the dialog.
 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.
TipLoader, 
TipOfTheDayModel, 
TipOfTheDayModel.Tip, 
showDialog(Component, Preferences), 
showDialog(Component, ShowOnStartupChoice), 
Serialized Form| Nested Class Summary | |
|---|---|
static interface | 
JXTipOfTheDay.ShowOnStartupChoice
Used in conjunction with the showDialog(Component, ShowOnStartupChoice) to save the
 "Show tips on startup" choice. | 
| Nested classes/interfaces inherited from class javax.swing.JPanel | 
|---|
JPanel.AccessibleJPanel | 
| Nested classes/interfaces inherited from class javax.swing.JComponent | 
|---|
JComponent.AccessibleJComponent | 
| Nested classes/interfaces inherited from class java.awt.Container | 
|---|
Container.AccessibleAWTContainer | 
| Nested classes/interfaces inherited from class java.awt.Component | 
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy | 
| Field Summary | |
|---|---|
static String | 
CURRENT_TIP_CHANGED_KEY
Used when generating PropertyChangeEvents for the "currentTip" property  | 
static String | 
PREFERENCE_KEY
Key used to store the status of the "Show tip on startup" checkbox"  | 
static String | 
uiClassID
JXTipOfTheDay pluggable UI key swingx/TipOfTheDayUI  | 
| Fields inherited from class javax.swing.JComponent | 
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW | 
| Fields inherited from class java.awt.Component | 
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT | 
| Fields inherited from interface java.awt.image.ImageObserver | 
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| Constructor Summary | |
|---|---|
JXTipOfTheDay()
Constructs a new JXTipOfTheDay with an empty
 TipOfTheDayModel | 
|
JXTipOfTheDay(TipOfTheDayModel model)
Constructs a new JXTipOfTheDay showing tips from the given
 TipOfTheDayModel. | 
|
| Method Summary | |
|---|---|
protected  JDialog | 
createDialog(Component parentComponent,
             JXTipOfTheDay.ShowOnStartupChoice choice)
Calls TipOfTheDayUI.createDialog(Component, JXTipOfTheDay.ShowOnStartupChoice). | 
static void | 
forceShowOnStartup(Preferences showOnStartupPref)
Removes the value set for "ShowTipOnStartup" in the given Preferences to ensure the dialog shown by a later call to showDialog(Component, Preferences) will be visible to the user. | 
 int | 
getCurrentTip()
 | 
 TipOfTheDayModel | 
getModel()
 | 
 TipOfTheDayUI | 
getUI()
Gets the UI object which implements the L&F for this component.  | 
 String | 
getUIClassID()
Returns the name of the L&F class that renders this component.  | 
static boolean | 
isShowingOnStartup(Preferences showOnStartupPref)
 | 
 void | 
nextTip()
Shows the next tip in the list.  | 
 void | 
previousTip()
Shows the previous tip in the list.  | 
 void | 
setCurrentTip(int currentTip)
Sets the index of the tip to show  | 
 void | 
setModel(TipOfTheDayModel model)
 | 
 void | 
setUI(TipOfTheDayUI ui)
Sets the L&F object that renders this component.  | 
 void | 
showDialog(Component parentComponent)
Pops up a "Tip of the day" dialog.  | 
 boolean | 
showDialog(Component parentComponent,
           JXTipOfTheDay.ShowOnStartupChoice choice)
Pops up a "Tip of the day" dialog.  | 
 boolean | 
showDialog(Component parentComponent,
           JXTipOfTheDay.ShowOnStartupChoice choice,
           boolean force)
Pops up a "Tip of the day" dialog.  | 
 boolean | 
showDialog(Component parentComponent,
           Preferences showOnStartupPref)
Pops up a "Tip of the day" dialog.  | 
 boolean | 
showDialog(Component parentComponent,
           Preferences showOnStartupPref,
           boolean force)
Pops up a "Tip of the day" dialog.  | 
 void | 
updateUI()
Notification from the UIManager that the L&F has changed. | 
| Methods inherited from class javax.swing.JPanel | 
|---|
getAccessibleContext, paramString, setUI | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
public static final String uiClassID
public static final String PREFERENCE_KEY
public static final String CURRENT_TIP_CHANGED_KEY
| Constructor Detail | 
|---|
public JXTipOfTheDay()
JXTipOfTheDay with an empty
 TipOfTheDayModel
public JXTipOfTheDay(TipOfTheDayModel model)
JXTipOfTheDay showing tips from the given
 TipOfTheDayModel.
model - | Method Detail | 
|---|
public void updateUI()
UIManager that the L&F has changed.
 Replaces the current UI object with the latest version from the
 UIManager.
updateUI in class JPanelJComponent.updateUI()public void setUI(TipOfTheDayUI ui)
ui - the TipOfTheDayUI L&F objectUIDefaults.getUI(javax.swing.JComponent)public TipOfTheDayUI getUI()
getUI in class JPanelpublic String getUIClassID()
getUIClassID in class JPaneluiClassIDJComponent.getUIClassID(), 
UIDefaults.getUI(javax.swing.JComponent)public TipOfTheDayModel getModel()
public void setModel(TipOfTheDayModel model)
public int getCurrentTip()
public void setCurrentTip(int currentTip)
currentTip - 
IllegalArgumentException - if currentTip is not within the bounds [0,
        getModel().getTipCount()[.public void nextTip()
public void previousTip()
public void showDialog(Component parentComponent)
                throws HeadlessException
parentComponent - 
HeadlessException - if GraphicsEnvironment.isHeadless() returns true.GraphicsEnvironment.isHeadless()
public boolean showDialog(Component parentComponent,
                          Preferences showOnStartupPref)
                   throws HeadlessException
parentComponent - showOnStartupPref - 
HeadlessException - if GraphicsEnvironment.isHeadless() returns true.
IllegalArgumentException - if showOnStartupPref is nullGraphicsEnvironment.isHeadless()
public boolean showDialog(Component parentComponent,
                          Preferences showOnStartupPref,
                          boolean force)
                   throws HeadlessException
parentComponent - showOnStartupPref - force - if true, the dialog is displayed even if the Preferences is set to
          hide the dialog
HeadlessException - if GraphicsEnvironment.isHeadless() returns true.
IllegalArgumentException - if showOnStartupPref is nullGraphicsEnvironment.isHeadless()
public boolean showDialog(Component parentComponent,
                          JXTipOfTheDay.ShowOnStartupChoice choice)
choice is not null, the method first checks if
 JXTipOfTheDay.ShowOnStartupChoice.isShowingOnStartup() is true before showing the
 dialog.
 
 Additionally, it saves the state of the "Show tips on startup" checkbox
 using the given JXTipOfTheDay.ShowOnStartupChoice object.
parentComponent - choice - 
HeadlessException - if GraphicsEnvironment.isHeadless() returns true.GraphicsEnvironment.isHeadless()
public boolean showDialog(Component parentComponent,
                          JXTipOfTheDay.ShowOnStartupChoice choice,
                          boolean force)
choice is not null, the method first checks if
 force is true or if
 JXTipOfTheDay.ShowOnStartupChoice.isShowingOnStartup() is true before showing the
 dialog.
 
 Additionally, it saves the state of the "Show tips on startup" checkbox
 using the given JXTipOfTheDay.ShowOnStartupChoice object.
parentComponent - choice - force - if true, the dialog is displayed even if
          JXTipOfTheDay.ShowOnStartupChoice.isShowingOnStartup() is false
HeadlessException - if GraphicsEnvironment.isHeadless() returns true.GraphicsEnvironment.isHeadless()public static boolean isShowingOnStartup(Preferences showOnStartupPref)
showOnStartupPref - 
public static void forceShowOnStartup(Preferences showOnStartupPref)
showDialog(Component, Preferences) will be visible to the user.
showOnStartupPref - 
protected JDialog createDialog(Component parentComponent,
                               JXTipOfTheDay.ShowOnStartupChoice choice)
TipOfTheDayUI.createDialog(Component, JXTipOfTheDay.ShowOnStartupChoice).
 
 This method can be overriden in order to control things such as the
 placement of the dialog or its title.
parentComponent - choice - 
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||