DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Posts
    5

    Why do my jbuttons not work?

    Hey eveyone. Im taking an intro to programming class in school and tried practicing at home. Only problem ive had is that my jbuttons dont work. Everytime i try to add text to them, it get an error compiling.. the error is

    "cannot find symbol - constructor JButton(java.lang.String)"

    heres my code.. thanks

    Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    
    public class JButton extends JApplet implements ActionListener
    {
        Container c;
        JButton button;
        
        public void init()
        {
            c = getContentPane();
            c.setLayout(new FlowLayout());
            
            button = new JButton("hey");
            c.add(button);
        }
        
        public void actionPerformed(ActionEvent e)
        {
            
        }
    }

  2. #2
    Join Date
    Dec 2005
    Location
    Arrr
    Posts
    32
    Name your class something other than JButton.

    For example,
    public class JButtonExample extends JApplet implements ActionListener

    and so on.

    The compiler is trying to use your JButton class instead of the one in javax.swing.

Similar Threads

  1. Data Entry Work
    By Anjana Jonathan in forum Careers
    Replies: 5
    Last Post: 07-03-2006, 03:15 AM
  2. Revalidating my Jbuttons
    By Eric Lada in forum Java
    Replies: 1
    Last Post: 09-12-2000, 11:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links