I hav added a JScrollpane to JPanel and the JPanel is added to a JFrame.Then i painted/drawn some rectangles using paintComponet().There r many rectangles drawn but I cant scroll down the JPanel. Is it possible to scroll down a JPanel to see all paintings down this area where some paintings hav been made during runtime.And what if I want to change the color of each rectangle during runtime. I also want to add a button which being pressed will do all this drawing on the JPanel. Or is there any component to draw this way.I hav given the code I hav tried my best, Pls help me, actually I m trying to make a GantChart.
int width=15;
int hight=12;
int down=60;
int strX=140;
int lineX=140;
//double cval;
int cR,cG,cB;
//cval=Math.random();
///////////////////////////FOR DATE TITLE/////////////////////////
for( int i=1; i<32 ; i++ )
{
g.setColor(Color.red);
String st=new String().valueOf(i);
g.setFont(new Font("Monospaced",Font.BOLD+Font.ITALIC,13));
g.drawString(st,strX,45);
g.setColor(Color.magenta);
strX=strX+22;
}
for( int i=1; i<50 ; i++ )
{ g.drawLine(lineX,37,lineX,1000);
lineX=lineX+20;
}
//////////////////////////FOR BAR CHART/TIMELINE/////////////////////////
for( int a=1; a<20 ; a++ ){
cR=160;
cG=46;
cB=98;
g.setColor(new Color(cR,cG,cB));
g.fill3DRect(140,down,width,hight,true);
down=down+20;
width=width+20;
cR=cR+15;
cG=cG+5;
cB=cB+35;
}