ProfilerLayeredPane extends JLayeredPane { @Nullable public static Container setCursorOnProfilerLayeredPane(Container container, Cursor cursor) { for (Container p = container; p != null; p = p.getParent()) { if (p instanceof ProfilerLayeredPane) { p.setCursor(cursor); return p; } } return null; } ProfilerLayeredPane(@NotNull JComponent content); @Nullable static Container setCursorOnProfilerLayeredPane(Container container, Cursor cursor); @Override void setBounds(int x, int y, int width, int height);  }
@Test public void setCursorOnProfilerLayeredPane() { JButton button = new JButton(); JPanel panel = new JPanel(); panel.add(button); ProfilerLayeredPane layeredPane = new ProfilerLayeredPane(panel); Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); Container cursorSettingContainer = ProfilerLayeredPane.setCursorOnProfilerLayeredPane( button, cursor); assertThat(layeredPane).isSameAs(cursorSettingContainer); assertThat(cursor).isEqualTo(layeredPane.getCursor()); }
@Test public void setCursorOnProfilerLayeredPaneNotFound() { JButton button = new JButton(); JPanel panel = new JPanel(); panel.add(button); Cursor cursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR); assertThat(ProfilerLayeredPane.setCursorOnProfilerLayeredPane(button, cursor)).isNull(); }