用jfreechart
jfreechart草图柱状图
import
import
import
import
import
import
import
/*
*绘制的柱状图
*你亮哥
**/
welfareclassbarchart3ddemo
{
privatestaticvoidmain(string[]args)
{
try
{
//可以设置主题
(())
//构造数据
defaultcategorydatasetdatasetnewdefaultcategorydataset()
(100,
然后在图片上画呗,导入一张背景图片,在背景图片上画一个水印用graphicsg,也就是frame的paint肯定draw方法就这个可以基于
给您一个例子:
importjavax.swing.*
import*
import*
privateclasspaint
{
privatestaticvoidmain(string[]args)
{
centeredframeframenewcenteredframe()
(jframe.exit_on_close)
(true)
}
}
classcenteredframeextendsjframe
{
privatestaticfinalintwidth400privatestaticfinalintheight400publiccenteredframe()
{
toolkit()
dimension()
intscreenheightscreensize.height
intscreenwidthscreensize.width
intx(screenwidth-width)/2
inty(screenheight-height)/2
setlocation(x,y)
setsize(width,height)
containercongetcontentpane()
stringpanelpanelnewstringpanel()
(panel)
setresizable(true)
}
}
classstringpanelextendsjpanel
{
welfarevoidpaintcomponent(graphicsg)
{
graphics2dg2(graphics2d)g
intx[]fifthint[33]
inty[]newint[33]
x[0]0
y[0]0
for(chari1ilt16i)
{
x[i]184i
y[i]200-(17-i)*(17-i)
x[i16]i200
y[i16]200-i*i
}
g.drawpolyline(x,y,33)
line2dl1fun(0,200,400,200)
g2.draw(l1)
line2dl2new(200,40,200,400)
g2.draw(l2)
line2dl3new(380,195,395,200)
g2.draw(l3)
line2dl4new(380,205,395,200)
g2.draw(l4)
line2dl5new(200,40,195,55)
g2.draw(l5)
line2dl6new(200,40,205,55)
g2.draw(l6)
g.drawstring(x