GrandWelcomeCheckBox

GrandWelcomeCheckBox - { super.paint(g);...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//Welcome Applet with check boxes / import java.awt.*; import java.awt.event.*; import javax.swing.*; i public class GrandWelcomeCheckBox extends JApplet implements ItemListener { private int intBold = Font.PLAIN; private int intItalic = Font.PLAIN; private JCheckBox boldCB, italicCB; public void init() { Container c = getContentPane(); c.setLayout(null); boldCB = new JCheckBox("Bold"); italicCB = new JCheckBox("Italic"); 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)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { 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(); } }...
View Full Document

Page1 / 2

GrandWelcomeCheckBox - { super.paint(g);...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online