Set a Title for a jPanel on eclipse

Beginnerprogrammer picture Beginnerprogrammer · Sep 6, 2016 · Viewed 11.6k times · Source

I'm new to programming and I have a question about the window builder. I searched online looking for a way to set a title for a jPanel and not a Jframe, and all what I found was to use for the Jframe setVisible. I don't know if there is a way to set a title for jpanel. I need the user to always see which screen he accessed. I'm using eclipse java language. Please help

Answer

Beginnerprogrammer picture Beginnerprogrammer · Sep 6, 2016

This is What I did

JPanel mainPanel = new JPanel();

String title = "A titled border";
Border border = BorderFactory.createTitledBorder(title);
mainPanel.setBorder(border);