Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #922

Getting ScrolledComposite

From lionelv@gmail.com.remove-dii-this
Subject Getting ScrolledComposite
Message-ID <1171436554.686283.86420@s48g2000cws.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:30 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
I'm new to SWT, I have come from using Swing.

I think I'm having problems with the size stuff but I'm not sure.
Basically I've forced the scroll bar to show, but it's not enabled.
Here's my code as a subclass of org.eclipse.jface.window.Window:

protected Control createContents(Composite parent) {
        //layout the parent composite
        GridLayout layout = new GridLayout();
        layout.marginWidth = 0;
        layout.marginHeight = 2;
        parent.setLayout(layout);

        ScrolledComposite scrolledComposite = new
ScrolledComposite(parent,
                SWT.V_SCROLL | SWT.BORDER);
        scrolledComposite.setAlwaysShowScrollBars(true);

        //layout the composite holding the content
        content = new Composite(scrolledComposite, SWT.BORDER);
        scrolledComposite.setContent(content);
        content.setLayout(new GridLayout(2, false));
        content.setLayoutData(new GridData(GridData.FILL_BOTH));

        //heading font
        FontData fontData = new FontData();
        fontData.setStyle(SWT.BOLD);
        Font font = new Font(Display.getCurrent(), fontData);

        //create the heading labels
        Label label = new Label(content, SWT.CENTER);
        label.setText("Variable Name");
        label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        label.setFont(font);

        label = new Label(content, SWT.NULL);
        label.setText("Hide Variable?");
        label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        label.setFont(font);

        //adds 0-many labels to content
        addVariablePairs();

        content.setSize(content.computeSize(SWT.DEFAULT,
SWT.DEFAULT));
        content.layout(true);
        return parent;
    }

Thanks

Lionel.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

Getting ScrolledComposite lionelv@gmail.com.remove-dii-this - 2011-04-27 15:30 +0000
  Re: Getting ScrolledCompo lionelv@gmail.com.remove-dii-this - 2011-04-27 15:30 +0000

csiph-web