File: DSourceListClickListener.java

package info (click to toggle)
mac-widgets 0.10.0%2Bsvn416-dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,968 kB
  • sloc: java: 9,909; makefile: 13; sh: 12
file content (88 lines) | stat: -rw-r--r-- 3,378 bytes parent folder | download | duplicates (5)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.explodingpixels.macwidgets;

import com.explodingpixels.widgets.WindowUtils;

import javax.swing.*;
import java.awt.*;

public class DSourceListClickListener {

    private static String getPluralModifer(int clickCount) {
        return clickCount == 1 ? "" : "s";
    }

    public static void main(String[] args) {

        final SourceListClickListener clickListener = new SourceListClickListener() {
            public void sourceListItemClicked(SourceListItem item, Button button,
                                              int clickCount) {
                System.out.println(item.getText() + " clicked " + clickCount
                        + " time" + getPluralModifer(clickCount) + ".");
            }

            public void sourceListCategoryClicked(SourceListCategory category,
                                                  Button button, int clickCount) {
                System.out.println(category.getText() + " clicked " + clickCount
                        + " time" + getPluralModifer(clickCount) + ".");
            }
        };

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {

                SourceList sourceList = DSourceListMail.createSourceList();
                sourceList.addSourceListClickListener(clickListener);

//                JTree sourceList = new JTree(new String[]{
//                        "Node One", "Node Two", "Node Three", "Node Four",
//                        "Node Five"});
//                sourceList.setUI(new BasicTreeUI() {
//                    protected MouseListener createMouseListener() {
//                        return new MouseListener() {
//
//                            public void mouseClicked(MouseEvent e) {
//                                System.out.println("Node clicked.");
//                            }
//
//                            public void mousePressed(MouseEvent e) {
//                                System.out.println("Node pressed.");
//                            }
//
//                            public void mouseReleased(MouseEvent e) {
//                            }
//
//                            public void mouseEntered(MouseEvent e) {
//                            }
//
//                            public void mouseExited(MouseEvent e) {
//                            }
//                        };
//                    }
//                });
//
//                sourceList.addMouseListener(new MouseAdapter() {
//                    public void mouseClicked(MouseEvent e) {
//                        System.out.println("Node clicked.");
//                    }
//
//                    public void mousePressed(MouseEvent e) {
//                        System.out.println("Node pressed.");
//                    }
//                });

//                JScrollPane scrollPane = new JScrollPane(sourceList);

                JFrame frame = new JFrame();
                WindowUtils.createAndInstallRepaintWindowFocusListener(frame);
                frame.add(sourceList.getComponent(), BorderLayout.CENTER);
//                frame.add(scrollPane, BorderLayout.CENTER);
                frame.setSize(225, 250);
                frame.setLocationRelativeTo(null);
                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                frame.setVisible(true);

            }
        });

    }
}