Computers and Technology

Analyze the following code.

import java. awt.*;
import javax. swing.*;

public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame("My Frame");
frame. add(new MyDrawing("Welcome to Java!"));
frame. setSize(300, 300);
frame. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);
frame. setVisible(true);
frame. setVisible(true);
}
}

class MyDrawing extends JPanel {
String message;

public MyDrawing(String message) {
this. message = message;
}

public void paintcomponent(Graphics g) {
super. paintComponent(g);

g. drawString(message, 20 ,20);
}
}

What happens?

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 17:00, norsenorma
In addition to using the icons to adjust page margins, a user can also use
Answers: 1
image
Computers and Technology, 21.06.2019 18:30, porkhappycom
Which number on the image above correctly indicates the name of a folder in this url? a.1b.2c.3d.4
Answers: 2
image
Computers and Technology, 22.06.2019 09:30, relic7391
Is a string of code written to hurt others by damaging or destroying
Answers: 1
image
Computers and Technology, 22.06.2019 23:30, lexirandall19
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
Do you know the correct answer?
Analyze the following code.

import java. awt.*;
import javax. swing.*;

...

Questions in other subjects: