CS2_39_Graphics3

CS2_39_Graphics3 - CS2 Module 39 Category: CS Concepts...

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

View Full Document Right Arrow Icon
CS2 Module 39 Category: CS Concepts Topic: Graphics 3 Objectives Mouse/Event/Drawing/Graphics Interaction: Scribble Drag and drop
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 2 Introduction to Object Oriented Programming Module 39 CS Concepts Graphics 3
Background image of page 2
Simple Scribble Application
Background image of page 3

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

View Full DocumentRight Arrow Icon
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Scribbler extends JFrame implements ActionListener, WindowListener { private ScribblePanel sp; private JButton reset; private JButton red; private JButton yellow; private JButton green; private JButton blue; private JButton black;
Background image of page 4
public Scribbler() { getContentPane().setLayout (new BorderLayout ()); sp = new ScribblePanel (); getContentPane().add (sp, BorderLayout.CENTER); JPanel bp = new JPanel (); bp.setLayout (new FlowLayout ()); reset = new JButton ("reset"); reset.addActionListener (this); bp.add (reset); getContentPane().add (bp, BorderLayout.NORTH); JPanel cp = new JPanel (); cp.setLayout (new FlowLayout ());
Background image of page 5

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

View Full DocumentRight Arrow Icon
// public Scribbler() continued red = new JButton ("Red"); red.addActionListener (this); cp.add (red); yellow = new JButton ("Yellow"); yellow.addActionListener (this); cp.add (yellow); green = new JButton ("Green"); green.addActionListener (this); cp.add (green); blue = new JButton ("Blue"); blue.addActionListener (this); cp.add (blue); black = new JButton ("Black"); black.addActionListener (this); cp.add (black);
Background image of page 6
// public Scribbler() continued getContentPane().add (cp, BorderLayout.SOUTH);
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

CS2_39_Graphics3 - CS2 Module 39 Category: CS Concepts...

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

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