I'm beginner of java and I study about JFrame now but I have an issue. I made a constructor with parameters of JPanel but when I invoke it with arguments, an error is happened. Could you help me to find any solutions??
import javax.swing.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.*;
public class JFlexiblePanel extends JFrame{
private Color col1;
private Color col2;
private Font font1;
private String str;
private JPanel panel1;
private JLabel label1;
public JFlexiblePanel(Color col1, Color col2, Font font1, String str) {
this.col1 = col1;
this.col2 = col2;
this.font1 = font1;
this.str = str;
panel1.setBackground(this.col1);
panel1.setForeground(this.col2);
label1.setFont(this.font1);
label1.setText(this.str);
panel1.add(label1);
}
}
In different class to invoke this constructor
JFlexiblePanel p1 = new JFlexiblePanel(Color.BLUE, Color.RED, new Font("Arial",Font.BOLD,12), "America");