Java GUI 101 - changing the title of a JPanel

27,403

Solution 1

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");

Solution 2

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

Solution 3

It's not the JPanel, I think it will be the JFrame that you want to change, it has a setTitle() method you can use.
Also the constructor for the JFrame takes a string argument for it's title

Solution 4

Or if you don't have access to the JFrame directly (or just want to do it in a neater, more portable fashion)

SwingUtilities.getRoot(this).setTitle("SomeTitle);

Solution 5

That's not a JPanel. It's a JFrame that contains JPanels.

The title can be set in the constructor, and can be changed with setTitle()

If you read the tutorial you're linking to, you'll note that there's a link to the "Converter" application. Further reading would take you to the source for that tutorial application:

Converter application source

 //Create and set up the window.
 JFrame frame = new JFrame("Converter");
Share:
27,403
foaf
Author by

foaf

Updated on July 02, 2020

Comments