Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, February 4, 2016

java code to load and play media file

import javax.media.*;
import java.io.File;

import java.awt.*;
 
public class TrivialJMFPlayer extends Frame {

 
    public static void main (String[] args) {

        try {
            Frame f = new TrivialJMFPlayer();

            f.pack();

            f.setVisible (true);

        } catch (Exception e) {

            e.printStackTrace();

        }
    }
    public TrivialJMFPlayer() 

        throws java.io.IOException,

               java.net.MalformedURLException,
               javax.media.MediaException {

        FileDialog fd = new FileDialog

            (this, "TrivialJMFPlayer", FileDialog.LOAD);

        fd.setVisible(true);

        File f = new File(fd.getDirectory(), fd.getFile());

        Player p = Manager.createRealizedPlayer
            (f.toURI().toURL());

        Component c = p.getVisualComponent();

        add(c);
        p.start();

    }
}

Monday, December 7, 2015

Everything about java main(String[] args) method


main method is the first method which get called automatically when the program executes.
there  must be only one main in a java program which you want to execute.
in main method signature/prototype 
public
It is a access specifier which defines the scope of the method it must be public

static
makes the method  to be called with the class name as to run the program we use the class name. thats is the reason static is there in main method.

void:
void states that the main method doesnt return anything. and it must be void only.

main : it is a name of method.

(String[] args) :  here args is an array of String class and it must be string class array only.
here instead of String[] args you can use varargs i.e String... args

main method cannot be override
main method can be overloaded. 

Tuesday, November 29, 2011

NETBEANS SHORTCUTS (JSP Editor Code Templates)


JSP Editor Code Templates
ag                    application.getAttribute("|")

ap                    application.putAttribute("|",)

ar                     application.removeAttribute("|")

cfgi                  config.getInitParameter("|")

jspf                 

jspg                 

jspi                  

jspp                 

jsps                 

jspu                 

oup                  out.print("|")

oupl                 out.println("|")


pcg                  pageContext.getAttribute("|")

pcgn                pageContext.getAttributeNamesInScope("|")

pcgs                pageContext.getAttributesScope("|")

pcr                   pageContext.removeAttribute("|")

pcs                  pageContext.setAttribute("|",)

pg                    <%@page |%>

pga                  <%@page autoFlush="false"%>

pgb                  <%@page buffer="|kb"%>

pgc                  <%@page contentType="|"%>

pgerr                <%@page errorPage="|"%>

pgex                <%@page extends="|"%>

pgie                 <%@page isErrorPage="true"%>

pgim                <%@page import="|"%>

pgin                 <%@page info="|"%>

pgit                  <%@page isThreadSafe="false"%>

pgl                   <%@page language="java"%>

pgs                  <%@page session="false"%>

rg                     request.getParameter("|")

sg                    session.getAttribute("|")

sp                    session.setAttribute("|", )

sr                     session.removeAttribute("|")

tglb                  <%@taglib uri="|"%>

Enhanced by Zemanta