java中paint方法在哪 怎么用java做柱形图?
怎么用java做柱形图?
用jfreechart
jfreechart草图柱状图
import
import
import
import
import
import
import
/*
*绘制的柱状图
*你亮哥
**/
welfareclassBarChart3DDemo
{
privatestaticvoidmain(String[]args)
{
try
{
//可以设置主题
(())
//构造数据
DefaultCategoryDataset dataset new DefaultCategoryDataset()
(100,
Java中如何实现数字水印?
然后在图片上画呗,导入一张背景图片,在背景图片上画一个水印用graphicsg,也就是frame的paint肯定draw方法就这个可以基于
怎么用java写一个简单的抛物线程序?
给您一个例子:
importjavax.swing.*
import*
import*
privateclasspaint
{
privatestaticvoidmain(String[]args)
{
CenteredFrame framenew CenteredFrame()
(JFrame.EXIT_ON_close)
(true)
}
}
classCenteredFrameextendsJFrame
{
privatestaticfinalintWIDTH400private static final int HEIGHT400public CenteredFrame()
{
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
int x[]fifthint[33]
int y[]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
g2.draw true privatestaticvoidmain args String
版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。