Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
HELP ME with frames and panels Posted by floriz on 11 Mar 2009 at 3:08 AM
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.
Report
Re: HELP ME with frames and panels Posted by chandrus on 11 Mar 2009 at 4:53 AM
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();
}
}




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.