I am trying to offload my graphics to another class, however when I initialize that class I get:
at java.security.AccessController.getContext(Unknown Source)
at java.awt.Component.<init>(Unknown Source)
at java.awt.Canvas.<init>(Unknown Source)
at Display.<init>(Display.java:11)
at Display.<init>(Display.java:7)
I researched and found something saying that I have to have a constructor with no arguments however the constructor did not seem to solve the problem.
----This is where I initilize my display class----
import java.util.Scanner;
public class Ytube2URL
{
public static void main(String[] args) {
Display d = new Display();
d.initGraphics();
String Userurl = askUserForURL();
System.out.println(Userurl);
String Downloadurl = GetYoutubeOnlyURL(Userurl);
}
}
-------This is my Display class------
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Display extends Canvas
{
Display d = new Display();
JFrame f = new JFrame();
JOptionPane jo =new JOptionPane();
public Display()
{
}
public void initGraphics()
{
f.add(d);
f.setSize(200,600);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jo.add(f);
f.pack();
}
}
Thank you for your help and explanations.