Results 1 to 2 of 2
  1. #1
    baltimore is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default JFrame vs Applet

    Is it possible to get an applet into an application frame? if so, how? Second question: What is the difference between the JButton and Button objects???

    Thanks.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Is it possible to get an applet into an application frame?
    Yes. Applet extends Panel, JApplet extends Applet.
    Java Code:
    class Pseudo extends JApplet {
        public void init() {
    
        }
    
        public static void main(String[] args) {
            JApplet applet = new Pseudo();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(applet);
            f.setSize(400,400);
            f.setLocation(200,200);
            applet.init();
            // If you override start method
            // applet.start();
            f.setVisible(true);
        }
    }
    JButton is a Swing, lightweight component.
    Button is an AWT, heavyweight component.

Similar Threads

  1. JFrame Question ?
    By Mindhunter74 in forum New To Java
    Replies: 2
    Last Post: 12-21-2007, 11:45 PM
  2. help me with JFrame and JLabel
    By michcio in forum New To Java
    Replies: 5
    Last Post: 11-20-2007, 08:44 AM
  3. JFrame question
    By Try2Live4God in forum New To Java
    Replies: 2
    Last Post: 10-15-2007, 02:52 AM
  4. Help with JFrame
    By Albert in forum AWT / Swing
    Replies: 2
    Last Post: 07-04-2007, 05:44 AM
  5. Replies: 4
    Last Post: 06-08-2007, 07:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •