|
BuildYourFirstDesklet
A quick introduction to building your first desklet
A quick tutorial to build a simple desklet.Getting a project set up
Creating your deskletCreate a new class like MyAppDesklet_. Make MyAppDesklet subclass ab5k.Desklet and implement the abstract methods Make a main method like this: public static void main(String ... args) {
DeskletTester.start(myapp.MyAppDesklet.class);
}Stopping your deskletIn your stop() method you should be sure to call getContext().notifyStopped() after you have killed any threads or other resources you have created. If you don't call notifyStopped() it will take your widget 20 seconds (the default timeout) to actually quit. Starting your deskletThis main method will run your desklet in a test environment. This lets you test your desklet without running it in the full AB5k container In your MyAppDesklet class go to the init() method and type something like this: getContext().getContainer().setContent(new JButton("Greetings earthling!");
getContext().getContainer().setVisible(true);Compile your code and run the main method in MyAppDesklet. The DeskletTester will start your desklet in a test environment and you should see a window appear with your desklet in it. Packaging your deskletCreate a META-INF directory in your src directory. This directory must end up in your finished jar, so if you are not using NetBeans then you may need to modify your build environment to ensure that the META-INF directory and it's contents are copied to the compiled jar. Create a desklet.xml file in the META-INF directory. The contents of the desklets should be something like this: <?xml version="1.0" encoding="UTF-8"?>
<desklet version="0.1">
<name>My App</name>
<author>Meee</author>
<homepage>http://mydomain.com/ab5k/</homepage>
<description>My Cool App</description>
<class>myapp.MyAppDesklet</class>
</desklet>Build a jar of your class files, including the META-INF directory and the desklet.xml. Rename your .jar file as a .desklet file. Now you are done! You can run AB5k and add your desklet using the 'add' button in the manage dialog. we might also want to mention that there is a quick change in the project properties you can do so that the built jar has the .desklet extension instead of .jar. Maybe we just need a NB / Eclipse specific wiki page TestingTo aid in testing you can use these system properties.
|
Sign in to add a comment