Lab 2 - Lab 2 Creating objects calling their methods and...

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

View Full Document Right Arrow Icon
writing subclasses This lab helps you experiment with creating objects, calling their methods, and writing subclasses. At the end of this handout is a list of oft-used methods of class JFrame. The instructions ask you to write some things down on a piece of paper, so that you can (if you want) show what you have done to a consultant and see what you have done is correct. Whether you do this is up to you. Task 1. Practicing calling methods of objects (a) In DrJava, using the interactions pane, create two different JFrames and show them. You can drag them to different places. (Remember that you need to import the classes of package javax.swing. See Sec. 1.3.2 of the text. You create a JFrame folder and store its name in a variable jf1 using the assignment: jf1= new JFrame(); (b) Try out these method calls. In the table below, we show calls on the methods, using three dots . .. to denote the position of an argument, which you have to fill in when you type in the call in the DrJava interactions pane. For a function call, write the value that the function call returns, so that we know that you tried such a call. For a procedure call, just put a check next to it. You can call these methods as many times as you want. Experiment. show(); getWidth() setSize(int, int); getHeight() setLocation(int, int); getX() setTitle(String); getY() Describe BRIEFLY, below, the syntactic and semantic differences between the methods (and calls on them) being called in the left column and those being called in the right. Hint: what kind of method is called in the left column and what kind on the right? Syntax refers to grammar, structure. Semantics refers to meaning —in programming, how a statement is executed or an expression is evaluated. Task 2. Positioning JFrames
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

Lab 2 - Lab 2 Creating objects calling their methods and...

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