Consider this code:
TextField textField = new TextField(""); int DELAY = 1000; ActionListener listener = event -> textField.setText("Hello..."); Timer t = new Timer(DELAY, listener); // Add text field to frame and show frame
Assuming that textField
is in a frame and the frame is shown in the usual way, what is the contents of the text field after 3 seconds;
Hello...
Hello...Hello...Hello...
What does this set of instructions draw?
Ellipse2D.Double e = new Ellipse2D.Double(10, 10, 20, 20); Rectangle2D.Double r = new Rectangle2D.Double(10, 30, 20, 20);
Which of the following classes or interfaces are in the standard Java library (and not the library of the textbook)? Check all that apply.
~/oodp3code/ch04/action/ActionTester.java
file into your lab8
directory and make a project in that directory.JButton.setEnabled
.Hello 1
, Goodbye 1
, Hello 2
, and so on, incrementing with each button click. ~/oodp3code/ch04/animation
file into your lab8
directory and refresh the Eclipse project..MoveableShape
objects. Test with two cars.BouncingBall
that is also a MoveableShape
. It should bounce up and down.ImageIcon
to the list of moveable shapes?public class MoveableIcon extends ImageIcon implements MoveableShape { public MoveableIcon(String filename, int x, int y) { super(filename); this.x = x; this.y = y; } . . . private int x; private int y; }
new MoveableIcon("dog.png", 100, 0)
to the list of moveable shapes and run the program. What happens?x
in the move
method. Make it more real by randomly moving left and right:
if (Math.random() < 0.5) ...
Dog
class or by changing MoveableIcon.move
? What would be better?