Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import javax.swing. * ; public class Application { public static void main ( String [ ] args ) { JFrame frame = new Frame (

import javax.swing.*;
public class Application{
public static void main(String[] args){
JFrame frame = new Frame("Swing App");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,350);
IComponent Component = new ComponentImpl();
GUIBooster adapter = new GUIBooster(Component);
frame.getContentPane().add(adapter);
frame.setVisible(true);
}
}
public class ComponentImpl implements IComponent{
@Override
public void draw(){
System.out.println("Component is drawn");
}
}
import javax.swing.*;
public class GUIBooster extends JPanel{
private final IComponent Component;
public GUIBooster(IComponent Component){
this.Component = Component;
}
@Override
protected void paintComponent(java.awt.Graphics g){
super.paintComponent(g);
Component.draw();
}
}
public interface IComponent{
void draw();
}
Which design pattern is used?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

3. What is a Duchenne smile?

Answered: 1 week ago

Question

Group Size and Communication

Answered: 1 week ago

Question

Understanding Group Roles

Answered: 1 week ago