• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 22. FileExplorer > Implementation Notes

22.2. Implementation Notes

22.2.1. Flexible Layout

The FileExplorer shell uses FormLayout to arrange its children. Initially, the table, the tree, and the sash between them are attached to the tool bar at the top and the status label at the bottom. The View menu allows you to hide the tool bar or status label. This is accomplished by changing the attachment of the table, tree, and sash to be relative to the edge of the shell, then hiding the tool bar or label. For example, here is the code that toggles the visibility of the tool bar.

if (toolItem.getSelection ()) {
    FormData treeData = (FormData) tree.getLayoutData ();
    treeData.top = new FormAttachment (toolBar);
    FormData sashData = (FormData) sash.getLayoutData ();
    sashData.top = new FormAttachment (toolBar);
    FormData tableData = (FormData) table.getLayoutData ();
    tableData.top = new FormAttachment (toolBar);
} else {
    FormData treeData = (FormData) tree.getLayoutData ();
    treeData.top = new FormAttachment (0);
    FormData sashData = (FormData) sash.getLayoutData ();
    sashData.top = new FormAttachment (0);
    FormData tableData = (FormData) table.getLayoutData ();
    tableData.top = new FormAttachment (0);
}
toolBar.setVisible (toolItem.getSelection ());
shell.layout ();


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint