/** * Resets the rollover state of all rollover components in the current cell except the component * given as a parameter. * * @param excludeComponent the component to exclude from the reset */ public void resetRolloverState(Component excludeComponent) { if (!chatButton.equals(excludeComponent)) chatButton.getModel().setRollover(false); if (!callButton.equals(excludeComponent)) callButton.getModel().setRollover(false); if (!callVideoButton.equals(excludeComponent)) callVideoButton.getModel().setRollover(false); if (!desktopSharingButton.equals(excludeComponent)) desktopSharingButton.getModel().setRollover(false); if (!addContactButton.equals(excludeComponent)) addContactButton.getModel().setRollover(false); if (customActionButtons != null) { Iterator<JButton> buttonsIter = customActionButtons.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); if (!button.equals(excludeComponent)) button.getModel().setRollover(false); } } if (customActionButtonsUIGroup != null) { Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); if (!button.equals(excludeComponent)) button.getModel().setRollover(false); } } }
@Override public Component getListCellRendererComponent( JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) { label.setText(Objects.toString(value, "")); this.list = list; this.index = index; if (isSelected) { setBackground(list.getSelectionBackground()); label.setForeground(list.getSelectionForeground()); } else { setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground()); label.setForeground(list.getForeground()); } MutableComboBoxModel m = (MutableComboBoxModel) list.getModel(); if (index < 0 || m.getSize() - 1 <= 0) { setOpaque(false); deleteButton.setVisible(false); label.setForeground(list.getForeground()); } else { boolean f = index == rolloverIndex; setOpaque(true); deleteButton.setVisible(true); deleteButton.getModel().setRollover(f); deleteButton.setForeground(f ? Color.WHITE : list.getForeground()); } return this; }
private void resetButtonStatus() { for (JButton b : Arrays.asList(deleteButton, copyButton)) { ButtonModel m = b.getModel(); m.setRollover(false); m.setArmed(false); m.setPressed(false); m.setSelected(false); } }
/** Resets the rollover state of all rollover components in the current cell. */ public void resetRolloverState() { chatButton.getModel().setRollover(false); callButton.getModel().setRollover(false); callVideoButton.getModel().setRollover(false); desktopSharingButton.getModel().setRollover(false); addContactButton.getModel().setRollover(false); if (customActionButtons != null) { Iterator<JButton> buttonsIter = customActionButtons.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); button.getModel().setRollover(false); } } if (customActionButtonsUIGroup != null) { Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); button.getModel().setRollover(false); } } }
@Override public Component getListCellRendererComponent( JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) { label.setText(Objects.toString(value, "")); this.index = index; if (isSelected) { setBackground(list.getSelectionBackground()); label.setForeground(list.getSelectionForeground()); } else { setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground()); label.setForeground(list.getForeground()); } resetButtonStatus(); if (Objects.nonNull(button)) { if (index == pressedIndex) { button.getModel().setSelected(true); button.getModel().setArmed(true); button.getModel().setPressed(true); } else if (index == rolloverIndex) { button.getModel().setRollover(true); } } return this; }
@Override public void mouseMoved(MouseEvent e) { // JList list = (JList) e.getComponent(); Point pt = e.getPoint(); int index = list.locationToIndex(pt); if (!list.getCellBounds(index, index).contains(pt)) { if (prevIndex >= 0) { listRepaint(list, list.getCellBounds(prevIndex, prevIndex)); } index = -1; prevButton = null; return; } if (index >= 0) { JButton button = getButton(list, pt, index); ButtonsRenderer renderer = (ButtonsRenderer) list.getCellRenderer(); renderer.button = button; if (Objects.isNull(button)) { renderer.rolloverIndex = -1; Rectangle r = null; if (prevIndex == index) { if (prevIndex >= 0 && Objects.nonNull(prevButton)) { r = list.getCellBounds(prevIndex, prevIndex); } } else { r = list.getCellBounds(index, index); } listRepaint(list, r); prevIndex = -1; } else { button.getModel().setRollover(true); renderer.rolloverIndex = index; if (!button.equals(prevButton)) { listRepaint(list, list.getCellBounds(prevIndex, index)); } } prevButton = button; } prevIndex = index; }