Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This would be done by utilising the <code>Border</code> API available within the Swing. Take a closer look at <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.html" rel="nofollow noreferrer">How to use borders</a> for more details.</p> <p>As a very rough example...</p> <p><img src="https://i.stack.imgur.com/GxF8t.png" alt="enter image description here"></p> <pre><code>import java.awt.BorderLayout; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.MatteBorder; public class PanelTitles { public static void main(String[] args) { new PanelTitles(); } public PanelTitles() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TitlePane(), BorderLayout.NORTH); frame.add(new JLabel("This is the content")); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class TitlePane extends JPanel { public TitlePane() { setLayout(new BorderLayout()); setBorder(new CompoundBorder(new EmptyBorder(4, 4, 4, 4), new MatteBorder(0, 0, 1, 0, Color.BLACK))); JLabel label = new JLabel("This is a title"); label.setFont(label.getFont().deriveFont(Font.BOLD)); add(label); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload