HomeAPIGuideSF Project Home

JAPI: Using TipOfTheDayManager

This part of the guide demonstrates how to use the TipOfTheDayManager to extend your application with Tip Of The Days.

The TipOfTheDayManager allows you to easily add Tip Of The Days to your application.

Screenshots of sample applicationScreenshot of sample tip of the day (English)Screenshot of sample tip of the day (German)

Complete source

Java Source

Location: ex/App.class

package ex;
import javax.swing.JButton;
import javax.swing.JFrame;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
import net.sf.japi.swing.ActionFactory;
import net.sf.japi.swing.TipOfTheDayManager;
public class App {
   
public static void main(final String... args) {
       
//System.setProperty("net.sf.japi.swing.tod", "ex.tod");
       
new App();
   
}
   
final JFrame frame;
   
public App() {
       
final ActionFactory actionFactory = ActionFactory.getFactory("ex");
        frame =
new JFrame(actionFactory.getString("frame.title"));
        frame.add
(new JButton(actionFactory.createAction(false, "showTod", this)));
        frame.pack
();
        frame.setDefaultCloseOperation
(DISPOSE_ON_CLOSE);
        frame.setVisible
(true);
        TipOfTheDayManager.showAtStartup
(frame);
   
}
   
public void showTod() {
       
TipOfTheDayManager.show(frame);
   
}
}

Properties

Location: ex/tod.properties

tod.text.1=<html>This little App easily shows a Tip Of The Day at Startup.
tod.text.2=<html>You can build your own apps with a Tip Of The Day.
tod.text.3=<html>The Tip Of The Day can also be accessed during runtime.

Location: ex/action.properties

frame.title=Tip Of The Day Demo
showTod.text=Show Tip Of The Day Window

Services

Location: META-INF/services/net.sf.japi.swing.tod

ex.tod

Conclusion

It never was that easy!

Alternatives

Currently, the TipOfTheDayManager supports two ways to specify the properties containing the tips, queried in exactly that order:

  1. System Property net.sf.japi.swing.tod
  2. File META-INF/services/net.sf.japi.swing.tod
SourceForge.net LogoSupport This ProjectValid HTML 4.01!Valid CSS! Feedback: webmaster
$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $