Results 1 to 2 of 2
  1. #1
    mitra is offline Member
    Join Date
    Jun 2011
    Posts
    59
    Rep Power
    0

    Default JApplet GUI problem

    Hi everybody..........

    I need some help.

    Java Code:
    import javax.swing.JApplet;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    
    public class JAppletDemo extends JApplet {
        JPanel panel;
        JButton btn;
        
        public void init(){
            this.setLayout(new BorderLayout());
            this.setSize(200,200);
            
            panel = new JPanel();
            this.add(panel);
            panel.setBackground(Color.red);
            btn = new JButton("CLICK !");
            panel.add(btn);
            
        }
        
    }

    When I run this program through appletviewer it shows only the JApplet and JPanel within it.
    It can't show the button at first time when its loaded. But if I change the size of the window by mouse then it shows everything on it.

    I can't understand why it does?

    suggest me please.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    What HTML are you using to load the applet?
    The applet shows a red background and a button with this HTML

    XML Code:
    <applet code=JAppletDemo height=200 width=200></applet>

Similar Threads

  1. problem in setMnemonic for JMenu in JApplet
    By doron70 in forum AWT / Swing
    Replies: 2
    Last Post: 05-24-2011, 10:40 AM
  2. Problem with JApplet painting
    By Fuzzier in forum Java Applets
    Replies: 5
    Last Post: 07-29-2010, 09:54 PM
  3. JApplet display problem
    By Darrarski in forum New To Java
    Replies: 10
    Last Post: 06-05-2010, 08:02 AM
  4. JApplet Problem
    By tanmoy.b81 in forum AWT / Swing
    Replies: 2
    Last Post: 07-28-2008, 07:56 AM
  5. Another problem in JApplet :S
    By juju in forum Java Applets
    Replies: 2
    Last Post: 12-30-2007, 08:46 PM

Tags for this Thread

Posting Permissions

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