13-07mar06loopsturtles

13-07mar06loopsturtles - 1 CS100J 6 March 2007 Assignment...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 1 CS100J 6 March, 2007 Assignment A5: graphics, and loops The next time someone in government rather casually use a number that includes the word "billion", think about it. * A billion seconds ago was 1959. * A billion minutes ago Jesus was alive. * A billion hours ago our ancestors were living in the Stone Age. * A billion days ago no creature walked the earth on two feet. * And a billion dollars lasts 8 hours and 20 minutes at the rate our government spends it. Read: Sec. 2.3.8 and chapter 7 on loops. The lectures on the ProgramLive CD can be a big help. 2 Graphical User Interfaces (GUIs): graphics. A JFrame, with a panel on which you can draw jframe= new JFrame("Turtle window"); jpanel= new JPanel(); jpanel.setPreferredSize(new Dimension(width, height)); jpanel.setBackground(Color.white); jframe.getContentPane().add(panel, BorderLayout.CENTER); jframe.pack(); jframe.setVisible( true ); graphics= jpanel.getGraphics(); A “panel” in which you can draw You don’t have to learn all this unless you want to. We will be telling you more and more about GUIs as the course progresses. 3 Commands to draw // Draw a line from (10, 10) to (50, 40). d.graphics.drawLine(10,10,50, 40); // Draw a rectangle with top-left point (2, 5), width 40, and height 60 d.graphics.drawRect(2, 5, 40, 60); // Fill a rectangle with top-left point (50, 70), width 40, and height 60 d.graphics.fillRect(50, 70, 40, 60); (0,0) (0,1) (0, 2) … (1,0) (1,1), (1,2) … (2,0) (2,1), (2,2) … … The panel: each pair (i,j) is a “pixel” or picture element. 4...
View Full Document

This note was uploaded on 03/03/2012 for the course CS 100J taught by Professor Davidgries during the Spring '07 term at Cornell.

Page1 / 12

13-07mar06loopsturtles - 1 CS100J 6 March 2007 Assignment...

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

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