<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FStackLayout</id>
		<title>Java Tutorial/SWT/StackLayout - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FStackLayout"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/StackLayout&amp;action=history"/>
		<updated>2026-04-10T22:40:51Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/StackLayout&amp;diff=3207&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/StackLayout&amp;diff=3207&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:44, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/StackLayout&amp;diff=3208&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/StackLayout&amp;diff=3208&amp;oldid=prev"/>
				<updated>2010-05-31T15:22:03Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Configure the margin: marginHeight and marginWidth ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/******************************************************************************&lt;br /&gt;
 * Copyright (c) 1998, 2004 Jackwind Li Guojie&lt;br /&gt;
 * All right reserved. &lt;br /&gt;
 * &lt;br /&gt;
 * Created on Jan 31, 2004 1:05:58 AM by JACK&lt;br /&gt;
 * $Id$&lt;br /&gt;
 * &lt;br /&gt;
 * visit: http://www.asprise.ru/swt&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.StackLayout;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&lt;br /&gt;
import org.eclipse.swt.events.SelectionListener;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class StackLayoutControlMargin {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    final StackLayout stackLayout = new StackLayout();&lt;br /&gt;
    stackLayout.marginHeight=20;&lt;br /&gt;
    stackLayout.marginWidth=20;&lt;br /&gt;
    shell.setLayout(stackLayout);&lt;br /&gt;
    final Button[] buttons = new Button[3];&lt;br /&gt;
    for (int i = 0; i &amp;lt; buttons.length; i++) {&lt;br /&gt;
      buttons[i] = new Button(shell, SWT.NULL);&lt;br /&gt;
      buttons[i].setText(&amp;quot;Button #&amp;quot; + i);&lt;br /&gt;
      buttons[i].addSelectionListener(new SelectionListener() {&lt;br /&gt;
        public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
          // Flip to next button.&lt;br /&gt;
          Button nextButton = null;&lt;br /&gt;
          for (int i = 0; i &amp;lt; buttons.length; i++) {&lt;br /&gt;
            if (buttons[i] == e.widget) {&lt;br /&gt;
              if (i == buttons.length - 1)&lt;br /&gt;
                nextButton = buttons[0];&lt;br /&gt;
              else&lt;br /&gt;
                nextButton = buttons[i + 1];&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
          stackLayout.topControl = nextButton;&lt;br /&gt;
          shell.layout();&lt;br /&gt;
        }&lt;br /&gt;
        public void widgetDefaultSelected(SelectionEvent e) {&lt;br /&gt;
        }&lt;br /&gt;
      });&lt;br /&gt;
    }&lt;br /&gt;
    stackLayout.topControl = buttons[0];&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Use a StackLayout to switch between Composites ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * StackLayout example snippet: use a StackLayout to switch between Composites.&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.StackLayout;&lt;br /&gt;
import org.eclipse.swt.layout.RowLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.ruposite;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class StackLayoutSwitchComposites {&lt;br /&gt;
  static int pageNum = -1;&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setBounds(10, 10, 300, 200);&lt;br /&gt;
    // create the composite that the pages will share&lt;br /&gt;
    final Composite contentPanel = new Composite(shell, SWT.BORDER);&lt;br /&gt;
    contentPanel.setBounds(100, 10, 190, 90);&lt;br /&gt;
    final StackLayout layout = new StackLayout();&lt;br /&gt;
    contentPanel.setLayout(layout);&lt;br /&gt;
    // create the first page&amp;quot;s content&lt;br /&gt;
    final Composite page0 = new Composite(contentPanel, SWT.NONE);&lt;br /&gt;
    page0.setLayout(new RowLayout());&lt;br /&gt;
    Label label = new Label(page0, SWT.NONE);&lt;br /&gt;
    label.setText(&amp;quot;Label on page 1&amp;quot;);&lt;br /&gt;
    label.pack();&lt;br /&gt;
    // create the second page&amp;quot;s content&lt;br /&gt;
    final Composite page1 = new Composite(contentPanel, SWT.NONE);&lt;br /&gt;
    page1.setLayout(new RowLayout());&lt;br /&gt;
    Button button = new Button(page1, SWT.NONE);&lt;br /&gt;
    button.setText(&amp;quot;Button on page 2&amp;quot;);&lt;br /&gt;
    button.pack();&lt;br /&gt;
    // create the button that will switch between the pages&lt;br /&gt;
    Button pageButton = new Button(shell, SWT.PUSH);&lt;br /&gt;
    pageButton.setText(&amp;quot;Push&amp;quot;);&lt;br /&gt;
    pageButton.setBounds(10, 10, 80, 25);&lt;br /&gt;
    pageButton.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        pageNum = ++pageNum % 2;&lt;br /&gt;
        layout.topControl = pageNum == 0 ? page0 : page1;&lt;br /&gt;
        contentPanel.layout();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Using StackLayout ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;All controls are the same size and are put in the same location.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;They&amp;quot;re all stacked atop each other.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;only the topmost control is visible.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.StackLayout;&lt;br /&gt;
import org.eclipse.swt.events.SelectionAdapter;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Control;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class StackLayoutTest {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    StackLayout layout = new StackLayout();&lt;br /&gt;
    shell.setLayout(layout);&lt;br /&gt;
    StackLayoutSelectionAdapter adapter = new StackLayoutSelectionAdapter(shell, layout);&lt;br /&gt;
    Button one = new Button(shell, SWT.PUSH);&lt;br /&gt;
    one.setText(&amp;quot;one&amp;quot;);&lt;br /&gt;
    one.addSelectionListener(adapter);&lt;br /&gt;
    Button two = new Button(shell, SWT.PUSH);&lt;br /&gt;
    two.setText(&amp;quot;two&amp;quot;);&lt;br /&gt;
    two.addSelectionListener(adapter);&lt;br /&gt;
    Button three = new Button(shell, SWT.PUSH);&lt;br /&gt;
    three.setText(&amp;quot;three&amp;quot;);&lt;br /&gt;
    three.addSelectionListener(adapter);&lt;br /&gt;
    layout.topControl = one;&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class StackLayoutSelectionAdapter extends SelectionAdapter {&lt;br /&gt;
  Shell shell;&lt;br /&gt;
  StackLayout layout;&lt;br /&gt;
  public StackLayoutSelectionAdapter(Shell shell, StackLayout layout) {&lt;br /&gt;
    this.shell = shell;&lt;br /&gt;
    this.layout = layout;&lt;br /&gt;
  }&lt;br /&gt;
  public void widgetSelected(SelectionEvent event) {&lt;br /&gt;
    Control control = layout.topControl;&lt;br /&gt;
    Control[] children = shell.getChildren();&lt;br /&gt;
    int i = 0;&lt;br /&gt;
    for (int n = children.length; i &amp;lt; n; i++) {&lt;br /&gt;
      Control child = children[i];&lt;br /&gt;
      if (child == control) {&lt;br /&gt;
        break;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    i = i+1;&lt;br /&gt;
    if (i &amp;gt;= children.length)&lt;br /&gt;
      i = 0;&lt;br /&gt;
    layout.topControl = children[i];&lt;br /&gt;
    shell.layout();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Using StackLayouts ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;To set a particular control on the top, you should first set the topControl field of the StackLayout with that control and then call the layout method of the parent composite.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.StackLayout;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&lt;br /&gt;
import org.eclipse.swt.events.SelectionListener;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class StackLayoutButtons {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    final StackLayout stackLayout = new StackLayout();&lt;br /&gt;
    shell.setLayout(stackLayout);&lt;br /&gt;
    final Button[] buttons = new Button[3];&lt;br /&gt;
    for (int i = 0; i &amp;lt; buttons.length; i++) {&lt;br /&gt;
      buttons[i] = new Button(shell, SWT.NULL);&lt;br /&gt;
      buttons[i].setText(&amp;quot;Button #&amp;quot; + i);&lt;br /&gt;
      buttons[i].addSelectionListener(new SelectionListener() {&lt;br /&gt;
        public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
          // Flip to next button.&lt;br /&gt;
          Button nextButton = null;&lt;br /&gt;
          for (int i = 0; i &amp;lt; buttons.length; i++) {&lt;br /&gt;
            if (buttons[i] == e.widget) {&lt;br /&gt;
              if (i == buttons.length - 1)&lt;br /&gt;
                nextButton = buttons[0];&lt;br /&gt;
              else&lt;br /&gt;
                nextButton = buttons[i + 1];&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
          stackLayout.topControl = nextButton;&lt;br /&gt;
          shell.layout();&lt;br /&gt;
        }&lt;br /&gt;
        public void widgetDefaultSelected(SelectionEvent e) {&lt;br /&gt;
        }&lt;br /&gt;
      });&lt;br /&gt;
    }&lt;br /&gt;
    stackLayout.topControl = buttons[0];&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>