kalmudunuru
how to run a applet from browser
0 Answer(s)      4 years ago
Posted in : Java Beginners

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,

Advertisement
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...: javac HelloWorldApplet.java Running Applet from console: java HelloWorldApplet Running Applet from Web browser: Running applet in browser is very easy job
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
. 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
The Java Applet Viewer
and can be stored in a web page and run within a web browser. The applet's code... of Applet viewer is a bit different from a Web browser, though they are logically... applet tags. The difference in using the applet viewer and the web browser to run
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
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
Applet
Applet  how to run an applet on a web browser
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
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
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
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... Run->Run as->Java Applet from the menu bar. The program runs
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
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 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
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
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
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
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 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 run rmi program
how to run rmi program  how to run rmi program
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... to create browser shorcut to my project,how to deploy my project on web server
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
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     ... used for opening url from an applet. This program is using two functions in which
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