Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: file won't compile

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default file won't compile


    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;


    public class ClickMe extends JFrame implements ActionListener
    {


    public static void main(String[] args)
    {
    new ClickMe();
    }

    private JButton button1;

    public ClickMe()
    {
    this.setSize(200,100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
    this.setTitle("I'm Listening!");

    JPanel panel1=new JPanel();
    button1 = new JButton("Click Me!");
    button1.addActionListener(this);
    panel1.add(button1);
    this.add(panel1);

    this.setVisible(true);
    }

    private int clickCount = 0;

    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource() == button1)
    {
    clickCount++;
    if(clickCount == 1)
    button1.setText("I'v been Clicked!");
    else
    button1.setText("I'v been Clicked!" + clickCount + " times!");
    }
    }

    }

    I'm new to java programming. This small program should compile but it doesn't
    I'm using jdk1.7.0 version of java on a 64 bit machine. when i try to compile it I get "class, interface or enum expected" error
    the attached file is a screen shot of the dos window i tried to compile in
    I would appreciate any help anyone could give me in getting this program to work-bclark
    Attached Files Attached Files


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    42
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: file won't compile

    The above code compiled successfully.
    The error in your screenshot shows line number 69, but the above code has only 46 lines total. So I think you did not post the right code.

    java exception
    Last edited by hns1984; January 11th, 2012 at 06:57 PM.

Similar Threads

  1. How to compile OSGI bundle as EAR file in Netbeans
    By rcbandit in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: October 26th, 2011, 02:53 AM
  2. Can't compile .java file in JDeveloper due to missing files
    By javanewbie2 in forum Java Theory & Questions
    Replies: 4
    Last Post: July 7th, 2011, 11:22 AM
  3. File.listFiles(FileFilter) won't compile
    By GrantMRobinson in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 28th, 2011, 05:32 AM
  4. [SOLVED] I CANT COMPILE
    By savvas in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 31st, 2011, 12:34 PM
  5. need help to compile
    By hardwarewizard in forum Java Theory & Questions
    Replies: 0
    Last Post: February 14th, 2010, 10:03 AM