import java.awt.*;
import javax.swing.*;
public class HtmlTagsInJava extends JFrame
{
public static void main(String surat[])
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
}
catch(Exception e)
{
System.out.println(e);
}
new HtmlTagsInJava();
}
public HtmlTagsInJava()
{
super("Using HTML in JLabel");
Container c=getContentPane();
Font f=new Font("Serif",Font.PLAIN,35);
c.setFont(f);
String LabelText="<html> <font color=red> Red </font> and"
+"<font color=blue> Blue </font> Text </html>";
JLabel coloredLabel=new JLabel(LabelText,JLabel.CENTER);
coloredLabel.setBorder(BorderFactory.createTitledBorder("Mixed colors"));
c.add(coloredLabel,BorderLayout.NORTH);
LabelText="<html> <b> Bold </b> and" + "<i> Italic </i> Text </html>";
JLabel boldLabel=new JLabel(LabelText,JLabel.CENTER);
boldLabel.setBorder(BorderFactory.createTitledBorder("Mixed Fonts"));
c.add(boldLabel,BorderLayout.CENTER);
LabelText= "<html> India is good Country " + "<p> " +
"Major Cities of India : " +
"<UL>" +
"<li> Delhi " +
"<li> Surat " +
"<li> Mumbai " +
"<li> Banglore " +
"<li> Jaipur " +
"<li> etc " +
"</ul>";
JLabel fancyLabel=new JLabel(LabelText,JLabel.CENTER);
fancyLabel.setBorder(BorderFactory.createTitledBorder("Multi Line Html"));
c.add(fancyLabel,BorderLayout.SOUTH);
setSize(400,400);
setVisible(true);
}
}
Output:
import javax.swing.*;
public class HtmlTagsInJava extends JFrame
{
public static void main(String surat[])
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
}
catch(Exception e)
{
System.out.println(e);
}
new HtmlTagsInJava();
}
public HtmlTagsInJava()
{
super("Using HTML in JLabel");
Container c=getContentPane();
Font f=new Font("Serif",Font.PLAIN,35);
c.setFont(f);
String LabelText="<html> <font color=red> Red </font> and"
+"<font color=blue> Blue </font> Text </html>";
JLabel coloredLabel=new JLabel(LabelText,JLabel.CENTER);
coloredLabel.setBorder(BorderFactory.createTitledBorder("Mixed colors"));
c.add(coloredLabel,BorderLayout.NORTH);
LabelText="<html> <b> Bold </b> and" + "<i> Italic </i> Text </html>";
JLabel boldLabel=new JLabel(LabelText,JLabel.CENTER);
boldLabel.setBorder(BorderFactory.createTitledBorder("Mixed Fonts"));
c.add(boldLabel,BorderLayout.CENTER);
LabelText= "<html> India is good Country " + "<p> " +
"Major Cities of India : " +
"<UL>" +
"<li> Delhi " +
"<li> Surat " +
"<li> Mumbai " +
"<li> Banglore " +
"<li> Jaipur " +
"<li> etc " +
"</ul>";
JLabel fancyLabel=new JLabel(LabelText,JLabel.CENTER);
fancyLabel.setBorder(BorderFactory.createTitledBorder("Multi Line Html"));
c.add(fancyLabel,BorderLayout.SOUTH);
setSize(400,400);
setVisible(true);
}
}
Output:
No comments:
Post a Comment