|
by Jean-Marc Autexier |
Purpose
This page gives an overview about the JDesktop Integration Components (JDIC) project.
Update (10.08.2005): IBM developer works has published a good overview article about JDIC.
Feature list
The best and complete way to know what JDIC can is to browse the API documentation. This is more or less the javadoc extract, but easier to read if you just want an overview.
- Browser (sample
code)
- Launch system default browser
- navigate: back, forward,
stop, setURL
- get content of page (HTML), get URL
- File (sample code)
- isEditable(File)
- edit(): Launch associated editor to edit the given file
- open(): Launch the
associated application to open the given file
- Icons1: get icon associated to a file on this system
- Printing
- isPrintable(File)
- Prints the given file
- Launches the message compose window of the default mailer
- SystemTray (sample code)
- add/remove TrayIcon
- Ballon messages
- getDefaultSystemTray
- Tray icons: icon + caption
+ popup menu + tooltip
- display message
- Incubator projects API's: not supported everywhere, not official
- Floating Dock Toplevel Window (sample code)
- Alert API: indicate that a certain program (usually not the program currently focused) needs the user's attention. (Mac OSX supported)
- Volume API (sample code): get, set, and monitor the system volume. (Mac OSX supported)
- DockMenu API: set a right click menu on the Dock icon (Mac OSX supported)
- Desktop background wallpaper API (sample code): set the background of the desktop.
- Saverbeans Screensaver SDK: cross platform screensaver, includes 34 screensaver (0.2), OpenGL, fullscreen, multi-monitor, API,
- FileUtil: send file to trash bin, get free disk space, access file attributes,
Articles
- General
- Articles
- 01.06.2004: Introducing JDIC: Desktop Integration for Java Applications
- 14.10.2004: Joshua Marinacci: Introducing JDesktop Integration Components, Part 1
- 01.11.2004: Joshua Marinacci: Introducing JDesktop Integration Components, Part 2
- 06.12.2004: R.J. Lorimer: Swing: System Tray Icons
- Deploying a JDIC Application Using Java Web Start
- Blog entries
- 14.06.2004: tadelstein: Desktop Integration for Java Applications
- 17.07.2004: AlArenal: Suns JDNC and JDIC
- 10.11.2004: Colm Smyth: Java and Desktop
Code samples
Browser
import org.jdesktop.jdic.browser.*;
...
WebBrowser webBrowser;
webBrowser = new WebBrowser(new URL("http://java.net"));
webBrowser.addWebBrowserListener(new WebBrowserListener()
{
public void downloadStarted(WebBrowserEvent event) {...}
public void downloadCompleted(WebBrowserEvent event) {...}
public void documentCompleted(WebBrowserEvent event) {...}
public void downloadProgress(WebBrowserEvent event) {...}
public void downloadError(WebBrowserEvent event) {...}
public void documentCompleted(WebBrowserEvent event) {...}
public void titleChange(WebBrowserEvent event) {...}
public void statusTextChange(WebBrowserEvent event) {...}
});
Desktop
webBrowser.setURL(curUrl);
webBrowser.back();
webBrowser.forward();
webBrowser.refresh();
webBrowser.stop();
File file = ...;Tray
Desktop.open(file); // open file in default viewer
Desktop.edit(file); // open file in default editor
Desktop.print(file); // print file
Desktop.browse(new URL(inputUrl)); // open URL in default browser
// build message from file (attachment) and send as mail
Message msg = new Message();
List attachList = new ArrayList();
attachList.add(selectedFile.toString());
msg.setAttachments(attachList);
Desktop.mail(msg);
// build a popup menu
JPopupMenu menu = new JPopupMenu("A Menu");
....
// get an ImageIcon
ImageIcon i = new ImageIcon(Tray.class.getResource("images/duke.gif"));
// build TrayIcon
TrayIcon ti = new TrayIcon(i, "JDIC Tray Icon API Demo - TrayIcon", menu);
ti.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {...} });
SystemTray tray = SystemTray.getDefaultSystemTray();
tray.addTrayIcon(ti);
Floating Dock Toplevel Window
JButton button1, button2, button3;
FloatingDock fd;
GridLayout gl = new GridLayout(3, 1);
fd = new FloatingDock();
fd.setLocation (FloatingDock.LEFT);
fd.setLayout(gl);
button1 = new JButton("Button 1");
button1.setVisible(true);
button2 = new JButton("Button 2");
button2.setVisible(true);
button3 = new JButton("Button 3");
button3.setVisible(true);
fd.add(button1);
fd.add(button2);
fd.add(button3);
fd.setSize(new Dimension(100, 300));
fd.setVisible(true);
Volume
from http://weblogs.java.net/blog/joshy/archive/2005/04/sometimes_you_o.html
final Volume vol = Volume.newInstance();
// get the volume
float current_volume = vol.getVolume();
vol.setVolume(current_volume + 0.1);
vol.addPropertyChangedListener(mew PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {...}
});
int [] modes = Wallpaper.MODES;
String [] modeNames = Wallpaper.MODE_NAMES;
int mode = Wallpaper.STRETCH;
// int mode = Wallpaper.CENTER;
//int mode = Wallpaper.TILE;
p.setBackground(new File(".."), mode);
1 not yet in standard JDIC (V0.9)
(c) Jean-Marc Autexier, April 2005