Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Scroll Pane does not work with shell menu
Scroll Pane does not work with shell menu [message #722478] Mon, 05 September 2011 22:50 Go to next message
rahulrevo is currently offline rahulrevoFriend
Messages: 2
Registered: September 2011
Junior Member
Hi,

I have a simple class below where a shell with a menu bar is created and it contains a ScrollPane. The scroll pane content figure contains many rectangle figures which should cause the horizontal and vertical scroll bar to appear in the scroll pane. However the horizontal scroll bar does not appear when shell has a menu. If shell menu is not attached (comment buildMenu(shell) ) then both the horizontal and vertical scroll bars appear.

Anyone has any ideas on how this can be fixed?

Thanks,
Rahul


import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.ScrollPane;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;

public class ScrollPaneTest {

  private static final int COLUMN_COUNT = 50;
  private static final int FIGURE_COUNT = 500;

  public static void main(String args[]) {
    new ScrollPaneTest().process();
  }

  public void process() {
    Display d = Display.getDefault();
    final Shell shell = new Shell(d);

    // Comment this line for the scroll bars
    buildMenu(shell);

    LightweightSystem lws = new LightweightSystem(shell);

    final ScrollPane scrollPane = new ScrollPane();
    lws.setContents(scrollPane);

    final Figure contents = new Figure();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = COLUMN_COUNT;
    contents.setLayoutManager(gridLayout);
    scrollPane.setContents(contents);

    for (int i = 0; i < FIGURE_COUNT; i++) {
      IFigure rectangleFigure = createFigure();
      contents.add(rectangleFigure);
    }

    shell.open();
    shell.setText("Example");
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
  }

  IFigure createFigure() {
    RectangleFigure rectangleFigure = new RectangleFigure();
    rectangleFigure.setBackgroundColor(ColorConstants.darkBlue);
    rectangleFigure.setSize(300, 300);
    return rectangleFigure;
  }

  private void buildMenu(final Shell shell) {
    Menu menuBar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menuBar);

    MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
    fileItem.setText("&File");
    Menu fileSubmenu = new Menu(shell, SWT.DROP_DOWN);
    fileItem.setMenu(fileSubmenu);

    MenuItem exitMenuItem = new MenuItem(fileSubmenu, SWT.PUSH);
    exitMenuItem.setText("E&xit");
    exitMenuItem.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event event) {
        shell.close();
      }
    });
  }
}

Re: Scroll Pane does not work with shell menu [message #722485 is a reply to message #722478] Mon, 05 September 2011 23:20 Go to previous message
rahulrevo is currently offline rahulrevoFriend
Messages: 2
Registered: September 2011
Junior Member
This bug showed up on a Linux 64 bit OS (Ubuntu) and was not reproducible on Windows 32bit
Previous Topic:moving child from one container to another
Next Topic:Creating collapsable and expandable figures
Goto Forum:
  


Current Time: Tue Mar 19 11:41:04 GMT 2024

Powered by FUDForum. Page generated in 0.02025 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top