Why do my jbuttons not work?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Why do my jbuttons not work?

  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, 04:15 AM
  2. Revalidating my Jbuttons
    By Eric Lada in forum Java
    Replies: 1
    Last Post: 09-12-2000, 12:45 PM

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center