문제

I am new in SWT and java I really need an help here.

I need to build Eclipse plug-in that should open a dialog when you press on button.

The dialog should look like

       label 1   textBox1                label 2 textBox 2
       label 3  textBox13                label 4 textBox 4


       could be alot of them -> should be with scroller


       ---------------------------------------------------


           output ( should be textbox)


     -----------------------------------------------------


           messages ( should be textbox)

It could be alot of labels and textbox, How I can add them to control that could hold alot of them ? ( it should be with scroller )

How I can split the screen to 3 parts in SWT or fjace ? and how I can control on the size for example that the first part ( label textbox) will be 60% and the output will be 30% and the messages 10% ?

Maybe you could help me with an example for this ?

도움이 되었습니까?

해결책

This is asking for far too much code - you are supposed to show us what you have tried!

Some hints:

Use org.eclipse.jface.dialog.Dialog for the dialog, you could also use org.eclipse.jface.dialog.TitleAreaDialog which has an area for error messages.

To split an area by percentages use org.eclipse.swt.custom.SashForm.

To get multiple items on a line use org.eclipse.swt.layout.GridLayout specifying the number of columns.

To get a scrolled area use org.eclipse.swt.custom.ScrolledComposite

So something like:

@Override
protected Control createDialogArea(final Composite parent)
{
  Composite body = (Composite)super.createDialogArea(parent);

  // Vertical sash

  SashForm sashForm = new SashForm(body, SWT.VERTICAL);

  sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

  // First part, scrollable

  ScrolledComposite scrolledComp = new ScrolledComposite(sashForm, SWT.V_SCROLL);

  Composite comp1 = new Composite(scrolledComp, SWT.NONE);

  comp1.setLayout(new GridLayout());

  // TODO: add controls to comp1

  // Set scroll size - may need to adjust this

  Point size = comp1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  scrolledComp.setMinHeight(size.y);
  scrolledComp.setMinWidth(size.x);
  scrolledComp.setExpandVertical(true);
  scrolledComp.setExpandHorizontal(true);

  scrolledComp.setContent(comp1);

  // Second part

  Composite comp2 = new Composite(sashForm, SWT.NONE);

  comp2.setLayout(new GridLayout());

  // TODO: add controls to comp2

  // Third part

  Composite comp3 = new Composite(sashForm, SWT.NONE);

  comp3.setLayout(new GridLayout());

  // TODO: add controls to comp3

  // Set the sash weighting (must be after controls are created)

  sashForm.setWeights(new int [] {60, 30, 10});

  return body;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top