Simple graphics with AWT and Swing Flashcards
What is the purpose of the JFrame class in Java Swing?
a) To create a panel for drawing graphics
b) To create a window for displaying GUI components
c) To manage database connections
d) To handle HTTP requests
b) To create a window for displaying GUI components
What is the purpose of the JPanel class in Java Swing?
a) To create a window for displaying GUI components
b) To create a panel for drawing graphics and adding components
c) To manage database connections
d) To handle HTTP requests
b) To create a panel for drawing graphics and adding components
What is the purpose of the paintComponent method in Java Swing?
a) To create a new window
b) To define the layout of components
c) To draw graphics on a panel
d) To manage database connections
c) To draw graphics on a panel
What is the purpose of the Graphics2D class in Java AWT?
a) To create a new window
b) To provide advanced drawing capabilities
c) To manage database connections
d) To handle HTTP requests
b) To provide advanced drawing capabilities
What is the purpose of the setColor method in Java AWT?
a) To create a new window
b) To set the background color of a panel
c) To set the color for drawing operations
d) To manage database connections
c) To set the color for drawing operations
What is the purpose of the drawLine method in Java AWT?
a) To create a new window
b) To draw a line between two points
c) To manage database connections
d) To handle HTTP requests
b) To draw a line between two points
What is the purpose of the drawRect method in Java AWT?
a) To create a new window
b) To draw the outline of a rectangle
c) To manage database connections
d) To handle HTTP requests
b) To draw the outline of a rectangle
What is the purpose of the fillRect method in Java AWT?
a) To create a new window
b) To draw a filled rectangle
c) To manage database connections
d) To handle HTTP requests
b) To draw a filled rectangle
What is the purpose of the drawOval method in Java AWT?
a) To create a new window
b) To draw the outline of an oval
c) To manage database connections
d) To handle HTTP requests
b) To draw the outline of an oval
What is the purpose of the fillOval method in Java AWT?
a) To create a new window
b) To draw a filled oval
c) To manage database connections
d) To handle HTTP requests
b) To draw a filled oval
What is the purpose of the drawImage method in Java AWT?
a) To create a new window
b) To draw an image on a panel
c) To manage database connections
d) To handle HTTP requests
b) To draw an image on a panel
What is the purpose of the BufferedImage class in Java AWT?
a) To create a new window
b) To store and manipulate image data
c) To manage database connections
d) To handle HTTP requests
b) To store and manipulate image data
What is the purpose of the ImageIO class in Java?
a) To create a new window
b) To read and write image files
c) To manage database connections
d) To handle HTTP requests
b) To read and write image files
What is the purpose of the setPreferredSize method in Java Swing?
a) To create a new window
b) To set the preferred size of a component
c) To manage database connections
d) To handle HTTP requests
b) To set the preferred size of a component
What is the purpose of the setBackground method in Java Swing?
a) To create a new window
b) To set the background color of a component
c) To manage database connections
d) To handle HTTP requests
b) To set the background color of a component
What is the purpose of the setFocusable method in Java Swing?
a) To create a new window
b) To allow a component to receive focus
c) To manage database connections
d) To handle HTTP requests
b) To allow a component to receive focus
What is the purpose of the pack method in Java Swing?
a) To create a new window
b) To resize the window to fit its contents
c) To manage database connections
d) To handle HTTP requests
b) To resize the window to fit its contents
What is the purpose of the setVisible method in Java Swing?
a) To create a new window
b) To make a window visible or invisible
c) To manage database connections
d) To handle HTTP requests
b) To make a window visible or invisible
What is the purpose of the Color class in Java AWT?
a) To create a new window
b) To define and manipulate colors
c) To manage database connections
d) To handle HTTP requests
b) To define and manipulate colors
What is the purpose of the new Color(int r, int g, int b) constructor in Java AWT?
a) To create a new window
b) To define a custom color using RGB values
c) To manage database connections
d) To handle HTTP requests
b) To define a custom color using RGB values