Hi Friends,
Currently am building a small app where the Jpanel as the scroll but i want this to get auto scrolling based on the action event from a button and by set timing...
Can you please help me out in this
Thanks in advance
Printable View
Hi Friends,
Currently am building a small app where the Jpanel as the scroll but i want this to get auto scrolling based on the action event from a button and by set timing...
Can you please help me out in this
Thanks in advance
Sure thing. But where's what you've tried, and what's the specific issue with which you need help?
As your post stands, it looks more like "Will one of you suckers do this for me?" than "Can you please help" -- and even that can't work, what with the paucity of detail.
To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates your specific problem.
db
Thanks for the Darryl,
When i posted this i was not aware how to have a auto scroll option now i found the code and its getting done just adding the code sample for the review, wheather am i doing correct
int panelMaxY = (int)imgPanel.getBounds().getMaxY(); // getting the Max size of the Panel area
int scrolViewY = (int)scrollPane.getViewport().getViewPosition().ge tY();
log.info("The scrol panel height is : "+panelMaxY);
log.info("The scrol View Y is : "+scrolViewY);
if(scrolViewY < panelMaxY){
log.info("The scrol View Y is : "+scrolViewY);
scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getViewPo sition().getY()+180));
}else if (scrolViewY > panelMaxY){
log.info("The scrol View Y is More : "+scrolViewY);
scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getMaximu mSize().width));
}
am setting a timer for moving this scroll based on the set... Please suggest is this correct or any best way
Code:int panelMaxY = (int)imgPanel.getBounds().getMaxY(); // getting the Max size of the Panel area
int scrolViewY = (int)scrollPane.getViewport().getViewPosition().ge tY();
log.info("The scrol panel height is : "+panelMaxY);
log.info("The scrol View Y is : "+scrolViewY);
if(scrolViewY < panelMaxY){
log.info("The scrol View Y is : "+scrolViewY);
scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getViewPo sition().getY()+180));
}else if (scrolViewY > panelMaxY){
log.info("The scrol View Y is More : "+scrolViewY);
scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getMaximu mSize().width));
}
Where's that SSCCE?
db