lecture25-applets

lecture25-applets - Lecture 25: Graphics in Java Lecture...

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

View Full Document Right Arrow Icon
cture 5: Graphics in Java Lecture 25: Graphics in Java CS 170, Section 000 ecember 2009 3 December 2009 12/3/2009 CS170, Section 000, Fall 2009 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture Plan ± Homework 8 details review ¾ More on GUIs ¾ More on Java GUI API (Ch. 13): ¾ Essential Swing components and layouts ¾ Putting it all together: TicTacToe ¾ GUI very similar to HW8 ² Homework 8 questions CS170, Section 000, Fall 2009 2
Background image of page 2
HW8: Game of Life A mathematical game invented by mathematician John Conway in 1970 Game rules A dead cell with exactly three live neighbors becomes a live cell (birth). A live cell with two or three live neighbors stays alive (survival). gy ( ) In all other cases, a cell dies or remains dead (overcrowding or loneliness). esources and demos Resources and demos http://www.math.com/students/wonders/life/life.html http://www.ibiblio.org/lifepatterns/ plementation Implementation Use Timer class for animation Use two dimensional arrays for cell updates, then drawImage! en better: draw each cell separately (as anel e icTacToe xample ¾ Even better: draw each cell separately (as JPanel like TicTacToe example – stay tuned)!
Background image of page 3

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

View Full DocumentRight Arrow Icon
GUI Class Hierarchy (Swing) Dimension eavyweight Classes in the java.awt package LayoutManager Font FontMetrics Heavyweight 1 Graphics Object Color Panel Applet JApplet Component Container Frame Dialog Window JFrame JDialog * JComponent Swing Components in the javax.swing package 4 Lightweight
Background image of page 4
Container Classes Dimension nt Heavyweight Classes in the java.awt package LayoutManager Font FontMetrics bject olor anel pplet pplet 1 Component Graphics Object Color Container Panel Applet Frame Window JApplet JFrame Dialog JDialog * JComponent Swing Components in the javax.swing package JPanel Container classes can contain other GUI components. 5 Lightweight
Background image of page 5

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

View Full DocumentRight Arrow Icon
Swing GUI Components JMenuItem JCheckBoxMenuItem JMenu AbstractButton JRadioButtonMenuItem JToggleButton JCheckBox JButton JComponent JRadioButton JTextField JTextComponent JPasswordField JEditorPane ComboBox List OptionPane ScrollBar Slider JTextArea Panel Label JComboBox JLayeredPane JList JMenuBar JOptionPane PopupMenu FileChooser JScrollBar JScrollPane JSeparator JSplitPane JSlider JTabbedPane JToolBar JToolTip JRootPane JPanel JColorChooser JLabel 6 JInternalFrame Jp p JProgressBar JC JTable JTableHeader p JTree JSpinner
Background image of page 6
Frames Frame is a window that is not contained inside another window. Frame is the basis to contain other user interface components in Java GUI applications. e JFrame class can be used to create The JFrame class can be used to create windows. For Swing GUI programs, use JFrame class to create widows. 7
Background image of page 7

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

View Full DocumentRight Arrow Icon
Creating Frames import javax.swing.*; public class MyFrame { public static void main(String[] args) { JFrame frame = new JFrame("Test Frame"); frame.setSize(400, 300); frame.setVisible(true); rame setDefaultCloseOperation( frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); } } 8
Background image of page 8
Adding Components into a Frame
Background image of page 9

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

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

Page1 / 30

lecture25-applets - Lecture 25: Graphics in Java Lecture...

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

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