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
Ads
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
Advertisements
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
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
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... and the Options argument specifies
how to
run the Java
applet.
We can use only one option
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
Applet in Eclipse - Running Applet In Eclipse
and
run Applet in
Eclipse IDE. In this section, you will learn
how to
run applet...
browser.
The purpose of an
applet is to extend the functionality of a Web page in a
browser. The HTML document tells the
browser to load and
run an
applet using
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
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
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
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
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
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
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
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
Java Applet
Applets are Java programs that
run on java enabled web
browser. Java applets...:
Web browsers and operating system require Java plug-in to
run applet... interface in applets
Lifecycle of an
Applet:
Applet runs in a web
browser and its
Applet Write Files Example
that uses the
applet class to
run this in the Java based web
browser.
Here...;
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
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
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