Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use applet with portlet in liferay?

    • 0
    • 1
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 780
    Comment on it

    Hello Guys
    Below code will help you to build java applet in liferay portlet.

    Write below code in view.jsp :

    <applet name="Demo" id="Demo" code="com.AppletDemo" codebase='<%= themeDisplay.getCDNBaseURL()+"/PortletName" %>' width="450"  height="300">
        <param name="jnlp_href" value="AppletDemo.jnlp" />
         <param name="separate_jvm" value="true" />
    </applet>
    

    Create JNLP file for define jar file:

    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+" codebase="" href="AppletDemo.jnlp">
    
    <information>
        <title>AppletDemo</title>
        <vendor>Findnerd</vendor>
        <homepage href="http://www.Findnerd.com"/>
        <description>AppletDemo</description>
        <description kind="short">AppletDemo</description>
        <offline-allowed/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <update check="timeout" policy="prompt-update"/>
        <resources>
            <j2se version="1.6+"/>
            <jar href="AppletDemo.jar" main="true"/>
            <jar href="Other-jar-files.jar"/>
        </resources>
        <applet-desc
            name="Demo"
            documentbase="view.jsp"
            main-class="com.AppletDemo.class"
            width="400"
            height="450">
        </applet-desc>
    </jnlp>
    

    Now write applet in AppletDemo.java

    package com;
    
    import javax.swing.JApplet;
    import javax.swing.JLabel;
    import java.awt.Font;
    
    public class AppletDemo extends JApplet {
    
        /**
         * Create the applet.
         */
        public AppletDemo() {
            getContentPane().setLayout(null);
    
            JLabel lblNewLabel = new JLabel("Hello Bhagwan");
            lblNewLabel.setFont(new Font("SansSerif", Font.PLAIN, 18));
            lblNewLabel.setBounds(114, 78, 130, 51);
            getContentPane().add(lblNewLabel);
    
        }
    }
    

    Thank you.

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: