友人のために NetBeans で Java アプリケーションを作成しています。コードは次のとおりです。
public class ReportGenerator extends JFrame implements ActionListener {
//GUI components
private JMenuBar menuBar;
private JMenu fileMenu;
private JMenuItem newItem;
private JMenuItem openItem;
private JMenuItem exitItem;
private ReportGeneratorSetup setup;
private ReportGeneratorProgram application;
public ReportGenerator()
{
menuBar = new JMenuBar();
fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
exitItem = new JMenuItem("Exit");
fileMenu.add(exitItem);
exitItem.addActionListener(this);
menuBar.add(fileMenu);
this.setJMenuBar(menuBar);
this.setSize(1000,1200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
setup = new ReportGeneratorSetup(this);
application = new ReportGeneratorProgram(this,setup);
//this.add(setup);
this.validate();
}
public static void main(String[] args) {
ReportGenerator rg = new ReportGenerator();
}
public void switchToPanel(String panel)
{
this.getContentPane().removeAll();
if(panel.equals("Eval"))
{
application.setupComponents();
this.getContentPane().add(application);
}
else if(panel.equals("Setup"))
{
this.getContentPane().add(setup);
}
this.invalidate();
this.validate();
}
@Override
public void actionPerformed(ActionEvent arg0)
{
if(arg0.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem)arg0.getSource();
if(item.getText().equals("Exit"))
{
dispose();
System.exit(0);
}
}
}
}
次のようなエラーが表示されます。
no suitable method found for add(reportgenerator.ReportGeneratorSetup)
method java.awt.Container.add(java.awt.Component,java.lang.Object,int) is not applicable
(actual and formal argument lists differ in length)
method java.awt.Container.add(java.awt.Component,java.lang.Object) is not applicable
(actual and formal argument lists differ in length)
method java.awt.Container.add(java.awt.Component,int) is not applicable
(actual and formal argument lists differ in length)
method java.awt.Container.add(java.lang.String,java.awt.Component) is not applicable
(actual and formal argument lists differ in length)
method java.awt.Container.add(java.awt.Component) is not applicable
(actual argument reportgenerator.ReportGeneratorSetup cannot be converted to java.awt.Component by method invocation conversion)
method java.awt.Component.add(java.awt.PopupMenu) is not applicable
(actual argument reportgenerator.ReportGeneratorSetup cannot be converted to java.awt.PopupMenu by method invocation conversion)
なぜこれが起こっているのか誰にも教えてもらえますか? それは大歓迎です。