Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

StatusbarTogglePanel.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.addons.ui_swing.components.statusbar;
  18. import java.awt.event.HierarchyBoundsListener;
  19. import java.awt.event.HierarchyEvent;
  20. import java.awt.event.MouseEvent;
  21. import javax.swing.JComponent;
  22. import javax.swing.border.Border;
  23. /**
  24. * A panel shown in the status bar which displays a {@link StatusbarPopupWindow} when the clicks it.
  25. *
  26. * @since 0.6.6
  27. */
  28. public abstract class StatusbarTogglePanel<T extends JComponent> extends StatusbarPanel<T>
  29. implements HierarchyBoundsListener {
  30. /** A version number for this class. */
  31. private static final long serialVersionUID = 2;
  32. /**
  33. * Creates a new {@link StatusbarTogglePanel}, using the specified label.
  34. *
  35. * @param label The component to be displayed in the status bar
  36. */
  37. public StatusbarTogglePanel(final T label) {
  38. super(label);
  39. addHierarchyBoundsListener(this);
  40. }
  41. /**
  42. * Creates a new {@link StatusbarPanel}.
  43. *
  44. * @param label The component to be displayed in the status bar
  45. * @param nonSelectedBorder The border for when the panel is unselected
  46. * @param selectedBorder The border for when for the panel is selected
  47. */
  48. public StatusbarTogglePanel(final T label, final Border nonSelectedBorder,
  49. final Border selectedBorder) {
  50. super(label, nonSelectedBorder, selectedBorder);
  51. addHierarchyBoundsListener(this);
  52. }
  53. @Override
  54. public void mouseClicked(final MouseEvent e) {
  55. if (isDialogOpen()) {
  56. closeDialog();
  57. } else {
  58. openDialog();
  59. }
  60. }
  61. @Override
  62. public void mousePressed(final MouseEvent e) {
  63. // Don't care
  64. }
  65. @Override
  66. public void mouseReleased(final MouseEvent e) {
  67. // Don't care
  68. }
  69. @Override
  70. public void mouseEntered(final MouseEvent e) {
  71. // Don't care
  72. }
  73. @Override
  74. public void mouseExited(final MouseEvent e) {
  75. // Don't care
  76. }
  77. @Override
  78. public void ancestorMoved(final HierarchyEvent e) {
  79. refreshDialog();
  80. }
  81. @Override
  82. public void ancestorResized(final HierarchyEvent e) {
  83. refreshDialog();
  84. }
  85. }