-2

I use a line of code exactly like this one:

    MyFrame.add(new JLabel("<html><body>Information to be displayed</body></html>"));

Each time i execute my project, nothing displays in the JFrame MyFrame including other data not related to the JLabel. Please someone should kindly tell me where i'm going wrong.

  • (1-) `Please someone should kindly tell me where i'm going wrong.` - how can we possible know what you are doing wrong based on a single line of code. `nothing displays in the JFrame MyFrame including other data not related to the JLabel.` - so then the HTML is not the problem. Start by reading the section from the Swing tutorial on [How to Use Labels](https://docs.oracle.com/javase/tutorial/uiswing/components/label.html) for working examples. Download the demo code and change the labels in the demo code to use HTML. – camickr Nov 22 '17 at 16:03
  • Thank you for that link. I was able to learn new methods of using html. Will try to apply them. – caleb fonyuy Nov 23 '17 at 06:45

1 Answers1

0

I think that's duplicate question, see:
How do I put html in a JLabel in java?
HTML in JLabel not showing

test this code:

    JFrame MyFrame=new JFrame();
    MyFrame.setSize(300, 300);
    MyFrame.add(new JLabel("<html><font color='green'>Information to be </font> displayed <br/>it is tested</html>"));
    MyFrame.setVisible(true);
Gholamali Irani
  • 4,391
  • 6
  • 28
  • 59