Example usage for org.eclipse.swt.widgets Composite setTabList

List of usage examples for org.eclipse.swt.widgets Composite setTabList

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Composite setTabList.

Prototype

public void setTabList(Control[] tabList) 

Source Link

Document

Sets the tabbing order for the specified controls to match the order that they occur in the argument list.

Usage

From source file:FocusTraversal.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);

    shell.setLayout(new RowLayout());

    Composite composite1 = new Composite(shell, SWT.BORDER);
    composite1.setLayout(new RowLayout());
    composite1.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

    Button button1 = new Button(composite1, SWT.PUSH);
    button1.setText("Button1");

    Button button3 = new Button(composite1, SWT.PUSH);
    button3.setText("Button3");

    Button radioButton1 = new Button(composite1, SWT.RADIO);
    radioButton1.setText("radio-1");
    Button radioButton2 = new Button(composite1, SWT.RADIO);
    radioButton2.setText("radio-2");

    Composite composite2 = new Composite(shell, SWT.BORDER);
    composite2.setLayout(new RowLayout());
    composite2.setBackground(display.getSystemColor(SWT.COLOR_GREEN));

    Button button2 = new Button(composite2, SWT.PUSH);
    button2.setText("Button2");

    Combo combo = new Combo(composite2, SWT.DROP_DOWN);
    combo.add("combo");
    combo.select(0);//from  www.j a v  a  2 s  .co m

    composite1.setTabList(new Control[] { button1, button3 });
    composite2.setTabList(new Control[] { button2, combo });

    shell.setTabList(new Control[] { composite2, composite1 });

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

From source file:org.eclipse.swt.snippets.Snippet75.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 75");
    shell.setLayout(new RowLayout());

    Composite c1 = new Composite(shell, SWT.BORDER);
    c1.setLayout(new RowLayout());
    Button b1 = new Button(c1, SWT.PUSH);
    b1.setText("B&1");
    Button r1 = new Button(c1, SWT.RADIO);
    r1.setText("R1");
    Button r2 = new Button(c1, SWT.RADIO);
    r2.setText("R&2");
    Button r3 = new Button(c1, SWT.RADIO);
    r3.setText("R3");
    Button b2 = new Button(c1, SWT.PUSH);
    b2.setText("B2");
    List l1 = new List(c1, SWT.SINGLE | SWT.BORDER);
    l1.setItems("L1");
    Button b3 = new Button(c1, SWT.PUSH);
    b3.setText("B&3");
    Button b4 = new Button(c1, SWT.PUSH);
    b4.setText("B&4");

    Composite c2 = new Composite(shell, SWT.BORDER);
    c2.setLayout(new RowLayout());
    Button b5 = new Button(c2, SWT.PUSH);
    b5.setText("B&5");
    Button b6 = new Button(c2, SWT.PUSH);
    b6.setText("B&6");

    List l2 = new List(shell, SWT.SINGLE | SWT.BORDER);
    l2.setItems("L2");

    ToolBar tb1 = new ToolBar(shell, SWT.FLAT | SWT.BORDER);
    ToolItem i1 = new ToolItem(tb1, SWT.RADIO);
    i1.setText("I1");
    ToolItem i2 = new ToolItem(tb1, SWT.RADIO);
    i2.setText("I2");
    Combo combo1 = new Combo(tb1, SWT.READ_ONLY | SWT.BORDER);
    combo1.setItems("C1");
    combo1.setText("C1");
    combo1.pack();// w w  w . ja  va2  s .  c o  m
    ToolItem i3 = new ToolItem(tb1, SWT.SEPARATOR);
    i3.setWidth(combo1.getSize().x);
    i3.setControl(combo1);
    ToolItem i4 = new ToolItem(tb1, SWT.PUSH);
    i4.setText("I&4");
    ToolItem i5 = new ToolItem(tb1, SWT.CHECK);
    i5.setText("I5");

    Button b7 = new Button(shell, SWT.PUSH);
    b7.setText("B&7");

    Composite c4 = new Composite(shell, SWT.BORDER);
    Composite c5 = new Composite(c4, SWT.BORDER);
    c5.setLayout(new FillLayout());
    new Label(c5, SWT.NONE).setText("No");
    c5.pack();

    Control[] tabList1 = new Control[] { b2, b1, b3 };
    c1.setTabList(tabList1);
    Control[] tabList2 = new Control[] { c1, b7, tb1, c4, c2, l2 };
    shell.setTabList(tabList2);

    shell.pack();
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:Snippet75.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new RowLayout());

    Composite c1 = new Composite(shell, SWT.BORDER);
    c1.setLayout(new RowLayout());
    Button b1 = new Button(c1, SWT.PUSH);
    b1.setText("B1");
    Button[] radios = new Button[3];
    for (int i = 0; i < radios.length; i++) {
        radios[i] = new Button(c1, SWT.RADIO);
        radios[i].setText("R" + (i == 1 ? "&" : "") + i);
    }//from   w ww. j  a v a  2s. c o m
    Button b2 = new Button(c1, SWT.PUSH);
    b2.setText("B2");
    List l1 = new List(c1, SWT.SINGLE | SWT.BORDER);
    l1.setItems(new String[] { "L1" });
    Button b3 = new Button(c1, SWT.PUSH);
    b3.setText("B&3");
    Button b3_1 = new Button(c1, SWT.PUSH);
    b3_1.setText("B3_1");

    Composite c2 = new Composite(shell, SWT.BORDER);
    c2.setLayout(new RowLayout());
    Button b4 = new Button(c2, SWT.PUSH);
    b4.setText("B&4");
    Button b5 = new Button(c2, SWT.PUSH);
    b5.setText("B&5");

    List l2 = new List(shell, SWT.SINGLE | SWT.BORDER);
    l2.setItems(new String[] { "L2" });

    ToolBar tb1 = new ToolBar(shell, SWT.FLAT | SWT.BORDER);
    ToolItem i1 = new ToolItem(tb1, SWT.RADIO);
    i1.setText("I1");
    ToolItem i2 = new ToolItem(tb1, SWT.RADIO);
    i2.setText("I&2");
    Combo combo1 = new Combo(tb1, SWT.READ_ONLY | SWT.BORDER);
    combo1.setItems(new String[] { "C1" });
    combo1.setText("C1");
    combo1.pack();
    ToolItem i3 = new ToolItem(tb1, SWT.SEPARATOR);
    i3.setWidth(combo1.getSize().x);
    i3.setControl(combo1);
    i3.setText("I3");
    ToolItem i4 = new ToolItem(tb1, SWT.PUSH);
    i4.setText("I4");
    ToolItem i5 = new ToolItem(tb1, SWT.CHECK);
    i5.setText("I5");

    Button b6 = new Button(shell, SWT.PUSH);
    b6.setText("B&6");

    Composite c4 = new Composite(shell, SWT.BORDER);
    c4.setSize(32, 32);
    Composite c5 = new Composite(c4, SWT.BORDER);
    c5.setSize(20, 20);

    Control[] list1 = new Control[] { b2, b1, b3_1, b3 };
    c1.setTabList(list1);
    Control[] list2 = new Control[] { c1, b6, tb1, c4, c2, l2 };
    shell.setTabList(list2);

    shell.pack();
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:FocusTraversal.java

private void init() {
    shell.setLayout(new RowLayout());

    Composite composite1 = new Composite(shell, SWT.BORDER);
    composite1.setLayout(new RowLayout());
    composite1.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

    Button button1 = new Button(composite1, SWT.PUSH);
    button1.setText("Button1");

    List list = new List(composite1, SWT.MULTI | SWT.BORDER);
    list.setItems(new String[] { "Item-1", "Item-2", "Item-3" });

    Button radioButton1 = new Button(composite1, SWT.RADIO);
    radioButton1.setText("radio-1");
    Button radioButton2 = new Button(composite1, SWT.RADIO);
    radioButton2.setText("radio-2");

    Composite composite2 = new Composite(shell, SWT.BORDER);
    composite2.setLayout(new RowLayout());
    composite2.setBackground(display.getSystemColor(SWT.COLOR_GREEN));

    Button button2 = new Button(composite2, SWT.PUSH);
    button2.setText("Button2");

    final Canvas canvas = new Canvas(composite2, SWT.NULL);
    canvas.setSize(50, 50);/*w  w  w  .  ja  v a 2  s .c om*/
    canvas.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));

    Combo combo = new Combo(composite2, SWT.DROP_DOWN);
    combo.add("combo");
    combo.select(0);

    canvas.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            GC gc = new GC(canvas);
            // Erase background first. 
            Rectangle rect = canvas.getClientArea();
            gc.fillRectangle(rect.x, rect.y, rect.width, rect.height);

            Font font = new Font(display, "Arial", 32, SWT.BOLD);
            gc.setFont(font);

            gc.drawString("" + e.character, 15, 10);

            gc.dispose();
            font.dispose();
        }

        public void keyReleased(KeyEvent e) {
        }
    });

    canvas.addTraverseListener(new TraverseListener() {
        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS)
                e.doit = true;
        }
    });

    composite1.setTabList(new Control[] { button1, list });
    composite2.setTabList(new Control[] { button2, canvas, combo });

    shell.setTabList(new Control[] { composite2, composite1 });
}