Set a Title for a jPanel on eclipse
13,767
This is What I did
JPanel mainPanel = new JPanel();
String title = "A titled border";
Border border = BorderFactory.createTitledBorder(title);
mainPanel.setBorder(border);
Author by
Beginnerprogrammer
Updated on July 14, 2022Comments
-
Beginnerprogrammer almost 2 years
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 -
byxor over 7 yearsI've tweaked your code a little bit to make it more readable.
-
Beginnerprogrammer over 7 yearsThank you ! @BrandonIbbotson
-
Gustavo Rodríguez over 4 yearsI got "error: cannot find symbol" around "Border" so I must add "import javax.swing.border.TitledBorder;" and replace "Border border" by "TitledBorder border= BorderFactory.createTitledBorder("A titled border");"