Reputation: 41
This is a potion of my code:
topPanel = new JPanel ();
subheading = new JLabel("CRUISES");
description = new JLabel("Add or remove Cruises or click to assign a Cruise to a ship.");
topPanel.add(subheading);
topPanel.add(description);
CruiseFrame.add(topPanel);
CruiseFrame.setVisible(true)
Everything is working well, and upon running the above, I get the following result in my GUI:
"CRUISES Add or remove Cruises or click to assign a Cruise to a ship."
However, I wish to have the output as:
CRUISES
Add or remove Cruises or click to assign a Cruise to a ship.
I wish to have them on seperate lines, how do I go about this?
Thanks.
Upvotes: 0
Views: 40
Reputation: 3019
You can utilize simple HTML in Swing to style JLabels:
"<html>CRUISES<br> Add or remove Cruises or click to assign a Cruise to a ship.</html>"
Which will look like:
"CRUISES
Add or remove Cruises or click to assign a Cruise to a ship."
This might be better than using two JLabels, if it does meet the layout requirements.
Upvotes: 2