Deck 16: Graphics
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/74
Play
Full screen (f)
Deck 16: Graphics
1
You can instruct a Graphics object to use a font by inserting the font as the argument in a ____ method.
A) setColor()
B) drawString()
C) setCharacters()
D) setFont()
A) setColor()
B) drawString()
C) setCharacters()
D) setFont()
D
2
If you call getGraphics() in a frame that is not visible, you receive a(n) ____.
A) ForceQuit
B) ExecuteException
C) NonExecute
D) NullPointerException
A) ForceQuit
B) ExecuteException
C) NonExecute
D) NullPointerException
D
3
The drawRoundRect() method requires ____ arguments.
A) three
B) four
C) six
D) eight
A) three
B) four
C) six
D) eight
C
4
The ____ method allows you to draw a String in a JFrame window.
A) drawString()
B) setFont()
C) drawLine()
D) setString()
A) drawString()
B) setFont()
C) drawLine()
D) setString()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
5
The first step in drawing a 2D object is to specify how a drawn object is rendered.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
6
The statements pen.drawLine(50, 50, 100, 200); and pen.drawLine(100, 200, 50, 50); will both draw straight lines that slant down and to the right.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
7
If a window is 100 pixels by 100 pixels, the statement goButton.setLocation(100, 100); would place the JButton component outside the window where it would be unseen.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
8
When using the drawRoundRect() method, if you assign ____ to the arc coordinates, the rectangle is not rounded; instead, the corners are square.
A) -1
B) 0
C) 10
D) 99
A) -1
B) 0
C) 10
D) 99
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
9
If a window is 200 pixels wide by 100 pixels tall, you can place a Button named pressMe in the approximate center of the window with which of the following statements?
A) pressMe.setLocation(100,50);
B) pressMe.setPosition(100,50);
C) pressMe.setLocation(200,100);
D) pressMe.setPosition(200,100);
A) pressMe.setLocation(100,50);
B) pressMe.setPosition(100,50);
C) pressMe.setLocation(200,100);
D) pressMe.setPosition(200,100);
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
10
The Color class contains ____ constants.
A) 3
B) 9
C) 13
D) 16
A) 3
B) 9
C) 13
D) 16
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
11
The ____ method requires four arguments and draws the outline of a rectangle using the current drawing color.
A) clearRect()
B) drawRect()
C) fillRect()
D) paintRect()
A) clearRect()
B) drawRect()
C) fillRect()
D) paintRect()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
12
You can designate a Graphics color by calling the drawString() method.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
13
A Rectangle2D.Float can be created using five arguments representing the x-coordinate, y-coordinate, width, height, and position.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
14
Both Rectangle2D.Float and Rectangle2D.Double can be created using four arguments representing the x-coordinate, y-coordinate, width, and height.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
15
The ____ method draws what appears to be an empty rectangle.
A) clearRect()
B) emptyRect()
C) fillRect()
D) drawRect()
A) clearRect()
B) emptyRect()
C) fillRect()
D) drawRect()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
16
A rectangle created with the clearRect() method is not transparent.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
17
The repaint() method calls another method named ____, which calls the paint() method.
A) destroy()
B) actionPerformed()
C) update()
D) super()
A) destroy()
B) actionPerformed()
C) update()
D) super()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
18
The init() method of GeneralPath is used to create the beginning point of the polygon.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
19
Dimension(Dimension d) creates an instance of Dimension with a width of 0 and a height of 0.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
20
The FontMetrics class methods return an integer value representing the font size in points, with one point measuring 1/72 of an inch.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following statements starts a polygon named pol at the coordinates 20 and 290?
A) pol.moveTo(20F, 290F);
B) pol.lineTo(20F, 290F);
C) pol = new Path(20F, 290F);
D) pol.newPath(20F, 290F);
A) pol.moveTo(20F, 290F);
B) pol.lineTo(20F, 290F);
C) pol = new Path(20F, 290F);
D) pol.newPath(20F, 290F);
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
22
The draw3DRect() method has a ____ argument, which controls whether the rectangle is darker on the right and bottom, or lighter on the right and bottom.
A) cyclic gradient
B) fill pattern
C) null
D) Boolean value
A) cyclic gradient
B) fill pattern
C) null
D) Boolean value
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
23
The position of a component can be changed by using the ____ method and passing it x- and y-coordinate positions.
A) drawString()
B) setLocation()
C) fillArc()
D) repaint()
A) drawString()
B) setLocation()
C) fillArc()
D) repaint()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
24
You can use the ____ method to copy any rectangular area to a new location.
A) copyRect()
B) copyArea()
C) copyGraphics()
D) addPoint()
A) copyRect()
B) copyArea()
C) copyGraphics()
D) addPoint()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
25
You can discover the fonts that are available on your system by using the ____ method.
A) searchFonts()
B) findFonts()
C) findAllFonts()
D) getAvailableFontFamilyNames()
A) searchFonts()
B) findFonts()
C) findAllFonts()
D) getAvailableFontFamilyNames()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
26
The ____________________ method returns an object of type Dimension, which specifies the width and height of the screen in pixels.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
27
Which statement sets the font of a Graphics object named brush to boldFont?
A) Font.setFont = brush
B) setFont = brush(boldFont)
C) brush.setFont(boldFont)
D) Font = setFont(boldFont)
A) Font.setFont = brush
B) setFont = brush(boldFont)
C) brush.setFont(boldFont)
D) Font = setFont(boldFont)
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
28
____ is the amount of space between the bottom of the descent of one line and the top of the characters in the successive line of type.
A) Descent
B) Ascent
C) Leading
D) Height of a line
A) Descent
B) Ascent
C) Leading
D) Height of a line
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
29
The ____ method creates a solid arc.
A) solidArc()
B) fillArc()
C) clearArc()
D) drawArc()
A) solidArc()
B) fillArc()
C) clearArc()
D) drawArc()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following statements will correctly add a point to a polygon named myShape?
A) myShape.addPoint(50, 100)
B) addPoint = myShape(50, 100)
C) myShape.fillPolygon(50 100)
D) myShape = addPoint(50, 100)
A) myShape.addPoint(50, 100)
B) addPoint = myShape(50, 100)
C) myShape.fillPolygon(50 100)
D) myShape = addPoint(50, 100)
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
31
You can improve the appearance of strings drawn using Graphics objects by using the ____________________ method.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
32
If the beginning and ending points used with the fillPolygon() method are ____, the two endpoints are connected by a straight line before the polygon is filled with color.
A) connected
B) coordinate pairs
C) identical
D) not identical
A) connected
B) coordinate pairs
C) identical
D) not identical
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
33
You can instantiate an empty Polygon object using which of the following statements?
A) Polygon someFutureShape = new Polygon(0,0,0,0);
B) Polygon someFutureShape = new Polygon();
C) Polygon someFutureShape = new Polygon(0);
D) Polygon someFutureShape = new Polygon(xPoints, yPoints, xPoints.length);
A) Polygon someFutureShape = new Polygon(0,0,0,0);
B) Polygon someFutureShape = new Polygon();
C) Polygon someFutureShape = new Polygon(0);
D) Polygon someFutureShape = new Polygon(xPoints, yPoints, xPoints.length);
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
34
To create an arc object named halfArc that looks like the top half of a circle, you could use the ____ statement to produce identical results to the following statement: halfArc.drawArc(x, y, w, h, 0, 180);.
A) halfArc.drawArc(x, y, w, h, 180, 0);
B) halfArc.drawArc(x, y, w, h, 180, -180);
C) halfArc.drawArc(x, y, w, h, -180, 180);
D) fillArc.drawArc(x, y, w, h, 180, -180);
A) halfArc.drawArc(x, y, w, h, 180, 0);
B) halfArc.drawArc(x, y, w, h, 180, -180);
C) halfArc.drawArc(x, y, w, h, -180, 180);
D) fillArc.drawArc(x, y, w, h, 180, -180);
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
35
BasicStroke class variables determine the endcap and ____ style arguments.
A) stroke
B) line
C) juncture
D) fill
A) stroke
B) line
C) juncture
D) fill
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
36
You specify 2D colors by using the ____ method.
A) paint()
B) setPaint()
C) color()
D) setColor()
A) paint()
B) setPaint()
C) color()
D) setColor()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
37
The ____________________ method can be used when a window needs to be updated, such as when it contains new images or you have moved a new object onto the screen.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
38
You use the ____________________ method in statements to add points to a polygon.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
39
You use the ____________________ method to draw a rectangle that appears to have "shadowing" on two of its edges-the effect is that of a rectangle that is lit from the upper-left corner and slightly raised or slightly lowered.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
40
The ____ method provides information about the system in use.
A) getSystemInfo()
B) getDefaultToolkit()
C) getDefaultControlPanel()
D) getToolkit()
A) getSystemInfo()
B) getDefaultToolkit()
C) getDefaultControlPanel()
D) getToolkit()
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
41
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Returns the number of pixels as an integer
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Returns the number of pixels as an integer
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
42
Describe what happens when the update() method is called.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
43
Why would a programmer use the repaint() method?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
44
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Used to create lines
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Used to create lines
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
45
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Draws a solid shape
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Draws a solid shape
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
46
What are the three arguments the BasicStroke constructor takes?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
47
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Does not cycle between the colors
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Does not cycle between the colors
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
48
What are the constructors for the Dimension class?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
49
What activities does the process of drawing with Java 2D objects include?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
50
How can a programmer find and gather all the available fonts on a computer system?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
51
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Works best with lighter drawing colors
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Works best with lighter drawing colors
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
52
How do you use the drawOval() method to draw an oval?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
53
What parameters does the copyArea() method require?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
54
To create a rectangle with rounded corners, the drawRoundRect() method is used. Describe the six arguments that are required to create rounded rectangles.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
55
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Controls how a drawing object is filled in
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Controls how a drawing object is filled in
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
56
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Used to create polygons
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Used to create polygons
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
57
List the six arguments you need to provide for the drawArc() method.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
58
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Measures the parts of characters that "hang below" the baseline
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
Measures the parts of characters that "hang below" the baseline
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
59
Match each term with the correct statement below.
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
A Color class constant
a.fill pattern
f.fillPolygon()
b.GREEN
g.getScreenResolution()
c.acyclic gradient
h.GeneralPath
d.3D method
i.descent
e.Line2D.Float class
A Color class constant
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
60
In the drawPolygon() method, what are the three arguments and what values do they represent?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
61
The getFontMetrics() method can be used to discover a font's statistics. Describe the getLeading(), getAscent(), getDescent(), and getHeight() methods, and how they are used with the getFontMetrics() method.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
62
A rectangle is drawn with the following statement:
tool.drawRect(50, 50, 100, 60);
An oval is drawn with the following statement:
tool.drawOval(50, 50, 100, 60);
Describe the resulting output, and describe how the four arguments are used to draw the objects.
tool.drawRect(50, 50, 100, 60);
An oval is drawn with the following statement:
tool.drawOval(50, 50, 100, 60);
Describe the resulting output, and describe how the four arguments are used to draw the objects.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
63
A Polygon object is created by defining movements from one point to another. Describe the statements that are used to create a Polygon object.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
64
Write the statement to instruct a Graphics object named myGraphic to apply blue paint.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
65
import javax.swing.*;
import java.awt.*;
import java.awt.Color;
public class JDemoRectangles extends JFrame
{
Container con = getContentPane();
public JDemoRectangles()
{
con.setBackground(Color.BLUE);
con.setLayout(new FlowLayout());
}
public void paint(Graphics gr)
{
super.paint(gr);
gr.setColor(Color.RED);
gr.fillRect(40, 40, 120, 120);
gr.setColor(Color.YELLOW);
gr.fillRect(80, 80, 160, 160);
gr.clearRect(50, 60, 50, 50);
}
public static void main(String[] args)
{
JDemoRectangles frame = new JDemoRectangles();
frame.setSize(200, 200);
frame.setVisible(true);
}
}
Using the above code, describe what objects are drawn using the shaded statements of the paint() method.
import java.awt.*;
import java.awt.Color;
public class JDemoRectangles extends JFrame
{
Container con = getContentPane();
public JDemoRectangles()
{
con.setBackground(Color.BLUE);
con.setLayout(new FlowLayout());
}
public void paint(Graphics gr)
{
super.paint(gr);
gr.setColor(Color.RED);
gr.fillRect(40, 40, 120, 120);
gr.setColor(Color.YELLOW);
gr.fillRect(80, 80, 160, 160);
gr.clearRect(50, 60, 50, 50);
}
public static void main(String[] args)
{
JDemoRectangles frame = new JDemoRectangles();
frame.setSize(200, 200);
frame.setVisible(true);
}
}
Using the above code, describe what objects are drawn using the shaded statements of the paint() method.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
66
BasicStroke myLine = new BasicStroke(12.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND);
The above statement creates a BasicStroke object and makes it the current stroke. Describe the three arguments that are used in this statement, and then describe the purpose of each.
The above statement creates a BasicStroke object and makes it the current stroke. Describe the three arguments that are used in this statement, and then describe the purpose of each.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
67
Write the statement to create an Arc2D.Float object named myArc at 20, 143, with a width of 50 and a height of 43; with a starting degree of 50, 140 degrees traveled; and using the class variable Arc2D.PIE.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
68
import javax.swing.*;
import java.awt.*;
public class JDemoFont extends JFrame
{
Font bigFont = new Font("Serif", Font.ITALIC, 48);
String hello = "Hello";
public void paint(Graphics brush)
{
super.paint(brush);
brush.setFont(bigFont);
brush.drawString(hello, 10, 100);
}
public static void main(String[] args)
{
JDemoFont frame = new JDemoFont();
frame.setSize(180, 150);
frame.setVisible(true);
}
}
The above code shows an application that uses the setFont() method with a Graphics object named brush. Describe what will occur when the two shaded lines of code are executed.
import java.awt.*;
public class JDemoFont extends JFrame
{
Font bigFont = new Font("Serif", Font.ITALIC, 48);
String hello = "Hello";
public void paint(Graphics brush)
{
super.paint(brush);
brush.setFont(bigFont);
brush.drawString(hello, 10, 100);
}
public static void main(String[] args)
{
JDemoFont frame = new JDemoFont();
frame.setSize(180, 150);
frame.setVisible(true);
}
}
The above code shows an application that uses the setFont() method with a Graphics object named brush. Describe what will occur when the two shaded lines of code are executed.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
69
The draw3DRect() method is used to draw rectangles that appear to have "shadowing" on two of their edges. Five arguments are used to create shadowed rectangles. Describe the five arguments.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
70
Write the statement to position a JLabel object named myLabel at the upper-left corner of a JFrame.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
71
Write the statement to set the font of a Graphics object named myStyle to the font fancyFont.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
72
Write the statement to create a Rectangle2D.Float object named myRect at 20, 20 with a width of 80 and height of 50.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
73
import javax.swing.*;
import java.awt.*;
import java.awt.Color;
public class JDemo3DRectangles extends JFrame
{
public void paint(Graphics gr)
{
super.paint(gr);
final int WIDTH = 60, HEIGHT = 80;
gr.setColor(Color.PINK);
gr.fill3DRect(20, 40, WIDTH, HEIGHT, true);
gr.fill3DRect(100, 40, WIDTH, HEIGHT, false);
}
public static void main(String[] args)
{
JDemo3DRectangles frame = new JDemo3DRectangles();
frame.setSize(180, 150);
frame.setVisible(true);
}
}
The highlighted code above creates two filled 3D rectangles. Describe how the color of the rectangles is set, and explain the five arguments that are used to draw the rectangles.
import java.awt.*;
import java.awt.Color;
public class JDemo3DRectangles extends JFrame
{
public void paint(Graphics gr)
{
super.paint(gr);
final int WIDTH = 60, HEIGHT = 80;
gr.setColor(Color.PINK);
gr.fill3DRect(20, 40, WIDTH, HEIGHT, true);
gr.fill3DRect(100, 40, WIDTH, HEIGHT, false);
}
public static void main(String[] args)
{
JDemo3DRectangles frame = new JDemo3DRectangles();
frame.setSize(180, 150);
frame.setVisible(true);
}
}
The highlighted code above creates two filled 3D rectangles. Describe how the color of the rectangles is set, and explain the five arguments that are used to draw the rectangles.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
74
Write the statement to draw a rectangle that begins at position 30, 100 and is 150 pixels wide by 40 pixels tall.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck