@Override protected void paintComponent(final Graphics g) { super.paintComponent(g); if (myToolbar != null && myToolbar.getParent() == this && myContent != null && myContent.getParent() == this) { g.setColor(UIUtil.getBorderSeparatorColor()); if (myVertical) { final int y = (int) myToolbar.getBounds().getMaxY(); g.drawLine(0, y, getWidth(), y); } else { int x = (int) myToolbar.getBounds().getMaxX(); g.drawLine(x, 0, x, getHeight()); } } }
// Event forwarding. We need it if user does press-and-drag gesture for opening popup and // choosing item there. // It works in JComboBox, here we provide the same behavior private void dispatchEventToPopup(MouseEvent e) { if (myPopup != null && myPopup.isVisible()) { JComponent content = myPopup.getContent(); Rectangle rectangle = content.getBounds(); Point location = rectangle.getLocation(); SwingUtilities.convertPointToScreen(location, content); Point eventPoint = e.getLocationOnScreen(); rectangle.setLocation(location); if (rectangle.contains(eventPoint)) { MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, myPopup.getContent()); Component component = SwingUtilities.getDeepestComponentAt(content, event.getX(), event.getY()); if (component != null) component.dispatchEvent(event); } } }