Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!