HELP ME with frames and panels - Programmers Heaven

Howdy, Stranger!

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

Categories

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.