public void paintChildren(ParentPanelBase panel, Graphics2D graphics) { if (panel.hasChildren()) { Box innards = panel instanceof PropPanel ? ((PropPanel) panel).getPaddedBounds() : panel.getChildConsumableBounds(); graphics.clipRect(innards.x, innards.y, innards.width, innards.height); for (Panel child : panel.getChildren()) if (!child.isFloater()) paintChild(graphics, child); for (Panel child : panel.getChildren()) if (child.isFloater()) paintChild(graphics, child); } }
@Before public void setUp() throws Exception { action = new MockEventAction(); parent = new TestableParentPanel(); panel = new TestablePanelBase(); parent.add(panel); }
@Test public void unhandledInheritableEventsArePassedToParent() throws Exception { parent.getEventHandler().add(MousePressedEvent.class, action); panel.getEventHandler().dispatch(new MousePressedEvent(panel, 0, new Point(0, 0), 0)); assertEquals(true, action.invoked); assertEquals(parent, action.recipient); }
@Test public void unhandledNoninheritableEventsAreNotPassedToParent() throws Exception { parent.getEventHandler().add(KeyPressedEvent.class, action); panel .getEventHandler() .dispatch(new KeyPressedEvent(panel, 0, KeyEvent.KEY_ENTER, KeyEvent.LOCATION_LEFT)); assertEquals(false, action.invoked); }