Przeglądaj źródła

Move menu scroller to library

Depends-On: I7769f923a838d4812d23b6e24e1bd3571e3c5784
Change-Id: Idfe4ea8493e5aec37e05a485f67beb9ecaa42657
Reviewed-on: http://gerrit.dmdirc.com/1751
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.6.5
Greg Holmes 13 lat temu
rodzic
commit
d48d1f7853

BIN
lib/menuscroller.jar Wyświetl plik


+ 0
- 649
src/com/dmdirc/addons/ui_swing/components/MenuScroller.java Wyświetl plik

@@ -1,649 +0,0 @@
1
-/**
2
- * @(#)MenuScroller.java 1.3.0 05/04/09
3
- */
4
-package com.dmdirc.addons.ui_swing.components;
5
-
6
-import java.awt.Color;
7
-import java.awt.Component;
8
-import java.awt.Dimension;
9
-import java.awt.Graphics;
10
-import java.awt.event.ActionEvent;
11
-import java.awt.event.ActionListener;
12
-import java.awt.event.MouseEvent;
13
-import java.awt.event.MouseListener;
14
-import javax.swing.Icon;
15
-import javax.swing.JComponent;
16
-import javax.swing.JMenu;
17
-import javax.swing.JMenuItem;
18
-import javax.swing.JPopupMenu;
19
-import javax.swing.JSeparator;
20
-import javax.swing.MenuSelectionManager;
21
-import javax.swing.Timer;
22
-import javax.swing.event.ChangeEvent;
23
-import javax.swing.event.ChangeListener;
24
-import javax.swing.event.MenuEvent;
25
-import javax.swing.event.MenuListener;
26
-import javax.swing.event.PopupMenuEvent;
27
-import javax.swing.event.PopupMenuListener;
28
-
29
-/**
30
- * A class that provides scrolling capabilities to a long menu dropdown or
31
- * popup menu.  A number of items can optionally be frozen at the top and/or
32
- * bottom of the menu.
33
- * <P>
34
- * <B>Implementation note:</B>  The default number of items to display
35
- * at a time is 15, and the default scrolling interval is 125 milliseconds.
36
- * <P>
37
- * @author Darryl
38
- */
39
-public class MenuScroller {
40
-
41
-    private JMenu menu;
42
-    private JPopupMenu popupMenu;
43
-    private Component[] menuItems;
44
-    private MenuScrollItem upItem;
45
-    private MenuScrollItem downItem;
46
-    private final MenuScrollListener menuListener = new MenuScrollListener();
47
-    private int scrollCount;
48
-    private int interval;
49
-    private int topFixedCount;
50
-    private int bottomFixedCount;
51
-    private int firstIndex = 0;
52
-    private boolean showSeperators = true;
53
-
54
-    /**
55
-     * Registers a menu to be scrolled with the default number of items to
56
-     * display at a time and the default scrolling interval.
57
-     * <P>
58
-     * @param menu the menu
59
-     * @return the MenuScroller
60
-     */
61
-    public static MenuScroller setScrollerFor(JMenu menu) {
62
-        return new MenuScroller(menu);
63
-    }
64
-
65
-    /**
66
-     * Registers a popup menu to be scrolled with the default number of items to
67
-     * display at a time and the default scrolling interval.
68
-     * <P>
69
-     * @param menu the popup menu
70
-     * @return the MenuScroller
71
-     */
72
-    public static MenuScroller setScrollerFor(JPopupMenu menu) {
73
-        return new MenuScroller(menu);
74
-    }
75
-
76
-    /**
77
-     * Registers a menu to be scrolled with the default number of items to
78
-     * display at a time and the specified scrolling interval.
79
-     * <P>
80
-     * @param menu the menu
81
-     * @param scrollCount the number of items to display at a time
82
-     * @return the MenuScroller
83
-     * @throws IllegalArgumentException if scrollCount is 0 or negative
84
-     */
85
-    public static MenuScroller setScrollerFor(JMenu menu, int scrollCount) {
86
-        return new MenuScroller(menu, scrollCount);
87
-    }
88
-
89
-    /**
90
-     * Registers a popup menu to be scrolled with the default number of items to
91
-     * display at a time and the specified scrolling interval.
92
-     * <P>
93
-     * @param menu the popup menu
94
-     * @param scrollCount the number of items to display at a time
95
-     * @return the MenuScroller
96
-     * @throws IllegalArgumentException if scrollCount is 0 or negative
97
-     */
98
-    public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount) {
99
-        return new MenuScroller(menu, scrollCount);
100
-    }
101
-
102
-    /**
103
-     * Registers a menu to be scrolled, with the specified number of items to
104
-     * display at a time and the specified scrolling interval.
105
-     * <P>
106
-     * @param menu the menu
107
-     * @param scrollCount the number of items to be displayed at a time
108
-     * @param interval the scroll interval, in milliseconds
109
-     * @return the MenuScroller
110
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or negative
111
-     */
112
-    public static MenuScroller setScrollerFor(JMenu menu, int scrollCount,
113
-            int interval) {
114
-        return new MenuScroller(menu, scrollCount, interval);
115
-    }
116
-
117
-    /**
118
-     * Registers a popup menu to be scrolled, with the specified number of items to
119
-     * display at a time and the specified scrolling interval.
120
-     * <P>
121
-     * @param menu the popup menu
122
-     * @param scrollCount the number of items to be displayed at a time
123
-     * @param interval the scroll interval, in milliseconds
124
-     * @return the MenuScroller
125
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or negative
126
-     */
127
-    public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount,
128
-            int interval) {
129
-        return new MenuScroller(menu, scrollCount, interval);
130
-    }
131
-
132
-    /**
133
-     * Registers a menu to be scrolled, with the specified number of items
134
-     * to display in the scrolling region, the specified scrolling interval,
135
-     * and the specified numbers of items fixed at the top and bottom of the
136
-     * menu.
137
-     * <P>
138
-     * @param menu the menu
139
-     * @param scrollCount the number of items to display in the scrolling portion
140
-     * @param interval the scroll interval, in milliseconds
141
-     * @param topFixedCount the number of items to fix at the top.  May be 0.
142
-     * @param bottomFixedCount the number of items to fix at the bottom. May be 0
143
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or
144
-     * negative or if topFixedCount or bottomFixedCount is negative
145
-     * @return the MenuScroller
146
-     */
147
-    public static MenuScroller setScrollerFor(JMenu menu, int scrollCount,
148
-            int interval, int topFixedCount, int bottomFixedCount) {
149
-        return new MenuScroller(menu, scrollCount, interval,
150
-                topFixedCount, bottomFixedCount);
151
-    }
152
-
153
-    /**
154
-     * Registers a popup menu to be scrolled, with the specified number of items
155
-     * to display in the scrolling region, the specified scrolling interval,
156
-     * and the specified numbers of items fixed at the top and bottom of the
157
-     * popup menu.
158
-     * <P>
159
-     * @param menu the popup menu
160
-     * @param scrollCount the number of items to display in the scrolling portion
161
-     * @param interval the scroll interval, in milliseconds
162
-     * @param topFixedCount the number of items to fix at the top.  May be 0
163
-     * @param bottomFixedCount the number of items to fix at the bottom.  May be 0
164
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or
165
-     * negative or if topFixedCount or bottomFixedCount is negative
166
-     * @return the MenuScroller
167
-     */
168
-    public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount,
169
-            int interval, int topFixedCount, int bottomFixedCount) {
170
-        return new MenuScroller(menu, scrollCount, interval,
171
-                topFixedCount, bottomFixedCount);
172
-    }
173
-
174
-    /**
175
-     * Constructs a <code>MenuScroller</code> that scrolls a menu with the
176
-     * default number of items to display at a time, and default scrolling
177
-     * interval.
178
-     * <P>
179
-     * @param menu the menu
180
-     */
181
-    public MenuScroller(JMenu menu) {
182
-        this(menu, 15);
183
-    }
184
-
185
-    /**
186
-     * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the
187
-     * default number of items to display at a time, and default scrolling
188
-     * interval.
189
-     * <P>
190
-     * @param menu the popup menu
191
-     */
192
-    public MenuScroller(JPopupMenu menu) {
193
-        this(menu, 15);
194
-    }
195
-
196
-    /**
197
-     * Constructs a <code>MenuScroller</code> that scrolls a menu with the
198
-     * specified number of items to display at a time, and default scrolling
199
-     * interval.
200
-     * <P>
201
-     * @param menu the menu
202
-     * @param scrollCount the number of items to display at a time
203
-     * @throws IllegalArgumentException if scrollCount is 0 or negative
204
-     */
205
-    public MenuScroller(JMenu menu, int scrollCount) {
206
-        this(menu, scrollCount, 125);
207
-    }
208
-
209
-    /**
210
-     * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the
211
-     * specified number of items to display at a time, and default scrolling
212
-     * interval.
213
-     * <P>
214
-     * @param menu the popup menu
215
-     * @param scrollCount the number of items to display at a time
216
-     * @throws IllegalArgumentException if scrollCount is 0 or negative
217
-     */
218
-    public MenuScroller(JPopupMenu menu, int scrollCount) {
219
-        this(menu, scrollCount, 125);
220
-    }
221
-
222
-    /**
223
-     * Constructs a <code>MenuScroller</code> that scrolls a menu with the
224
-     * specified number of items to display at a time, and specified scrolling
225
-     * interval.
226
-     * <P>
227
-     * @param menu the menu
228
-     * @param scrollCount the number of items to display at a time
229
-     * @param interval the scroll interval, in milliseconds
230
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or negative
231
-     */
232
-    public MenuScroller(JMenu menu, int scrollCount, int interval) {
233
-        this(menu, scrollCount, interval, 0, 0);
234
-    }
235
-
236
-    /**
237
-     * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the
238
-     * specified number of items to display at a time, and specified scrolling
239
-     * interval.
240
-     * <P>
241
-     * @param menu the popup menu
242
-     * @param scrollCount the number of items to display at a time
243
-     * @param interval the scroll interval, in milliseconds
244
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or negative
245
-     */
246
-    public MenuScroller(JPopupMenu menu, int scrollCount, int interval) {
247
-        this(menu, scrollCount, interval, 0, 0);
248
-    }
249
-
250
-    /**
251
-     * Constructs a <code>MenuScroller</code> that scrolls a menu with the
252
-     * specified number of items to display in the scrolling region, the
253
-     * specified scrolling interval, and the specified numbers of items fixed at
254
-     * the top and bottom of the menu.
255
-     * <P>
256
-     * @param menu the menu
257
-     * @param scrollCount the number of items to display in the scrolling portion
258
-     * @param interval the scroll interval, in milliseconds
259
-     * @param topFixedCount the number of items to fix at the top.  May be 0
260
-     * @param bottomFixedCount the number of items to fix at the bottom.  May be 0
261
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or
262
-     * negative or if topFixedCount or bottomFixedCount is negative
263
-     */
264
-    public MenuScroller(JMenu menu, int scrollCount, int interval,
265
-            int topFixedCount, int bottomFixedCount) {
266
-        setValues(scrollCount, interval, topFixedCount, bottomFixedCount);
267
-
268
-        this.menu = menu;
269
-        menu.addMenuListener(menuListener);
270
-    }
271
-
272
-    /**
273
-     * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the
274
-     * specified number of items to display in the scrolling region, the
275
-     * specified scrolling interval, and the specified numbers of items fixed at
276
-     * the top and bottom of the popup menu.
277
-     * <P>
278
-     * @param menu the popup menu
279
-     * @param scrollCount the number of items to display in the scrolling portion
280
-     * @param interval the scroll interval, in milliseconds
281
-     * @param topFixedCount the number of items to fix at the top.  May be 0
282
-     * @param bottomFixedCount the number of items to fix at the bottom.  May be 0
283
-     * @throws IllegalArgumentException if scrollCount or interval is 0 or
284
-     * negative or if topFixedCount or bottomFixedCount is negative
285
-     */
286
-    public MenuScroller(JPopupMenu menu, int scrollCount, int interval,
287
-            int topFixedCount, int bottomFixedCount) {
288
-        setValues(scrollCount, interval, topFixedCount, bottomFixedCount);
289
-        this.popupMenu = menu;
290
-        menu.addPopupMenuListener(menuListener);
291
-    }
292
-
293
-    private void setValues(int scrollCount, int interval,
294
-            int topFixedCount, int bottomFixedCount) {
295
-        if (scrollCount <= 0 || interval <= 0) {
296
-            throw new IllegalArgumentException(
297
-                    "scrollCount and interval must be greater than 0");
298
-        }
299
-
300
-        if (topFixedCount < 0 || bottomFixedCount < 0) {
301
-            throw new IllegalArgumentException(
302
-                    "topFixedCount and bottomFixedCount cannot be negative");
303
-        }
304
-        upItem = new MenuScrollItem(MenuIcon.UP, -1);
305
-        downItem = new MenuScrollItem(MenuIcon.DOWN, +1);
306
-        setScrollCount(scrollCount);
307
-        setInterval(interval);
308
-        setTopFixedCount(topFixedCount);
309
-        setBottomFixedCount(bottomFixedCount);
310
-    }
311
-
312
-    /**
313
-     * Returns the scroll interval in milliseconds
314
-     * <P>
315
-     * @return the scroll interval in milliseconds
316
-     */
317
-    public int getInterval() {
318
-        return interval;
319
-    }
320
-
321
-    /**
322
-     * Sets the scroll interval in milliseconds
323
-     * <P>
324
-     * @param interval the scroll interval in milliseconds
325
-     * @throws IllegalArgumentException if interval is 0 or negative
326
-     */
327
-    public void setInterval(int interval) {
328
-        if (interval <= 0) {
329
-            throw new IllegalArgumentException(
330
-                    "interval must be greater than 0");
331
-        }
332
-        upItem.setInterval(interval);
333
-        downItem.setInterval(interval);
334
-        this.interval = interval;
335
-    }
336
-
337
-    /**
338
-     * Returns the number of items in the scrolling portion of the menu.
339
-     * <P>
340
-     * @return the number of items to display at a time
341
-     */
342
-    public int getscrollCount() {
343
-        return scrollCount;
344
-    }
345
-
346
-    /**
347
-     * Sets the number of items in the scrolling portion of the menu.
348
-     * <P>
349
-     * @param scrollCount the number of items to display at a time
350
-     * @throws IllegalArgumentException if scrollCount is 0 or negative
351
-     */
352
-    public void setScrollCount(int scrollCount) {
353
-        if (scrollCount <= 0) {
354
-            throw new IllegalArgumentException(
355
-                    "scrollCount must be greater than 0");
356
-        }
357
-        this.scrollCount = scrollCount;
358
-        if (menu != null) {
359
-            menu.doClick();
360
-        }
361
-        MenuSelectionManager.defaultManager().clearSelectedPath();
362
-    }
363
-
364
-    /**
365
-     * Returns the number of items fixed at the top of the menu or popup menu.
366
-     * <P>
367
-     * @return the number of items
368
-     */
369
-    public int getTopFixedCount() {
370
-        return topFixedCount;
371
-    }
372
-
373
-    /**
374
-     * Sets the number of items to fix at the top of the menu or popup menu.
375
-     * <P>
376
-     * @param topFixedCount the number of items
377
-     */
378
-    public void setTopFixedCount(int topFixedCount) {
379
-        firstIndex = Math.max(firstIndex, topFixedCount);
380
-        this.topFixedCount = topFixedCount;
381
-    }
382
-
383
-    /**
384
-     * Returns the number of items fixed at the bottom of the menu or popup menu.
385
-     * <P>
386
-     * @return the number of items
387
-     */
388
-    public int getBottomFixedCount() {
389
-        return bottomFixedCount;
390
-    }
391
-
392
-    /**
393
-     * Sets the number of items to fix at the bottom of the menu or popup menu.
394
-     * <P>
395
-     * @param bottomFixedCount the number of items
396
-     */
397
-    public void setBottomFixedCount(int bottomFixedCount) {
398
-        this.bottomFixedCount = bottomFixedCount;
399
-    }
400
-
401
-    /**
402
-     * Returns whether to show seperators when scrolling is required.
403
-     *
404
-     * @return Whether to show seperators when scrolling is required
405
-     */
406
-    public boolean getShowSeperators() {
407
-        return showSeperators;
408
-    }
409
-
410
-    /**
411
-     * Sets whether we show seperators when a menu requires scrolling.
412
-     *
413
-     * @param showSeperators true to add seperators
414
-     */
415
-    public void setShowSeperators(boolean showSeperators) {
416
-        this.showSeperators = showSeperators;
417
-    }
418
-
419
-    /**
420
-     * Removes this MenuScroller from the associated menu and restores the
421
-     * default behavior of the menu.
422
-     */
423
-    public void dispose() {
424
-        if (menu != null) {
425
-            menu.removeMenuListener(menuListener);
426
-            menu = null;
427
-        }
428
-
429
-        if (popupMenu != null) {
430
-            popupMenu.removePopupMenuListener(menuListener);
431
-            popupMenu = null;
432
-        }
433
-    }
434
-
435
-    /**
436
-     * Ensures that the <code>dispose</code> method of this MenuScroller is
437
-     * called when there are no more refrences to it.
438
-     * <P>
439
-     * @exception  Throwable if an error occurs.
440
-     * @see MenuScroller#dispose()
441
-     */
442
-    @Override
443
-    protected void finalize() throws Throwable {
444
-        dispose();
445
-        super.finalize();
446
-    }
447
-
448
-    private void setMenuItems() {
449
-        if (menu != null) {
450
-            menuItems = menu.getMenuComponents();
451
-        }
452
-        if (popupMenu != null) {
453
-            menuItems = popupMenu.getComponents();
454
-        }
455
-        if (menuItems.length > topFixedCount + scrollCount + bottomFixedCount) {
456
-            refreshMenu();
457
-        }
458
-    }
459
-
460
-    private void restoreMenuItems() {
461
-        JComponent container = menu == null ? popupMenu : menu;
462
-        container.removeAll();
463
-        for (Component component : menuItems) {
464
-            container.add(component);
465
-        }
466
-    }
467
-
468
-    private void refreshMenu() {
469
-        firstIndex = Math.max(topFixedCount, firstIndex);
470
-        firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount,
471
-                firstIndex);
472
-
473
-        upItem.setEnabled(firstIndex > topFixedCount);
474
-        downItem.setEnabled(
475
-                firstIndex + scrollCount < menuItems.length - bottomFixedCount);
476
-
477
-        JComponent container = menu == null ? popupMenu : menu;
478
-        container.removeAll();
479
-        for (int i = 0; i < topFixedCount; i++) {
480
-            container.add(menuItems[i]);
481
-        }
482
-        if (topFixedCount > 0 && showSeperators) {
483
-            container.add(new JSeparator());
484
-        }
485
-
486
-        container.add(upItem);
487
-        for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
488
-            container.add(menuItems[i]);
489
-        }
490
-        container.add(downItem);
491
-
492
-        if (bottomFixedCount > 0 && showSeperators) {
493
-            container.add(new JSeparator());
494
-        }
495
-        for (int i = menuItems.length - bottomFixedCount; i < menuItems.length;
496
-                i++) {
497
-            container.add(menuItems[i]);
498
-        }
499
-        upItem.getParent().validate();
500
-    }
501
-
502
-    private class MenuScrollItem extends JMenuItem
503
-            implements MouseListener, ChangeListener {
504
-
505
-        private static final long serialVersionUID = -9164893168723608060L;
506
-        private MenuScrollTimer timer;
507
-        private MouseListener[] mouseListeners;
508
-
509
-        public MenuScrollItem(MenuIcon icon, int increment) {
510
-            setIcon(icon);
511
-            setDisabledIcon(icon);
512
-            timer = new MenuScrollTimer(increment, interval);
513
-            mouseListeners = getMouseListeners();
514
-            addMouseListener(this);
515
-            addChangeListener(this);
516
-        }
517
-
518
-        public void setInterval(int interval) {
519
-            timer.setDelay(interval);
520
-        }
521
-
522
-        // MouseListener methods
523
-        @Override
524
-        public void mouseClicked(MouseEvent e) {
525
-        }
526
-
527
-        @Override
528
-        public void mousePressed(MouseEvent e) {
529
-        }
530
-
531
-        @Override
532
-        public void mouseReleased(MouseEvent e) {
533
-        }
534
-
535
-        @Override
536
-        public void mouseEntered(MouseEvent e) {
537
-            for (MouseListener mouseListener : mouseListeners) {
538
-                mouseListener.mouseEntered(e);
539
-            }
540
-        }
541
-
542
-        @Override
543
-        public void mouseExited(MouseEvent e) {
544
-            for (MouseListener mouseListener : mouseListeners) {
545
-                mouseListener.mouseExited(e);
546
-            }
547
-        }
548
-
549
-        // ChangeListener method
550
-        @Override
551
-        public void stateChanged(ChangeEvent e) {
552
-            if (isArmed() && !timer.isRunning()) {
553
-                timer.start();
554
-            }
555
-            if (!isArmed() && timer.isRunning()) {
556
-                timer.stop();
557
-            }
558
-        }
559
-    }
560
-
561
-    private class MenuScrollTimer extends Timer {
562
-
563
-        private static final long serialVersionUID = 1329095900644142841L;
564
-
565
-        public MenuScrollTimer(final int increment, int interval) {
566
-            super(interval, new ActionListener() {
567
-
568
-                @Override
569
-                public void actionPerformed(ActionEvent e) {
570
-                    firstIndex += increment;
571
-                    refreshMenu();
572
-                }
573
-            });
574
-        }
575
-    }
576
-
577
-    private class MenuScrollListener
578
-            implements MenuListener, PopupMenuListener {
579
-
580
-        // MenuListener methods
581
-        @Override
582
-        public void menuSelected(MenuEvent e) {
583
-            setMenuItems();
584
-        }
585
-
586
-        @Override
587
-        public void menuDeselected(MenuEvent e) {
588
-            restoreMenuItems();
589
-        }
590
-
591
-        @Override
592
-        public void menuCanceled(MenuEvent e) {
593
-            restoreMenuItems();
594
-        }
595
-
596
-        // PopupMenuListener methods
597
-        @Override
598
-        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
599
-            setMenuItems();
600
-        }
601
-
602
-        @Override
603
-        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
604
-            restoreMenuItems();
605
-        }
606
-
607
-        @Override
608
-        public void popupMenuCanceled(PopupMenuEvent e) {
609
-            restoreMenuItems();
610
-        }
611
-    }
612
-
613
-    private static enum MenuIcon implements Icon {
614
-
615
-        UP(9, 1, 9),
616
-        DOWN(1, 9, 1);
617
-        final int[] xPoints = {1, 5, 9};
618
-        final int[] yPoints;
619
-
620
-        MenuIcon(int... yPoints) {
621
-            this.yPoints = yPoints;
622
-        }
623
-
624
-        @Override
625
-        public void paintIcon(Component c, Graphics g, int x, int y) {
626
-            Dimension size = c.getSize();
627
-            Graphics g2 = g.create(size.width / 2 - 5, size.height / 2 - 5, 10,
628
-                    10);
629
-            g2.setColor(Color.GRAY);
630
-            g2.drawPolygon(xPoints, yPoints, 3);
631
-            if (c.isEnabled()) {
632
-                g2.setColor(Color.BLACK);
633
-                g2.fillPolygon(xPoints, yPoints, 3);
634
-            }
635
-            g2.dispose();
636
-        }
637
-
638
-        @Override
639
-        public int getIconWidth() {
640
-            return 0;
641
-        }
642
-
643
-        @Override
644
-        public int getIconHeight() {
645
-            return 10;
646
-        }
647
-    }
648
-
649
-}

+ 9
- 8
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuScroller.java Wyświetl plik

@@ -1,17 +1,17 @@
1 1
 /*
2
- * 
2
+ *
3 3
  * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
4
- * 
4
+ *
5 5
  * Permission is hereby granted, free of charge, to any person obtaining a copy
6 6
  * of this software and associated documentation files (the "Software"), to deal
7 7
  * in the Software without restriction, including without limitation the rights
8 8
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 9
  * copies of the Software, and to permit persons to whom the Software is
10 10
  * furnished to do so, subject to the following conditions:
11
- * 
11
+ *
12 12
  * The above copyright notice and this permission notice shall be included in
13 13
  * all copies or substantial portions of the Software.
14
- * 
14
+ *
15 15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 16
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 17
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,10 +24,11 @@
24 24
 package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
25 25
 
26 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
-import com.dmdirc.addons.ui_swing.components.MenuScroller;
28 27
 import com.dmdirc.config.IdentityManager;
29 28
 import com.dmdirc.interfaces.ConfigChangeListener;
30 29
 
30
+import darrylbu.util.MenuScroller;
31
+
31 32
 import javax.swing.JMenu;
32 33
 
33 34
 /**
@@ -38,11 +39,11 @@ public class WindowMenuScroller implements ConfigChangeListener {
38 39
     /** Menu scroller. */
39 40
     private MenuScroller scroller;
40 41
     /** Config domain. */
41
-    private String configDomain;
42
+    private final String configDomain;
42 43
     /** Menu to scroll. */
43
-    private JMenu menu;
44
+    private final JMenu menu;
44 45
     /** Fixed menu item count. */
45
-    private int fixedCount;
46
+    private final int fixedCount;
46 47
 
47 48
     /**
48 49
      * Creates a new menu scroller for the window menu.

Ładowanie…
Anuluj
Zapisz