Class DelegatingBorder

  • All Implemented Interfaces:
    Serializable, Border

    public class DelegatingBorder
    extends AbstractBorder
    A self-installing border that wraps another Border (e.g., TitledBorder) and overlays a real Swing component as a child inside the border. No explicit install() needed.

    Usage: TitledBorder titled = BorderFactory.createTitledBorder("Dataset"); DelegatingBorder border = new DelegatingBorder( titled, () -> { JLabel sub = new JLabel(""); sub.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); sub.setToolTipText("Click for details"); sub.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(sub), "Clicked!"); } }); return sub; }, DelegatingBorder.Anchor.SOUTH_EAST, new Insets(4,6,4,6) ); panel.setBorder(border);

    See Also:
    Serialized Form