Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why I cannot change font and Color in JFrame title??

sunnycodeMar 20 2009 — edited Mar 21 2009
Dear sir:

I try to change font and Color in JFrame title in code below,
It display all html code, not expected formatted ones.
but fail. Looks like no way to do it??
Can somebody help??
Thanks
import java.awt.BorderLayout;
import java.awt.Toolkit;

import javax.swing.*;

public class JFrameTester {

  public static void main(String[] args) {
	String iconPath ="file:C:/eclipse/workspace/Test/images/long.PNG";
	String title = "<html><body bgcolor=\"yellow\">" + "<img src=\""+iconPath+"\">" +
		" <font size=\"6\" face=\"Verdana\" color=\"red\"><b>"+ "New Tester" + "</b></font></html>";
    JFrame f = new JFrame(title);
    f.setIconImage(Toolkit.getDefaultToolkit().getImage("images/123.gif"));
    f.setSize(250, 250);
    f.setLocation(300,200);
    f.getContentPane().add(new BorderLayout().CENTER, new JTextArea(10, 40));
    f.setVisible(true);
    
  }
  
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 18 2009
Added on Mar 20 2009
5 comments
650 views