0

Looking at the screen short how do i add the Steps and Choose project

is it a jabel or a title in the panel

image

Johan
  • 74,508
  • 24
  • 191
  • 319
BeyondProgrammer
  • 893
  • 2
  • 15
  • 32

1 Answers1

3

This would be done by utilising the Border API available within the Swing. Take a closer look at How to use borders for more details.

As a very rough example...

enter image description here

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);
        }        
    }        
}
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • 2
    Also look at `TitledBorder` as seen in [this answer](http://stackoverflow.com/a/19138661/418556). It is not as nice as the multiple border seen in this solution, but possibly fewer lines of code. – Andrew Thompson Oct 04 '13 at 05:35