Deck 17: Applets, Images, and Sound

Full screen (f)
exit full mode
Question
The ____ command is part of the Java Development Kit (JDK), which provides a convenient environment in which to test your applets.

A) appletview
B) appletviewer
C) viewapplet
D) av
Use Space or
up arrow
down arrow
to flip the card.
Question
The name of a called applet must be a compiled Java applet with a .class file extension.
Question
The GIF image format is more flexible than other formats and uses lossless data compression.
Question
Because applets execute in a browser, the JApplet class contains methods that are automatically called by the browser.
Question
If the JApplet class was not already written, you would have to write more than ____ methods to give your JApplet all the capabilities of the built-in JApplet class.

A) 20
B) 50
C) 200
D) 300
Question
The applet can be run within a page on the Internet or an intranet, but you do not have to connect to the Internet to run an applet in your browser-you can simply use the browser locally.
Question
What package contains the JApplet class?

A) javax.applet
B) javax.swing
C) java.applet
D) java.swing
Question
You save applets with a(n) ____ file extension.

A).java
B).appl
C).applet
D).class
Question
Applet code runs in a constrained area called a(n) ____.

A) sandbox
B) toolbox
C) appletview
D) XHTML
Question
What is the parent class of JApplet?

A) Container
B) Component
C) Applet
D) Panel
Question
____ contains many commands that allow you to format text on a Web page, import graphic images, and link your page to other Web pages.

A) JApplet
B) HTML
C) Swing
D) Applet
Question
There are four methods inherited from JApplet that make up the life cycle of an applet.
Question
Applets can delete, read, or create files on the user's system.
Question
It is common practice for programmers to write their own stop() and destroy() methods.
Question
You can run an applet in a ____.

A) main() method
B) Java application
C) Web server
D) Web browser
Question
To compile an applet into bytecode, use the ____ command.

A) appletview
B) viewapp
C) javac
D) java
Question
You can use an overloaded version of the Image class method drawImage() to output a scaled image.
Question
In the JApplet life cycle, a paint() method would always be called before the init() and start() methods.
Question
You do not use the java command to execute an applet.
Question
The extension of an HTML document should be .html or ____.

A).htm
B).app
C).java
D).class
Question
A(n) ___________________ is a likeness of a person or thing.
Question
The ____ provides image-manipulation capabilities.

A) Java Speech API
B) Java Media Framework (JMF)
C) Java 3D API
D) Java Advanced Imaging API
Question
Which of the following lines of code are used when creating a JApplet using only the init() method?

A) public add.init()
B) public void init()
C) public void start()
D) public new init()
Question
If you want to place an image on a button, it is simplest to use the ____ class.

A) Image
B) ImageIcon
C) Sound
D) Graphics
Question
By calling ____ in an applet, you get a URL object that represents the folder in which the applet's class file is stored.

A) getFile()
B) getClass()
C) getDocBase()
D) getCodeBase()
Question
A(n) ___________________ is a program that is called within another application-often a Web browser.
Question
Use the ____ applet method to perform initialization tasks, such as setting variables to initial values or placing applet components on the screen.

A) initialize()
B) begin()
C) init()
D) start()
Question
The ___________________ method is always called after the init() and start() methods execute.
Question
The ____ method is used to load an Image into the named Image in the applet.

A) get()
B) loadImage()
C) load()
D) getImage()
Question
The ____ API allows you to add audio and video media to an application.

A) Java Media Framework (JMF)
B) Java Advanced Imaging
C) Java Speech
D) Java 2D or the Java 3D
Question
Which of the following statements will properly code the init() method header?

A) import void init()
B) JApplet void init()
C) JLabel = new init()
D) public void init()
Question
The tag that begins every HTML document is ____.

A)
B)
C)
D)
Question
You override the existing empty ____ method only if you want to take some action when a JApplet is no longer visible.

A) hide()
B) onHide()
C) destroy()
D) stop()
Question
Usually, you place three attributes within the tag: code, width, and ____.

A) codebase
B) size
C) length
D) height
Question
Invoking the ____ method after adding one or more JComponents to an applet ensures that the Components draw themselves on the screen.

A) draw()
B) paint()
C) repaint()
D) validate()
Question
When you write your own ____ method, you must include any actions you want your JApplet to take when a user revisits the JApplet.

A) repaint()
B) start()
C) paint()
D) restart()
Question
To run an applet from an HTML document, you add an and ___________________ tag pair.
Question
___________________ is a Swing class from which you can inherit to create your own applet.
Question
Which of the following cannot be performed with JApplets?

A) Use layout managers.
B) Add images and sounds.
C) Use a flow() method for layout.
D) Change label fonts/colors.
Question
With an applet, the browser can call ____ different methods automatically at different times.

A) two
B) three
C) four
D) five
Question
What are the four steps involved in creating an applet?
Question
What are the three object tag attributes commonly used to run an applet?
Question
How do you view an applet?
Question
How is an applet like a Java application?
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Executes again every time the applet becomes active after it has been inactive
Question
Explain lossless data compression and the image formats with which it is used.
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Describes the use of sound, images, graphics, and video in computer programs
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Retrieves and plays the sound as soon as possible after it is called
Question
Briefly describe the image formats that Java supports.
Question
How is an applet different from a Java application?
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Provides a convenient environment in which to test your applets
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Surrounded by angle brackets
Question
What are the two forms of the play() method?
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
A simple language used to create Web pages for the Internet
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
The first method called in any applet
Question
Describe the two methods for running an applet.
Question
Describe the stop() method.
Question
What are the methods of the applet life cycle?
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
A little application
Question
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Extensible Hypertext Markup Language
Question
Write the statement to retrieve and play the myTune.au sound file that will be stored in the same place as the applet.
Question
There are three attributes typically placed within the tag: code, width, and height. Describe the purpose of the three object tag attributes and their corresponding arguments.
Question
public void actionPerformed(ActionEvent e)
{
String name = answer.getText();
con.remove(greeting);
con.remove(pressMe);
con.remove(answer);
personalGreeting.setText("Hello, " + name + "! ");
con.add(personalGreeting);
con.setBackground(Color.PINK);
validate();
}
In the actionPerformed() method above, the final statement following the addition of the JLabel is validate(). Explain the validate() method and how it is used with JComponents.
Question
In order to play sounds more than once, or to stop and start sounds, the sound must be loaded into an AudioClip object. Write the statement to load the AudioClip named myClip with the sound file myTune.au, which is located in the audio folder.
Question

Using the above statement, identify the three object tag attributes and their corresponding arguments.
Question

____________________


Using the HTML code above, write the statement to run a JApplet named JHello. The applet will be 450 pixels wide by 150 pixels tall.
Question
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class JSound extends JApplet
{
AudioClip sound;
public void init()
{
sound = getAudioClip(getCodeBase(),"mysteryTune.au");
}
public void start()
{
___________________________________
}
public void stop()
{
___________________________________
}
public void paint(Graphics g)
{
super.paint(g);
Graphics2D g2D = (Graphics2D)g;
g2D.drawString("Listen to the mystery tune ", 10, 10);
}
}
In the first shaded line provided, write the loop() method to play the mysteryTune.au sound continually. On the second shaded line, write the stop() method to halt the mysteryTune.au sound file.
Question
import javax.swing.*;
import java.awt.*;
public class JHello extends JApplet
{
JLabel greeting = new JLabel("Hello. Who are you?");
public void init()
{
add(greeting);
}
}
The above code displays an applet with a JLabel added without a specified BorderLayout region. Describe how the JLabel will occupy the JApplet surface.
Question
arrowPicture.paintIcon(this, g, 150, 0);
The statement above is used to display the arrowPicture ImageIcon using the paintIcon() method. Describe the four arguments that are used in this method.
Question
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class JCompanyImage extends JApplet
{
Image companyLogo;
final int WIDTH = 287;
final int HEIGHT = 129;
final int FACTOR = 2;
public void init()
{
companyLogo = getImage(getCodeBase(), "CompanyLogo. png");
}
public void paint(Graphics g)
{
super.paint(g);
// Draw image at its natural size
___________________________________
// Draw the image scaled - twice as large
___________________________________
}
}
Using the above code, complete the first shaded line with the statement to draw the image first in its original size in the upper-left corner. In the second shaded line, write the code to redraw the image at twice its original size using the WIDTH, HEIGHT, and FACTOR values.
Question
The init() method is the first method called in any applet. Write the code for the init() method header and explain the purpose of the init() method.
Question

____________________________


In the blank line provided, write the code to run a JApplet named JGreeting that will be 370 pixels wide by 110 pixels tall.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/72
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 17: Applets, Images, and Sound
1
The ____ command is part of the Java Development Kit (JDK), which provides a convenient environment in which to test your applets.

A) appletview
B) appletviewer
C) viewapplet
D) av
B
2
The name of a called applet must be a compiled Java applet with a .class file extension.
True
3
The GIF image format is more flexible than other formats and uses lossless data compression.
False
4
Because applets execute in a browser, the JApplet class contains methods that are automatically called by the browser.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
5
If the JApplet class was not already written, you would have to write more than ____ methods to give your JApplet all the capabilities of the built-in JApplet class.

A) 20
B) 50
C) 200
D) 300
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
6
The applet can be run within a page on the Internet or an intranet, but you do not have to connect to the Internet to run an applet in your browser-you can simply use the browser locally.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
7
What package contains the JApplet class?

A) javax.applet
B) javax.swing
C) java.applet
D) java.swing
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
8
You save applets with a(n) ____ file extension.

A).java
B).appl
C).applet
D).class
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
9
Applet code runs in a constrained area called a(n) ____.

A) sandbox
B) toolbox
C) appletview
D) XHTML
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
10
What is the parent class of JApplet?

A) Container
B) Component
C) Applet
D) Panel
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
11
____ contains many commands that allow you to format text on a Web page, import graphic images, and link your page to other Web pages.

A) JApplet
B) HTML
C) Swing
D) Applet
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
12
There are four methods inherited from JApplet that make up the life cycle of an applet.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
13
Applets can delete, read, or create files on the user's system.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
14
It is common practice for programmers to write their own stop() and destroy() methods.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
15
You can run an applet in a ____.

A) main() method
B) Java application
C) Web server
D) Web browser
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
16
To compile an applet into bytecode, use the ____ command.

A) appletview
B) viewapp
C) javac
D) java
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
17
You can use an overloaded version of the Image class method drawImage() to output a scaled image.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
18
In the JApplet life cycle, a paint() method would always be called before the init() and start() methods.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
19
You do not use the java command to execute an applet.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
20
The extension of an HTML document should be .html or ____.

A).htm
B).app
C).java
D).class
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
21
A(n) ___________________ is a likeness of a person or thing.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
22
The ____ provides image-manipulation capabilities.

A) Java Speech API
B) Java Media Framework (JMF)
C) Java 3D API
D) Java Advanced Imaging API
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following lines of code are used when creating a JApplet using only the init() method?

A) public add.init()
B) public void init()
C) public void start()
D) public new init()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
24
If you want to place an image on a button, it is simplest to use the ____ class.

A) Image
B) ImageIcon
C) Sound
D) Graphics
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
25
By calling ____ in an applet, you get a URL object that represents the folder in which the applet's class file is stored.

A) getFile()
B) getClass()
C) getDocBase()
D) getCodeBase()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
26
A(n) ___________________ is a program that is called within another application-often a Web browser.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
27
Use the ____ applet method to perform initialization tasks, such as setting variables to initial values or placing applet components on the screen.

A) initialize()
B) begin()
C) init()
D) start()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
28
The ___________________ method is always called after the init() and start() methods execute.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
29
The ____ method is used to load an Image into the named Image in the applet.

A) get()
B) loadImage()
C) load()
D) getImage()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
30
The ____ API allows you to add audio and video media to an application.

A) Java Media Framework (JMF)
B) Java Advanced Imaging
C) Java Speech
D) Java 2D or the Java 3D
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following statements will properly code the init() method header?

A) import void init()
B) JApplet void init()
C) JLabel = new init()
D) public void init()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
32
The tag that begins every HTML document is ____.

A)
B)
C)
D)
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
33
You override the existing empty ____ method only if you want to take some action when a JApplet is no longer visible.

A) hide()
B) onHide()
C) destroy()
D) stop()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
34
Usually, you place three attributes within the tag: code, width, and ____.

A) codebase
B) size
C) length
D) height
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
35
Invoking the ____ method after adding one or more JComponents to an applet ensures that the Components draw themselves on the screen.

A) draw()
B) paint()
C) repaint()
D) validate()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
36
When you write your own ____ method, you must include any actions you want your JApplet to take when a user revisits the JApplet.

A) repaint()
B) start()
C) paint()
D) restart()
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
37
To run an applet from an HTML document, you add an and ___________________ tag pair.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
38
___________________ is a Swing class from which you can inherit to create your own applet.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following cannot be performed with JApplets?

A) Use layout managers.
B) Add images and sounds.
C) Use a flow() method for layout.
D) Change label fonts/colors.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
40
With an applet, the browser can call ____ different methods automatically at different times.

A) two
B) three
C) four
D) five
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
41
What are the four steps involved in creating an applet?
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
42
What are the three object tag attributes commonly used to run an applet?
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
43
How do you view an applet?
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
44
How is an applet like a Java application?
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
45
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Executes again every time the applet becomes active after it has been inactive
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
46
Explain lossless data compression and the image formats with which it is used.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
47
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Describes the use of sound, images, graphics, and video in computer programs
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
48
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Retrieves and plays the sound as soon as possible after it is called
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
49
Briefly describe the image formats that Java supports.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
50
How is an applet different from a Java application?
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
51
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Provides a convenient environment in which to test your applets
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
52
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Surrounded by angle brackets
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
53
What are the two forms of the play() method?
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
54
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
A simple language used to create Web pages for the Internet
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
55
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
The first method called in any applet
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
56
Describe the two methods for running an applet.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
57
Describe the stop() method.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
58
What are the methods of the applet life cycle?
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
59
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
A little application
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
60
Match each term with the correct statement below.
a.current version of HTML
f.tags
b.init()
g.multimedia
c.start()
h.applet
d.HTML
i.play()
e.Applet Viewer
Extensible Hypertext Markup Language
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
61
Write the statement to retrieve and play the myTune.au sound file that will be stored in the same place as the applet.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
62
There are three attributes typically placed within the tag: code, width, and height. Describe the purpose of the three object tag attributes and their corresponding arguments.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
63
public void actionPerformed(ActionEvent e)
{
String name = answer.getText();
con.remove(greeting);
con.remove(pressMe);
con.remove(answer);
personalGreeting.setText("Hello, " + name + "! ");
con.add(personalGreeting);
con.setBackground(Color.PINK);
validate();
}
In the actionPerformed() method above, the final statement following the addition of the JLabel is validate(). Explain the validate() method and how it is used with JComponents.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
64
In order to play sounds more than once, or to stop and start sounds, the sound must be loaded into an AudioClip object. Write the statement to load the AudioClip named myClip with the sound file myTune.au, which is located in the audio folder.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
65

Using the above statement, identify the three object tag attributes and their corresponding arguments.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
66

____________________


Using the HTML code above, write the statement to run a JApplet named JHello. The applet will be 450 pixels wide by 150 pixels tall.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
67
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class JSound extends JApplet
{
AudioClip sound;
public void init()
{
sound = getAudioClip(getCodeBase(),"mysteryTune.au");
}
public void start()
{
___________________________________
}
public void stop()
{
___________________________________
}
public void paint(Graphics g)
{
super.paint(g);
Graphics2D g2D = (Graphics2D)g;
g2D.drawString("Listen to the mystery tune ", 10, 10);
}
}
In the first shaded line provided, write the loop() method to play the mysteryTune.au sound continually. On the second shaded line, write the stop() method to halt the mysteryTune.au sound file.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
68
import javax.swing.*;
import java.awt.*;
public class JHello extends JApplet
{
JLabel greeting = new JLabel("Hello. Who are you?");
public void init()
{
add(greeting);
}
}
The above code displays an applet with a JLabel added without a specified BorderLayout region. Describe how the JLabel will occupy the JApplet surface.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
69
arrowPicture.paintIcon(this, g, 150, 0);
The statement above is used to display the arrowPicture ImageIcon using the paintIcon() method. Describe the four arguments that are used in this method.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
70
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class JCompanyImage extends JApplet
{
Image companyLogo;
final int WIDTH = 287;
final int HEIGHT = 129;
final int FACTOR = 2;
public void init()
{
companyLogo = getImage(getCodeBase(), "CompanyLogo. png");
}
public void paint(Graphics g)
{
super.paint(g);
// Draw image at its natural size
___________________________________
// Draw the image scaled - twice as large
___________________________________
}
}
Using the above code, complete the first shaded line with the statement to draw the image first in its original size in the upper-left corner. In the second shaded line, write the code to redraw the image at twice its original size using the WIDTH, HEIGHT, and FACTOR values.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
71
The init() method is the first method called in any applet. Write the code for the init() method header and explain the purpose of the init() method.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
72

____________________________


In the blank line provided, write the code to run a JApplet named JGreeting that will be 370 pixels wide by 110 pixels tall.
Unlock Deck
Unlock for access to all 72 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 72 flashcards in this deck.