Is it possible to have a java swing border only on the top side?

You can use the MatteBorder to specify the dimensions of the border in each side. The constructor of MatteBorder is:

public MatteBorder(int top,
                   int left,
                   int bottom,
                   int right,
                   Color matteColor)

So if you want to have a border only on the bottom and right sides of your JPanel, you could write something like this:

JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.BLACK));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)