---
title: "关于图形拖出Editor的左侧或上侧边界的时候不自动出现滚动条的问题。"
author: "Dollyn"
date: "2007-04-22T21:16:00Z"
tags: []
slug: "editor"
draft: false
lastmod: "2012-02-10T09:48:45Z"
id: 1401574
url: "https://dollyn.iteye.com/blog/1401574"
---

问题现象：  
当拖动一个图形出Editor的左侧或者上侧边界的时候，会拖出边界，但是并没有出现滚动条，这样再想看图形的全貌就必须再把图形拖进来。

这个问题很早就遇到了过了，当时没有注意，随便查了下资料，也没搞懂，反正不是什么大毛病，就没在管它了。  
最近又看到了这个问题，于是仔细看了下代码，和GEF例子里的代码比较了一下，发现少了下面的语句：

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)protectedvoidconfigureGraphicalViewer()...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)super.configureGraphicalViewer();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)viewer=this.getGraphicalViewer();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)viewer.setEditPartFactory(newDBPartFactory());  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//下面这句用于实现在向左，上拖动模型出Editor边界的时候，自动出现滚动条。同时需要保证Contentsmodel的figure用的是FreefromLayout。同时，Figure还有一定的要求，目前已知freeformLayer可以，Layer不可以 。  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)viewer.setRootEditPart(newScalableFreeformRootEditPart());//少的就是这句了  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)还要注意ContentsModel对应的Figure的LayoutManager，必须是这个Freeformlayout,不然的话，当把图形脱出边界的时候会出现像死循环一样的情况，就是滚动条一直在自动滚动，一直到程序死掉。

就这样了，大家遇到相同的情况可以参考下。