Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Adding other controls to a ToolBar
Adding other controls to a ToolBar [message #902711] Mon, 20 August 2012 04:00 Go to next message
Eclipse UserFriend
I must admit upfront to being pretty clueless about Java and SWT. In an
attempt to learn I'm trying to port a small C# program and immediately
found the GUI construction...erm...interesting.

So, is it possible to shoehorn other controls into a ToolBar (in this
case a label and a progress bar) or do I just place these controls over
an equal-sized separator in the toolbar to simulate the effect?

It's a fixed size window, so that makes the layout simpler at least.

--
`~:.,.:'^`~:.,.:'^`~:.,.:'^`~:.,.:'^`~:.,.:'^`~:.,.:'^`~:.,.:'^`~:.,.:'^`
S e á n Ó S é a g h d h a sean.anseo [at] gmail.com
Go mbéadh seacht shliocht ag sliocht do shleachta. Rabhlóg.
Re: Adding other controls to a ToolBar [message #902915 is a reply to message #902711] Tue, 21 August 2012 07:15 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
public static void main(String[] args) {

    Display display = new Display();

    Shell shell = new Shell(display);

    ToolBar toolBar = new ToolBar(shell, SWT.HORIZONTAL);

    Combo combo = new Combo(toolBar, SWT.READ_ONLY);

    ToolItem comboItem =

        new ToolItem(toolBar, SWT.SEPARATOR);

    comboItem.setControl(combo);

    comboItem.setWidth(64);

    new ToolItem(toolBar, SWT.SEPARATOR);

    for (int i = 0; i < 2; i++) {

        ToolItem item = new ToolItem(toolBar, SWT.PUSH);

        item.setText("Push " + i);

    }

    toolBar.pack();

    shell.pack();

    shell.open();

    while (!shell.isDisposed()) {

        if (!display.readAndDispatch()) display.sleep();

    }

    display.dispose();

}
Re: Adding other controls to a ToolBar [message #903214 is a reply to message #902711] Wed, 22 August 2012 14:10 Go to previous message
Oliver Koch is currently offline Oliver KochFriend
Messages: 40
Registered: June 2012
Member
Am 20.08.2012 06:00, schrieb Seán Ó Séaghdha:
> I must admit upfront to being pretty clueless about Java and SWT. In an
> attempt to learn I'm trying to port a small C# program and immediately
> found the GUI construction...erm...interesting.
>
> So, is it possible to shoehorn other controls into a ToolBar (in this
> case a label and a progress bar) or do I just place these controls over
> an equal-sized separator in the toolbar to simulate the effect?
>
> It's a fixed size window, so that makes the layout simpler at least.
>
You might want to consider using the WindowBuilder feature for eclipse
Previous Topic:active CTabItem
Next Topic:[OLEAutomation]retrieving data from a VT_ARRAY
Goto Forum:
  


Current Time: Thu Dec 18 20:15:49 GMT 2014

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

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