Can someone help me on how to draw a dynamic pie chart in java?
I don't want to use jfreechart. I want to use jtable or other methods if available(but simple one)
I have one but it is static.i need to write it upon user input.how can i do it?
private Font font;
public PieChart ()
{
super( "Computer" );
setSize( 600, 400 );
setLocation( 70, 70 ) ;
show();
}
public void paint( Graphics g )
{
font = new Font("Sanserif", Font.BOLD, 14);
// start at 0 and sweep 360 degrees
g.setColor( Color.black );
g.fillArc( 110, 80, 300, 300, 0, 36 );
g.drawString("Hand Tool : 10%", 420, 80);
g.setColor( Color.red );
g.fillArc( 110, 80, 300, 300, 36, 120 );
g.drawString("Power : 33%", 420, 100);
g.setColor( Color.blue );
g.fillArc( 110, 80, 300, 300, 156, 80 );
g.drawString("Lawn Mower Sales: 22%", 420, 120);
g.setColor( Color.green );
g.fillArc( 110, 80, 300, 300, 236, 80 );
g.drawString("Bench Tools Sales: 22%", 420, 140);
g.setColor( Color.white );
g.fillArc( 110, 80, 300, 300, 316, 44 );
g.drawString("Tool Accessories Sales: 12%", 420, 160);
g.setColor( Color.black );
g.drawArc( 110, 80, 300, 300, 0, 360 );
}
public static void main( String args[] )
{
PieChart app = new PieChart ();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
}
);
}
}