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: jbutton on applet

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

    Question jbutton on applet

    i have compile it but unable to run it using applet viewer ,,,it says lot of error !


    HTML Code:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
     
    public class ButtonAction  implement ActionListener  {
     
        private static void createAndShowGUI()  {
     
            JFrame frame1 = new JFrame("JAVA");
            frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
            JButton button = new JButton(" >> JavaProgrammingForums.com <<");
            //Add action listener to button
            button.addActionListener(new ActionListener() {
     
                public void actionPerformed(ActionEvent e)
                {
                    //Execute when button is pressed
                    System.out.println("You clicked the button");
                }
            });      
     
            frame1.getContentPane().add(button);
            frame1.pack();
            frame1.setVisible(true);
        }
     
     
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
                }
            });
        }
    }


  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: jbutton on applet

    What errors are you seeing? Without knowing what your errors are, we can't really help you.

    I see no code here that shows you're using an applet. This is an application.
    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!

Similar Threads

  1. Help with jButton
    By ls7897 in forum AWT / Java Swing
    Replies: 6
    Last Post: March 13th, 2011, 03:22 PM
  2. JButton with 2D Graphics help
    By mystikaljester in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 13th, 2010, 09:33 PM
  3. JButton help
    By tabutcher in forum Java Applets
    Replies: 4
    Last Post: March 9th, 2010, 07:04 PM
  4. JButton Help
    By ravjot28 in forum AWT / Java Swing
    Replies: 3
    Last Post: January 17th, 2010, 11:38 AM
  5. JButton...
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 27th, 2009, 11:39 AM