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 4 of 4

Thread: Extending Jframe

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Extending Jframe

    Please help me. What is wrong with this code? I took it from a tutorial and is studying the syntax but it will not run. Something seems to be wrong with line 6. Thanks

    import java.awt.FlowLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import  javax.swing.JButton;
    import  javax.swing.JFrame;
     
    public class MoreFrame extends JFrame implements ActionListener;
    {
    	private static final long serialVersionUID = 1L;
     
    		public static void main(String[] args)
    		{
     
    	new MoreFrame ().setVisible(true);
    		}
    	private MoreFrame()
    		{
    super("Tutorial =Rhoen MoreFrame");
    setSize (600,600);
    setDefaultCloseOperation (EXIT_ON_CLOSE);
    setLayout (new FlowLayout());
    JButton button = new JButton ("Click me");
    button.addActionListener(this);
    add (button);
    	}
    public void actionPerformed(ActionEvent e)
    {
    	System.out.println("Button has been clicked");
    }
    		}
    Error message

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at MoreFrame.main(MoreFrame.java:11)
    Last edited by jps; August 8th, 2013 at 01:24 AM. Reason: code tags


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Extending Jframe

    What is the compiler error? The error you listed is simply warning that there is a compiler error (you're probably using an IDE before you really should, but that's beside the point). You need to identify what that compiler error is if you want to fix it.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Extending Jframe

    Please post your code in code tags.

    There should not be a semi-colon at the end of line 7:

    public class MoreFrame extends JFrame implements ActionListener;

  4. #4
    Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Extending Jframe

    Thanks I really appreciate your quick response
    I will continue to develop the programme

Similar Threads

  1. Reg:extending a jpanel
    By mohamed_mashood in forum What's Wrong With My Code?
    Replies: 9
    Last Post: March 23rd, 2013, 05:40 AM
  2. Extending JFrame + having multiple windows.
    By RedCloudTsunami in forum AWT / Java Swing
    Replies: 7
    Last Post: August 5th, 2012, 01:24 PM
  3. Extending class
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 8
    Last Post: January 10th, 2012, 05:06 PM
  4. Extending a Servlet and sharing HttpServletRequest
    By mastervh in forum Java Servlet
    Replies: 6
    Last Post: October 12th, 2011, 03:51 AM
  5. class extending
    By Reem in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 18th, 2010, 01:49 AM