CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2000
    Posts
    7

    Swinf in the html file

    I wana a browse a swing applet in the html file i use to write
    <HTML>
    <BODY>


    <Applet code=TJApplet width=200 height=100>
    </Applet>

    </BODY>
    </HTML>
    and my source code of the class is :

    //Listing 2.2 Swing Applet with a Matte Border (TJApplet.java)
    // Demonstrates the Swing applets

    /*
    * <Applet code=TJApplet width=200 height=100>
    * </Applet>;
    */

    import javax.swing.*;
    import java.awt.*;

    public class TJApplet extends JApplet {

    public void init() {
    JOptionPane.showMessageDialog(null,"text","test",2);

    // 1. Get a reference to the content pane of the applet.
    Container contentPane = getContentPane();
    // 2. Create a label with an icon and text.
    JLabel label = new JLabel("This is a Swing applet", // text
    new ImageIcon("Metal.gif"), // icon
    JLabel.CENTER); // horiz. position

    // 3. Assign a matte border by using an icon and the specified insets.
    label.setBorder(BorderFactory.createMatteBorder(
    10, // top inset
    10, // left inset
    10, // bottom inset
    10, // right inset
    new ImageIcon("border.gif"))); // border icon

    // 4. Add the label to the applet's content pane.
    contentPane.add(label);
    setVisible(true);
    }
    }

    I don't know why it's not working

    Help me please



  2. #2
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: Swinf in the html file

    You will have to use 'object' and 'embed' instead of 'Applet' tag.

    See appletviewer help in ur JDK1.2 documentation.

    - UnicMan
    http://members.tripod.com/unicman

  3. #3
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: Swing in the browser/ html file

    You don't say what the error is. I guess it's that the browser doesn't have the swing classes. If that's the case, you need to convert your HTML to use the java plugin which has the newer java classes. The Sun site has a free download of an HTMLConversion program that will do it.
    Good luck

    Norm

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured