Here is the original code that created this window.
public class Driver00Graffiti {
public static void main(String[] args) {
JFrame frame = new JFrame("Graffiti lab");
frame.setSize(400, 300);
frame.setLocation(100, 50);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new Panel00Graffiti());
frame.setVisible(true);
}
} |
public class Panel00Graffiti extends JPanel { public void paintComponent(Graphics g){ g.setColor(Color.RED); g.fillRect(10,10,100,50); g.setColor(Color.YELLOW); g.drawString("window",20,30); } } |
Match these changes to the windows that result. (NOTE: some changes are in the driver and some are in the panel. Can you tell which is which?) Describe what changed for each line of code
New code | How does the output change? | Original window |
frame.setSize(100,300) | ||
g.fillRect(10,10,400,50); | ||
frame.setSize(400, 100); | ||
g.fillRect(100,10,100,50); | ||
g.fillRect(10,100,100,50); | ||
g.fillRect(10,10,50,100); | ||
g.drawString("window",100,30); |
Describe what this program does
Making Colors: Fill in the missing colors:
rgb code | actual color |
rgb(0, 0, 255) | |
rgb(0, 0, 0) | |
green | |
white | |
rgb(255, 0, 255) | |
yellow |