S
scifluent
Hi!
For some reason the code below will run fine in the sun applet viewer
but will not deploy in my Safari or Firefox browser. All I get is the
java loading indicator and then a red "x" in the window it should be
working in. I exported the class into an uncompressed .jar file to
eliminate the issue mentioned at:
http://www.velocityreviews.com/forums/t132903-problem-deploying-applet.html
but no improvement.
Anyone made this hurdle?
Web page:
<html>
<body>
<applet code= ChartApplet.class
archive="ChartJar.jar"
width=500 height=500>
</applet>
</body>
</html>
Code made using Eclipse with the assistance of VE:
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Rectangle;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.TitledBorder;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class ChartApplet extends JApplet {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private ChartPanel chartPanel;
private String columnNames[];
private String dataValues[][];
protected XYSeriesCollection chartDataSet = new XYSeriesCollection();
protected ArrayList <String> chartPlotType = new
ArrayList<String>(); // @jve:decl-index=0:
protected String chartTitle = "Hey";
protected String chartYAxisTitle = "Wow";
protected String chartXAxisTitle = "NoWay";
/**
* This is the xxx default constructor
*/
public ChartApplet() {
super();
}
/**
* This method initializes this
*
* @return void
*/
public void init() {
dummyChart();
this.setContentPane(getJContentPane());
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
FlowLayout flowLayout = new FlowLayout();
flowLayout.setHgap(9);
flowLayout.setVgap(27);
jContentPane = new JPanel();
jContentPane.setLayout(flowLayout);
jContentPane.add(chartPanel);
}
return jContentPane;
}
// jFreeChart
public void createChart(){
JFreeChart chart = createChart(chartDataSet);
chartPanel = new ChartPanel(chart);
chartPanel.setBorder(BorderFactory.createTitledBorder(new
SoftBevelBorder(SoftBevelBorder.RAISED), "Option Chart",
TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, null, null));
}
protected JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createXYAreaChart(
chartTitle,
chartXAxisTitle, chartYAxisTitle,
dataset,
PlotOrientation.VERTICAL,
true, // legend
true, // tool tips
false // URLs
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setForegroundAlpha(0.65f);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setTickMarkPaint(Color.black);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setTickMarkPaint(Color.black);
return chart;
}
private void dummyChart(){
for (int j = 0; j < 2; j++){
ArrayList<Float> xdata = new ArrayList<Float>();
ArrayList<Float> ydata = new ArrayList<Float>();
for (int i = 0; i < 10; i++) {
xdata.add((float)i);
ydata.add((float) i * .10f);
}
xdata.trimToSize();
ydata.trimToSize();
this.addChartSeriesXandYValues("Test", xdata, ydata,"Shape");
this.createChart();
}
}
public void addChartSeriesXandYValues(String series_title_in,
ArrayList<Float> x_data_in,
ArrayList<Float> y_data_in, String plot_type) {
XYSeries newSeries = new XYSeries(series_title_in);
ArrayList<Float> seriesX = x_data_in;
ArrayList<Float> seriesY = y_data_in;
for(int i = 0; i < seriesX.size(); i++)
newSeries.add(seriesX.get(i), seriesY.get(i));
chartDataSet.addSeries(newSeries);
chartDataSet.setIntervalWidth(0.0);
chartPlotType.add(plot_type);
}
}
For some reason the code below will run fine in the sun applet viewer
but will not deploy in my Safari or Firefox browser. All I get is the
java loading indicator and then a red "x" in the window it should be
working in. I exported the class into an uncompressed .jar file to
eliminate the issue mentioned at:
http://www.velocityreviews.com/forums/t132903-problem-deploying-applet.html
but no improvement.
Anyone made this hurdle?
Web page:
<html>
<body>
<applet code= ChartApplet.class
archive="ChartJar.jar"
width=500 height=500>
</applet>
</body>
</html>
Code made using Eclipse with the assistance of VE:
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Rectangle;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.TitledBorder;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class ChartApplet extends JApplet {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private ChartPanel chartPanel;
private String columnNames[];
private String dataValues[][];
protected XYSeriesCollection chartDataSet = new XYSeriesCollection();
protected ArrayList <String> chartPlotType = new
ArrayList<String>(); // @jve:decl-index=0:
protected String chartTitle = "Hey";
protected String chartYAxisTitle = "Wow";
protected String chartXAxisTitle = "NoWay";
/**
* This is the xxx default constructor
*/
public ChartApplet() {
super();
}
/**
* This method initializes this
*
* @return void
*/
public void init() {
dummyChart();
this.setContentPane(getJContentPane());
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
FlowLayout flowLayout = new FlowLayout();
flowLayout.setHgap(9);
flowLayout.setVgap(27);
jContentPane = new JPanel();
jContentPane.setLayout(flowLayout);
jContentPane.add(chartPanel);
}
return jContentPane;
}
// jFreeChart
public void createChart(){
JFreeChart chart = createChart(chartDataSet);
chartPanel = new ChartPanel(chart);
chartPanel.setBorder(BorderFactory.createTitledBorder(new
SoftBevelBorder(SoftBevelBorder.RAISED), "Option Chart",
TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, null, null));
}
protected JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createXYAreaChart(
chartTitle,
chartXAxisTitle, chartYAxisTitle,
dataset,
PlotOrientation.VERTICAL,
true, // legend
true, // tool tips
false // URLs
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setForegroundAlpha(0.65f);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setTickMarkPaint(Color.black);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setTickMarkPaint(Color.black);
return chart;
}
private void dummyChart(){
for (int j = 0; j < 2; j++){
ArrayList<Float> xdata = new ArrayList<Float>();
ArrayList<Float> ydata = new ArrayList<Float>();
for (int i = 0; i < 10; i++) {
xdata.add((float)i);
ydata.add((float) i * .10f);
}
xdata.trimToSize();
ydata.trimToSize();
this.addChartSeriesXandYValues("Test", xdata, ydata,"Shape");
this.createChart();
}
}
public void addChartSeriesXandYValues(String series_title_in,
ArrayList<Float> x_data_in,
ArrayList<Float> y_data_in, String plot_type) {
XYSeries newSeries = new XYSeries(series_title_in);
ArrayList<Float> seriesX = x_data_in;
ArrayList<Float> seriesY = y_data_in;
for(int i = 0; i < seriesX.size(); i++)
newSeries.add(seriesX.get(i), seriesY.get(i));
chartDataSet.addSeries(newSeries);
chartDataSet.setIntervalWidth(0.0);
chartPlotType.add(plot_type);
}
}