1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
package com.explodingpixels.macwidgets;
import com.explodingpixels.widgets.WindowUtils;
import javax.swing.*;
import java.awt.*;
public class DSourceListMail {
public static SourceList createSourceList() {
Icon mailboxIcon =
new ImageIcon(DSourceListITunes.class.getResource("/com/explodingpixels/macwidgets/icons/mailbox.png"));
Icon sentIcon =
new ImageIcon(DSourceListITunes.class.getResource("/com/explodingpixels/macwidgets/icons/sent.png"));
Icon trashCanIcon =
new ImageIcon(DSourceListITunes.class.getResource("/com/explodingpixels/macwidgets/icons/trashcan.png"));
Icon rss =
new ImageIcon(DSourceListITunes.class.getResource("/com/explodingpixels/macwidgets/icons/rss.png"));
final SourceListModel model = new SourceListModel();
SourceListCategory mailboxesCategory = new SourceListCategory("Mailboxes");
SourceListCategory rssCategory = new SourceListCategory("RSS");
model.addCategory(mailboxesCategory);
model.addCategory(rssCategory);
SourceListItem inboxItem = new SourceListItem("Inbox", mailboxIcon);
SourceListItem trashCanItem = new SourceListItem("Trash", trashCanIcon);
model.addItemToCategory(inboxItem, mailboxesCategory);
model.addItemToCategory(trashCanItem, mailboxesCategory);
SourceListItem macInbox = new SourceListItem("john.doe@mac.com", mailboxIcon);
macInbox.setCounterValue(3);
SourceListItem gmailInbox = new SourceListItem("john.doe@gmail.com", mailboxIcon);
gmailInbox.setCounterValue(15);
model.addItemToItem(macInbox, inboxItem);
model.addItemToItem(gmailInbox, inboxItem);
model.addItemToItem(new SourceListItem("Sent", sentIcon), inboxItem);
model.addItemToItem(new SourceListItem("john.doe@mac.com", trashCanIcon), trashCanItem);
model.addItemToItem(new SourceListItem("john.doe@gmail.com", trashCanIcon), trashCanItem);
model.addItemToCategory(new SourceListItem("Apple Hot News", rss), rssCategory);
model.addItemToCategory(new SourceListItem("Exploding Pixels", rss), rssCategory);
SourceList sourceList = new SourceList(model);
sourceList.setFocusable(false);
return sourceList;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
WindowUtils.createAndInstallRepaintWindowFocusListener(frame);
frame.add(createSourceList().getComponent(), BorderLayout.CENTER);
frame.setSize(225, 250);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
});
}
}
|