I am trying to create a very simple java GUI application in Eclipse. I have created a class that extends JFrame and I am able to open the blank JFrame without any issues. When I try to add a JButton to the JFrame I get the error: The method add(Component) in the type Container is not applicable for the arguments (JButton). I have been reading examples of how to do this for hours now and every example looks like what I have already done so why doesn't it work. My code is shown below.
public class MainForm extends JFrame
{
private static final long serialVersionUID = 1L;
public MainForm ()
{
super(" Encryption Suite");
setLayout(new FlowLayout());
setResizable(false);
setSize(500, 200);
//Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
//setLocation((dim.width - 500)/2, (dim.height-200)/2);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
JButton btnRandomKeygen = new JButton("Random Keygen");
//JButton btnEnDeCrypt = new JButton("Encrypt/Decrypt");
//JButton btnChecksum = new JButton("MD5 Checksum");
//JButton btnFileCompare = new JButton("File Compare");
//JButton btnCryptanalysis = new JButton("Cryptanalysis");
//JRadioButton rdBtnSub = new JRadioButton("Substitution");
//JRadioButton rdBtnOnTmPd = new JRadioButton("One-Time Pad");
add(btnRandomKeygen);
}
}
public class EncryptionSuite
{
public static void main(String[] args)
{
final MainForm mainForm = new MainForm();
mainForm.setVisible(true);
}
}