Review_6 AWT, Swing, ActionListener, and Graphics.
-
Upload
maryann-gardner -
Category
Documents
-
view
228 -
download
2
Transcript of Review_6 AWT, Swing, ActionListener, and Graphics.
![Page 1: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/1.jpg)
Review_6
AWT, Swing,ActionListen
er,and
Graphics
![Page 2: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/2.jpg)
What is javax.swing?
![Page 3: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/3.jpg)
If we make a JFrame, what code
do we need to make it show up?
![Page 4: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/4.jpg)
How do we put a JPanel into a
JFrame?
![Page 5: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/5.jpg)
If we do not specify a JFrame to do
EXIT_ON_CLOSE, what happens?
![Page 6: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/6.jpg)
What are JButton and JCheckbox?
![Page 7: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/7.jpg)
How do we set the color to red
in the paintComponent
method?
![Page 8: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/8.jpg)
If we set a JLabel to have a background color, what else do
we need to do to see the color?
![Page 9: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/9.jpg)
How do we change this label to write something
else?
JLabel display = new Jlabel();
![Page 10: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/10.jpg)
In Java, layouts are handled by objects called…
![Page 11: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/11.jpg)
Which layout is the best for quick GUI
design and automatically reacts
to resizing?
![Page 12: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/12.jpg)
Which layout is the best for grouping
and placing components at the center or sides of
your frame?
![Page 13: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/13.jpg)
Which layout is the best for placing all of your components
manually?
![Page 14: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/14.jpg)
Which layout is the best for
automatically placing components
into rows and columns?
![Page 15: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/15.jpg)
What is it called when we put panels with layouts inside
panels with layouts?
![Page 16: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/16.jpg)
What is ActionListener?
![Page 17: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/17.jpg)
What method does the
ActionListener interface have?
![Page 18: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/18.jpg)
Fill in the blank to use
actionlisteners:
public class MyListener ________ ActionListener
![Page 19: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/19.jpg)
What import do we need to use
ActionListeners?
![Page 20: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/20.jpg)
In the following code, what is goes in the
blank?
button.addActionListener(____);
![Page 21: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/21.jpg)
What goes in the blank?
public void actionPerformed(___) {
![Page 22: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/22.jpg)
What code do we use to figure out which button was
clicked?
![Page 23: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/23.jpg)
To paint inside of a JPanel, we first need to make a class that extends Jpanel and
overrides the....
![Page 24: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/24.jpg)
What keyword can we use to refer to the
parent class?
![Page 25: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/25.jpg)
If we want our graphics to resize
with the frame, what methods do we need?
![Page 26: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/26.jpg)
If we want to draw the outline of a circle,
what method should we use?
![Page 27: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/27.jpg)
If we want to draw a filled in rectangle
what method should we use?
![Page 28: Review_6 AWT, Swing, ActionListener, and Graphics.](https://reader036.fdocuments.in/reader036/viewer/2022062305/5697c00b1a28abf838cc8860/html5/thumbnails/28.jpg)
The drawPolygon method takes in what
three parameters?