how to run a applet from browser

how to run a applet from browser

hi,

iam sending the code of an applet. it is working in cmd prompt,but not working from browser.

<APPLET CODE="SPlotfinal.class" codebase="/applets" archive="jfreechart-1.0.13.jar , jcommon-1.0.8.jar ,mysql-connector-java-5.0.8-bin.jar">
</APPLET>

iam getting error. plz suggest me the related code to execute from browser.

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Shape;
import java.util.*;
import javax.swing.JPanel;
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.util.ShapeUtilities;
import java.sql.*;

public class SPlotfinal extends ApplicationFrame {

    public SPlotfinal(String s) {
        super(s);
        JPanel jpanel = createDemoPanel();
        jpanel.setPreferredSize(new Dimension(640, 480));
        add(jpanel);
    }
     public static JPanel createDemoPanel() {
        JFreeChart jfreechart = ChartFactory.createScatterPlot(
            "Dot Plot ", "X", "Y", samplexydataset2(),
            PlotOrientation.VERTICAL, true, true, false);
        Shape cross = ShapeUtilities.createDiagonalCross(3, 1);
        XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
        xyPlot.setDomainCrosshairVisible(true);
        xyPlot.setRangeCrosshairVisible(true);
        XYItemRenderer renderer = xyPlot.getRenderer();
        renderer.setSeriesShape(0, cross);
        renderer.setSeriesPaint(0, Color.red);
        return new ChartPanel(jfreechart);
    }

    private static XYDataset samplexydataset2() {
        int cols = 20;
        int rows = 20;
        double[][] values = new double[cols][rows];
        XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
        XYSeries series = new XYSeries("GRAPH");
        Random rand = new Random();

    try
{

String connectionURL = "jdbc:mysql://localhost:3306/mysql";
Connection con;
Class.forName("com.mysql.jdbc.Driver");
// Get a Connection to the database
con = DriverManager.getConnection(connectionURL, "root", "root"); 
//Add the data into the database
String sql = "SELECT COUNT(*) FROM GRAPH";
Statement stm = con.createStatement();
stm.executeQuery(sql);
ResultSet rs= stm.getResultSet();

while (rs.next ()){

 int count=rs.getInt(1);
 System.out.println(count);
 String sql1 = "SELECT XAXIS,YAXIS FROM GRAPH";
 Statement stm1 = con.createStatement();
 stm1.executeQuery(sql1);
 ResultSet rs1= stm1.getResultSet();
  while (rs1.next ()){

 for(int k=0; k<=count; k++)
    {

               double x = rs1.getInt(1);
               double y = rs1.getInt(2);
               series.add(x, y);
            }
    }
}

}

catch(Exception e){
    System.out.println(e);
       }





        xySeriesCollection.addSeries(series);
        return xySeriesCollection;
    }

    public static void main(String args[]) {
        SPlotfinal scatterplotdemo4 = new SPlotfinal("GRAPH-KALYANI");
        scatterplotdemo4.pack();
        RefineryUtilities.centerFrameOnScreen(scatterplotdemo4);
        scatterplotdemo4.setVisible(true);
    }


       }

thank in advance,

View Answers









Related Tutorials/Questions & Answers:
how to run a applet from browser
how to run a applet from browser  hi, iam sending the code of an applet. it is working in cmd prompt,but not working from browser. <APPLET CODE... error. plz suggest me the related code to execute from browser. import
how to run applet - Applet
how to run applet   Hi everybody i am using connecting jdbc in applet program. this is executed successfully with appletviewer command >... how can i execute in browser ? Thanks in advance thanks for seeing my
Advertisements
Applet run with appletviewer but not in browser, any code problem.
Applet run with appletviewer but not in browser, any code problem.  ... fine but not run from the browser as http://localhost:8080/ProgressoApplication... the 52 cards will be show in browser as by "appletviewer" and run as "java applet" I
Problem In applet Its run on browser but hang and blinking when image is draging some where.
Problem In applet Its run on browser but hang and blinking when image is draging some where.  I am Created applet in working properly on browser. In my applet 52 card images is draw and drage and move on the applet, but when I am
Java - Applet Hello World
. You will learn how to develop applet code and run in the browser. Applet...;} } Compiling Applets: javac HelloWorldApplet.javaADS_TO_REPLACE_2 Running Applet from console: java HelloWorldApplet Running Applet from Web browser:ADS_TO_REPLACE_3
The Java Applet Viewer
. It is included in the SDK. It helps you to test an applet before you run it in a browser... in a web page and run within a web browser. The applet's code gets transferred... different from a Web browser, though they are logically same. The Applet viewer runs
Java - Opening a URL from an Applet
window from an applet. This program shows that how a url is opened in same... Java - Opening a URL from an Applet  ... used for opening url from an applet. This program is using two functions
The Java Applet Viewer
. It is included in the SDK. It helps you to test an applet before you run it in a browser... in a web page and run within a web browser. The applet's code gets transferred... different from a Web browser, though they are logically same. The Applet viewer
The Java Applet Viewer
to test an applet before you run it in a browser. Before going any further, lets... the applet viewer and the web browser to run the applet is that the applet viewer only... program and the Options argument specifies how to run the Java applet. We can use
Java - Opening a url in new window from an applet
Java - Opening a url in new window from an applet       This is the example of opening a url from an applet. This program shows that how a url is opened in a new document or browser
Applet
Applet  how to run an applet on a web browser
How to run PHP Script from the command line ?
How to run PHP Script from the command line ?  Running PHP Script from the command line   Actually it is very simple to run php script... expect. You can also check : http://www.phpzag.com/running-php-script-from
How to call the run method from another class?
How to call the run method from another class?  Sorry, if this is a stupid question. I would like to find out how to call the run method... run() { new FereastraPrincipala().setVisible(true); from the class
Browser Crashes Suddenly : Application uses applet - Applet
Browser Crashes Suddenly : Application uses applet   Hello All, All of sudden, when the application is running the browser IE6 gets crashed . JRE used is 1.5.0_05. Can anyone please help me out . Its urgent.. Vishal
java applet run time error - Applet
java applet run time error  Hi, Im new to java applet.please help me. i have create a MPEG movie player in applet. when i run that program... javax.media.*; public class PlayerApplet extends Applet implements ControllerListener
how to retrieve data into combo from database in java applet?
how to retrieve data into combo from database in java applet?  hi,. i have written applet codes for linking two frames and database connectivity...= con.createStatement(); ResultSet rs=st.executeQuery("SELECT rolename from role
Applet in Eclipse - Running Applet In Eclipse
and run Applet in Eclipse IDE. In this section, you will learn how to run applet... in a browser. The HTML document tells the browser to load and run an applet using..., then select Run->Run as->Java Applet from the menu bar. The program runs
How to create Applet Hello World?
How to create Applet Hello World?  Hi, What is Applet in Java? How to create Applet Hello World? Thanks   Hi, Applet is Java Program that runs in browser. Browser should be Java enabled to run a program. You have
Security Issues with the Applet
Security Issues with the Applet       Java applet is run inside a web browser. But an applet is restricted in some areas, until it has been deemed
How to run java swing application from jar files .
How to run java swing application from jar files .  Hello Sir... setup file .As per my knowledge i have to run .jar file from dist folder of netbeans but when i am trying to run from there i am getting error "Could not find
how can i run ASP.Net Server from netbeans IDE?
how can i run ASP.Net Server from netbeans IDE?  please help me how can i run ASP.Net Server from netbeans IDE? in other word , I have a web services published with IIS7 and I want to use it from my Application My Application
how i get experience wise resume from database when i submit from browser
how i get experience wise resume from database when i submit from browser  how i get experience wise resume from database when i submit from browser   Please go through the following link: Visit Here
Opening a URL from an Applet
window from an applet. This program shows that how a url is opened in same... Opening a URL from an Applet     ... features have been used for opening url from an applet. This program is using two
difference from browser to browser - JSP-Servlet
difference from browser to browser  I am developing a project in jsp. When browse in mozilla it works good and when I open it with IE there is a difference how to overcome this problem.Thanks in advance
to run html code in web browser - JSP-Servlet
to run html code in web browser  how to run jsp file which calls html file on web browser??  Hi Friend, Try the following code: 1)form.jsp: Enter Name: 2)welcome.html: Add Profile Edit
passing parameter from html to applet
passing parameter from html to applet  how to pass the following from HTML to applet in Java code - font size,font style,font size?give me suitable code
Run a .exe from a class
Run a .exe from a class  how to lauch a .exe file from a class in Java and to check the success ful execution of the same
Applet in Java
Applet is a Java program designed for execution within the web browser... Firefox and Internet Explorer. These web browsers download Applet from the Internet and run them. An Applet is a Java subclass that extends
How to launch my web application from my desktop without opening Netbeans IDE everytime i run the application?
How to launch my web application from my desktop without opening Netbeans IDE everytime i run the application?  Hi RoseIndia, Thanks for ur reply... please explain in detail how to create browser shorcut to my project,how to deploy
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Browser database. what code will i do? this is my existing code from my
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Browser database. what code will i do? this is my existing code from my
The Java Applet Viewer
be stored in a web page and run within a web browser. The applet's code gets... of Applet viewer is a bit different from a Web browser, though they are logically same... tags. The difference in using the applet viewer and the web browser to run
download a file from browser - Java Beginners
download a file from browser  How to download a file from browser and save it in local path
Could not able to run Java Applet in JSP using <jsp:plugin>
Could not able to run Java Applet in JSP using   I could not able to run the above example applet in the JSP. Getting class not found exception... the following links: http://www.roseindia.net/jsp/applet-jsp.shtml http
Java - Opening a url in new window from an applet
how to open a new window from an applet. You can use the code given... Java - Opening a url in new window from an applet  ... window from applet is rather very simple task as all the necessary functions
how to run java program that has several classes under package from usb drive?
how to run java program that has several classes under package from usb drive... package. I have to use following line on command line to compile and run my program... and run the code. I tried installing jdk but it was taking very long time so did
Works when run from desktop but....
Works when run from desktop but....  I used the code provided here for a pie chart using swing in Java, and when I saved it to my desktop, it ran fine, and worked as explained, but then I tried to add the same code to NetBeans
how to import user-define package to applet - Applet
how to import user-define package to applet  how to import user-define package to applet... can u write a java coding can execute in jdk only...; public class JavaApplet extends Applet{ public static final String DATE
Java Applet
Applets are Java programs that run on java enabled web browser. Java applets...-in to run applet Java applet takes time to startup for the first time... Applet runs in a web browser and its lifecycle method are called by JVM when
Opening a browser only with body from a java program
Opening a browser only with body from a java program  Hi all, I got following requirement, Opening a browser window only with body and title bar... bar and etc. And I don't know how to close this browser window. Please help me
Applet
the start Method() of an Applet will be called by the web browser and the user...Applet  Explain the start() and stop() methods of applet life cycle.   Start and Start method of Applet Life Cycle Start () method
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized  import java.awt.*; import java.awt.event.*; import java.applet.*; public class Textfields extends Applet implements
How to get browser time zone?
How to get browser time zone?  How to get browser Time Zone and browser date using java concept
Applet Write Files Example
;  In this section, you will learn how to write to a file from... the permission for writing a file from an applet. For this, you will have to maintain... a file from an applet. Without maintaining the Java security policy file
how to access database in applet
how to access database in applet  HI... I'm having an applet where we should display the database values in the applet... It works fine in the local system(same network)... but when its in the server, we r getting null values
changes in netbeans/ browser so that each application run opens in a new window of browser
changes in netbeans/ browser so that each application run opens in a new window... time i run an application it opens up in a new window rather than a new tab.. Do i have to make changes in netbeans or browser? and what changes need
Applet : Java Glossary
applets run from inside a browser therefore they require a reference... under a Web browser. We can automatically download applet as part of a Web page... a Web page having an applet in it by using a Java-enabled browser, the browser
how to disable browser back button
how to disable browser back button  Am doing a web application in that how to disable browser back button using java script
Applet - Applet
. Applet is designed to run remotely on the client browser, so there are some...Applet  what is the concept of applet? what is different between the applet concept and HTML? what is mean by swing?  Hi friend
how to run rmi program
how to run rmi program  how to run rmi program

Ads