JLabel.getText() has the following syntax.
public String getText()
In the following code shows how to use JLabel.getText() method.
//from w w w .jav a2s . c o m import javax.swing.JFrame; import javax.swing.JLabel; public class Main { public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String htmlLabel = "<html><sup>HTML</sup> <sub><em>Label</em></sub><br>" + "<font color=\"#FF0080\"><u>Multi-line</u></font>"; JLabel label = new JLabel(htmlLabel); System.out.println(label.getText()); frame.add(label); frame.setSize(300, 200); frame.setVisible(true); } }