• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am not able to display panel in my applet by embedding applet in html. Please help.

 
arindamin ghosh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not able to display panel in my applet by embedding applet in html. Please help.
It is displaying draw string "sample applet 9" but the chartpanel is not being displayed.


html file:
<APPLET
CODE="SampleApplet.class"
WIDTH="700" HEIGHT="400"
ARCHIVE = "jfreechart-1.0.13.jar,jcommon-1.0.16.jar"
>
</APPLET>

applet code:
public void paint(Graphics g) {
g.drawString("sample applet 9", 100, 100);

XYDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
chartPanel.setVisible(true);
getContentPane().add(chartPanel);
g.dispose();
g.finalize();
g = null;
//setVisible(true);
}

Advance Thanks.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arindamin, welcome to the Ranch!

1. Any painting method override should invoke the super implementation, unless the entire area of the component is being painted in the custom painting code.

2. Painting method overrides are to be used for painting alone. Not for adding components or any other business logic.

3. Don't dispose() the passed in Graphics reference. You only need to dispose() any Graphics objects that you create in your code.

4. It is virtually never required to call finalize() in client code.

The code snippet you posted isn't enough to give more specific advice than this. To get better help sooner, post a SSCCE that clearly demonstrates your problem.

Also, please go through the Swing tutorial.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic