Shadow
Shadow adds visual depth to text and interface containers. JDance can render shadows around characters or around the rectangular bounds of a layout.
For the complete API reference, visit https://doc.jdance.org.
Overview
A text shadow follows the shape of the letters, making it useful for subtle title emphasis. Offset and blur affect the perceived direction and softness.
CODE
BasicLayout layout = new BasicLayout(BasicLayout.Direction.VERTICAL);
layout.setRelativeWidth(100);
layout.setGap(12);
Text soft = new Text("Soft text");
soft.setFont(new Font().setSize(18).setBold(true));
soft.setShadow(new Shadow(1,2,3,new Color("#AAB7C4")));
layout.add(soft);
Text strong = new Text("Deep text");
strong.setFont(new Font().setSize(18).setBold(true));
strong.setShadow(new Shadow(2,3,4,new Color("#777777")));
layout.add(strong);The preview above uses a small amount of space so the behavior is visible even in a narrow documentation panel.
Layout shadows and inset effects
A layout shadow surrounds the component box. An inset shadow is drawn inside its bounds, creating a recessed appearance rather than a raised card.
CODE
BasicLayout layout = new BasicLayout(BasicLayout.Direction.VERTICAL);
layout.setRelativeWidth(100);
layout.setGap(14);
BasicLayout card = new BasicLayout(BasicLayout.Direction.VERTICAL);
card.setPadding(10);
card.setBackground(new Color("white"));
card.setShadow(new Shadow(2,2,6,new Color("#BBBBBB")));
card.add(new Text("Raised card"));
layout.add(card);
BasicLayout inset = new BasicLayout(BasicLayout.Direction.VERTICAL);
inset.setPadding(10);
inset.setBackground(new Color("#F1F3F5"));
inset.setShadow(new Shadow(2,2,5,new Color("#999999")).setStyle(Shadow.Style.INSET));
inset.add(new Text("Inset card"));
layout.add(inset);Choosing shadow strength
Small offsets with a soft blur suit cards and understated panels. Larger, darker shadows draw attention but can make a dense interface visually noisy.
Creating a reusable shadow
The same idea can also be expressed as a compact Java snippet without requiring a live preview.
CODE
Shadow shadow = new Shadow(2,2,6,new Color("#BBBBBB"));
card.setShadow(shadow);
Practical guidance
Text and layout shadows have different rendering targets. Use setShadow on the intended component and verify the effect against the actual background.
Full API reference
These examples focus on the day-to-day use of Shadow. The full API documentation contains additional options, inherited properties and complete method signatures.
Visit https://doc.jdance.org for the full reference.