cf实现java代码 jar cfm( 六 )


{
try
{
Robot ro=new Robot();
bi=ro.createScreenCapture(new Rectangle(0,0,di.width,di.height));
}
catch(Exception e)
{
e.printStackTrace();
}
addMouseListener(this);
addMouseMotionListener(this);
}
public void paintComponent(Graphics g)
{
g.drawImage(bi,0,0,di.width,di.height,this);
g.setColor(Color.red);
g.drawRect(startx, starty, endx-startx, endy-starty);
}
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getButton()==MouseEvent.BUTTON3)
{
System.exit(0);
}
else if(e.getClickCount()==2)
{
try
{
Robot ro=new Robot();
get=ro.createScreenCapture(new Rectangle(startx,starty,endx-startx,endy-starty));
String name=filename+String.valueOf(count++)+"."+fileformat;
File f=new File(name);
ImageIO.write(get, fileformat, f);
}
catch(Exception ex)
{
ex.printStackTrace();
}
flag=1; //置flag为1,以便重新开始截图 。
startx=starty=endx=endy=0;
repaint();
}
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
if(flag==1)
{
startx=e.getX();
starty=e.getY();
}
}
public void mouseReleased(MouseEvent e) {
flag=0;
}
public void mouseDragged(MouseEvent e) {
flag=1;
endx=e.getX();
endy=e.getY();
repaint();
}
public void mouseMoved(MouseEvent e) {}
}
}
【cf实现java代码 jar cfm】cf实现java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于jar cfm、cf实现java代码的信息别忘了在本站进行查找喔 。

推荐阅读