Mastering Java 2026 – 400 Free Practice Questions to Pass the 'Thinking in Java' Exam

Question: 1 / 510

Which method in SWT is analogous to Swing's paintComponent(Graphics g)?

public void paintControl(PaintEvent e)

The SWT method that is analogous to Swing's paintComponent(Graphics g) is public void paintControl(PaintEvent e). This method is used to paint or redraw graphics onto a canvas or a control using the PaintEvent object, which contains information about the area to be painted. Option B, protected void onPaint(Event e), is incorrect because it is a method used in Windows Forms applications, not in SWT. Option C, void draw(Graphics g), is incorrect because it is a method in the AWT graphics library, not in SWT. Option D, protected void render(GraphicsContext gc), is incorrect because it is a method in the JavaFX graphics library, not in SWT. Therefore, the correct answer is A.

Get further explanation with Examzify DeepDiveBeta

protected void onPaint(Event e)

void draw(Graphics g)

protected void render(GraphicsContext gc)

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy