Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java GUI 101 - changing the title of a JPanel

Simple question here. How do I change the title of a JPanel, for exmple

http://docs.oracle.com/javase/tutorial/figures/uiswing/components/ConverterColored.png

change the text "converter" here to something else?

Thanks in advance!


EDIT: sorry, it was a JPanel!

like image 471
foaf Avatar asked Nov 28 '22 18:11

foaf


2 Answers

First of all, the link you provided contains a JFrame not JPanel.

Second, pass the title as a parameter to the JFrame constructor once you create it JFrame(String title):

JFrame myFrame = new JFrame("My Title");

or use the method setTitle(String title) inherited from class Frame:

myFrame.setTitle("My Title");
like image 78
Eng.Fouad Avatar answered Dec 05 '22 10:12

Eng.Fouad


The element in the screen you linked to looks like a JFrame, and not a JPanel. The setTitle() method should do the trick.

like image 39
filip-fku Avatar answered Dec 05 '22 10:12

filip-fku