Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

HELP ME with frames and panels

florizfloriz Posts: 1Member
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import java.io.*;

public class fc extends JFrame
implements ActionListener

{
private JButton bFlo;
private JPanel buttonPanel;
private Container c;
private Font f;
private String a;
private int a1;



public fc()
{
super ("FColina");
setup();
setSize(500,500);
setLocation(250,250);
show();

}

public void setup()
{
c=getContentPane();
setUpButtons();
setUpActionListener();

}

public void setUpButtons()

{
buttonPanel=new JPanel();
c.add(buttonPanel,BorderLayout.CENTER);
bFlo=new JButton("BUTTON");

buttonPanel.add(bFlo);
buttonPanel.setLayout(new GridLayout(5,3,5,5));
}

public void setUpActionListener()
{
bFlo.addActionListener(this);
}

public void actionPerformed(ActionEvent c)
{

if(c.getSource()==bFlo)
{
JOptionPane.showMessageDialog(null,"Hello");
}
}
}




My programs doesn;t work. when i compile it i only says
"Exception in thread "main" java.lang.NoSuchMethodError: main

can anyone help me to fix this error please? i realy need it today.

Comments

  • chandruschandrus Posts: 2Member
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JOptionPane;
    import java.io.*;

    class fc extends JFrame
    implements ActionListener

    {
    private JButton bFlo;
    private JPanel buttonPanel;
    private Container c;
    private Font f;
    private String a;
    private int a1;



    public fc()
    {
    super ("FColina");
    setup();
    setSize(500,500);
    setLocation(250,250);
    show();

    }

    public void setup()
    {
    c=getContentPane();
    setUpButtons();
    setUpActionListener();

    }

    public void setUpButtons()

    {
    buttonPanel=new JPanel();
    c.add(buttonPanel,BorderLayout.CENTER);
    bFlo=new JButton("BUTTON");

    buttonPanel.add(bFlo);
    buttonPanel.setLayout(new GridLayout(5,3));
    }

    public void setUpActionListener()
    {
    bFlo.addActionListener(this);
    }

    public void actionPerformed(ActionEvent c)
    {

    if(c.getSource()==bFlo)
    {
    JOptionPane.showMessageDialog(null,"Hello");
    }
    }
    public static void main(String args[])
    {
    fc f=new fc();
    }
    }

Sign In or Register to comment.