JDIC - Java Desktop Componets
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.



Articles




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) {...}
});

webBrowser.setURL(curUrl);
webBrowser.back();
webBrowser.forward();
webBrowser.refresh();
webBrowser.stop();
Desktop
File file = ...;
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);
Tray
// 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) {...}
});
Wallpaper
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