Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic