How to get position and size of project editor?


How can I get the position and size of the whole editor? (no matter how many files are opened I need the whole area):


This I how I get the current editor and then I apply a VisibleAreaListener:

MyVisibleAreaListener visibleAreaChangedListener = new MyVisibleAreaListener();

EditorFactory.getInstance().getEventMulticaster().addVisibleAreaListener(visibleAreaChangedListener, new Disposable() {
public void dispose() {


And the listener:

public class MyVisibleAreaListener implements VisibleAreaListener {

public void visibleAreaChanged(VisibleAreaEvent event) {
Rectangle rect = event.getNewRectangle();
System.out.println("Rect x: " + rect.x + ", Rect y:" + rect.y);
System.out.println("Rect width: " + rect.width + ", Rect height:" + rect.height);



This allows me to get the current width and height of the editor but rect.x and rect.y are always zero

Comment actions Permalink

You can get the on-screen location using the Editor's Swing component:

Comment actions Permalink

Indeed that allows me to get the screen X and Y position correctly but the width and height are wrong.

Everytime I change the size of the editor there is some weird behavior inside the listener and It always gets triggered two times:

  • First call: The event contains the correct X and Y but wrong width and height 
  • Second call: The event contains negative X and Y but correct height and width
Comment actions Permalink

What about the component width and height? Does it differs from the values from the event?


Please sign in to leave a comment.