How to set distance between border title and border in Java Swing

154 Views Asked by At

Hello I'd like to add the border title 50px above the border without changing any thickness of the border.

So far, my code is below and it displays far left/bottom on the corner of the window.

    Border emptyBorder = BorderFactory.createEmptyBorder();
    final TitledBorder borderTitle= BorderFactory.createTitledBorder(emptyBorder, "Border Title");
    borderTitle.setTitlePosition(TitledBorder.ABOVE_BOTTOM);
    panel.setBorder(borderTitle);

Is it possible to add a border title away from the border or should I rather use a separate JLabel? Or any other suggestion?

0

There are 0 best solutions below