Java Reference
In-Depth Information
boldCB.setSize(100, 30);
italicCB.setSize(100,30);
boldCB.setLocation(100, 100);
italicCB.setLocation(300, 100);
boldCB.addItemListener( this );
italicCB.addItemListener( this );
c.add(boldCB);
c.add(italicCB);
}
public void paint( Graphics g)
{
super .paint(g);
g.setColor(Color.red);
g.setFont( new Font("Courier", intBold + intItalic, 24));
g.drawString("Welcome to Java Programming", 30, 30);
}
public void itemStateChanged(ItemEvent e)
{
if (e.getSource() == boldCB)
{
if (e.getStateChange() == ItemEvent.SELECTED)
intBold = Font.BOLD;
if (e.getStateChange() == ItemEvent.DESELECTED)
intBold = Font.PLAIN;
}
if (e.getSource() == italicCB)
{
if (e.getStateChange() == ItemEvent.SELECTED)
intItalic = Font.ITALIC;
if (e.getStateChange() == ItemEvent.DESELECTED)
intItalic = Font.PLAIN;
}
repaint();
}
}
The HTML file for this program contains the following code:
<HTML>
<HEAD>
<TITLE>WELCOME</TITLE>
</HEAD>
<BODY>
<OBJECT code = "GrandWelcomeCheckBox.class" width = "440"
height = "200">
</OBJECT>
</BODY>
</HTML>
Search WWH ::




Custom Search