<?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%2FSWT_JFace_Eclipse%2FScroll</id>
		<title>Java/SWT JFace Eclipse/Scroll - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSWT_JFace_Eclipse%2FScroll"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/SWT_JFace_Eclipse/Scroll&amp;action=history"/>
		<updated>2026-04-07T11:05:17Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/SWT_JFace_Eclipse/Scroll&amp;diff=5704&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/SWT_JFace_Eclipse/Scroll&amp;diff=5704&amp;oldid=prev"/>
				<updated>2010-06-01T05:57:02Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&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;Версия 05:57, 1 июня 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>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/SWT_JFace_Eclipse/Scroll&amp;diff=5703&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/SWT_JFace_Eclipse/Scroll&amp;diff=5703&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:43Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Create a ScrolledComposite with wrapping content ==&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;
/*&lt;br /&gt;
 * Create a ScrolledComposite with wrapping content.&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.ScrolledComposite;&lt;br /&gt;
import org.eclipse.swt.events.ControlAdapter;&lt;br /&gt;
import org.eclipse.swt.events.ControlEvent;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.layout.RowLayout;&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.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class Snippet166 {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Image image1 = display.getSystemImage(SWT.ICON_WORKING);&lt;br /&gt;
    Image image2 = display.getSystemImage(SWT.ICON_QUESTION);&lt;br /&gt;
    Image image3 = display.getSystemImage(SWT.ICON_ERROR);&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final ScrolledComposite scrollComposite = new ScrolledComposite(shell,&lt;br /&gt;
        SWT.V_SCROLL | SWT.BORDER);&lt;br /&gt;
    final Composite parent = new Composite(scrollComposite, SWT.NONE);&lt;br /&gt;
    for (int i = 0; i &amp;lt;= 50; i++) {&lt;br /&gt;
      Label label = new Label(parent, SWT.NONE);&lt;br /&gt;
      if (i % 3 == 0)&lt;br /&gt;
        label.setImage(image1);&lt;br /&gt;
      if (i % 3 == 1)&lt;br /&gt;
        label.setImage(image2);&lt;br /&gt;
      if (i % 3 == 2)&lt;br /&gt;
        label.setImage(image3);&lt;br /&gt;
    }&lt;br /&gt;
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);&lt;br /&gt;
    layout.wrap = true;&lt;br /&gt;
    parent.setLayout(layout);&lt;br /&gt;
    scrollComposite.setContent(parent);&lt;br /&gt;
    scrollComposite.setExpandVertical(true);&lt;br /&gt;
    scrollComposite.setExpandHorizontal(true);&lt;br /&gt;
    scrollComposite.addControlListener(new ControlAdapter() {&lt;br /&gt;
      public void controlResized(ControlEvent e) {&lt;br /&gt;
        Rectangle r = scrollComposite.getClientArea();&lt;br /&gt;
        scrollComposite.setMinSize(parent.ruputeSize(r.width,&lt;br /&gt;
            SWT.DEFAULT));&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;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&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;
== Create two ScrolledComposites that scroll in tandem ==&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;
/*&lt;br /&gt;
 * Create two ScrolledComposites that scroll in tandem.&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.ScrolledComposite;&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.events.SelectionListener;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&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.ScrollBar;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class Snippet167 {&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.setLayout(new FillLayout());&lt;br /&gt;
    final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.BORDER&lt;br /&gt;
        | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    Button button1 = new Button(sc1, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;Button 1&amp;quot;);&lt;br /&gt;
    button1.setSize(400, 300);&lt;br /&gt;
    sc1.setContent(button1);&lt;br /&gt;
    final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.BORDER&lt;br /&gt;
        | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    Button button2 = new Button(sc2, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;Button 2&amp;quot;);&lt;br /&gt;
    button2.setSize(300, 400);&lt;br /&gt;
    sc2.setContent(button2);&lt;br /&gt;
    final ScrollBar vBar1 = sc1.getVerticalBar();&lt;br /&gt;
    final ScrollBar vBar2 = sc2.getVerticalBar();&lt;br /&gt;
    final ScrollBar hBar1 = sc1.getHorizontalBar();&lt;br /&gt;
    final ScrollBar hBar2 = sc2.getHorizontalBar();&lt;br /&gt;
    SelectionListener listener1 = new SelectionAdapter() {&lt;br /&gt;
      public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
        int x = hBar1.getSelection()&lt;br /&gt;
            * (hBar2.getMaximum() - hBar2.getThumb())&lt;br /&gt;
            / Math.max(1, hBar1.getMaximum() - hBar1.getThumb());&lt;br /&gt;
        int y = vBar1.getSelection()&lt;br /&gt;
            * (vBar2.getMaximum() - vBar2.getThumb())&lt;br /&gt;
            / Math.max(1, vBar1.getMaximum() - vBar1.getThumb());&lt;br /&gt;
        sc2.setOrigin(x, y);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    SelectionListener listener2 = new SelectionAdapter() {&lt;br /&gt;
      public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
        int x = hBar2.getSelection()&lt;br /&gt;
            * (hBar1.getMaximum() - hBar1.getThumb())&lt;br /&gt;
            / Math.max(1, hBar2.getMaximum() - hBar2.getThumb());&lt;br /&gt;
        int y = vBar2.getSelection()&lt;br /&gt;
            * (vBar1.getMaximum() - vBar1.getThumb())&lt;br /&gt;
            / Math.max(1, vBar2.getMaximum() - vBar2.getThumb());&lt;br /&gt;
        sc1.setOrigin(x, y);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    vBar1.addSelectionListener(listener1);&lt;br /&gt;
    hBar1.addSelectionListener(listener1);&lt;br /&gt;
    vBar2.addSelectionListener(listener2);&lt;br /&gt;
    hBar2.addSelectionListener(listener2);&lt;br /&gt;
    shell.setSize(400, 300);&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;
}&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;
== Demonstrates ScrolledComposite ==&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;
//Send questions, comments, bug reports, etc. to the authors:&lt;br /&gt;
//Rob Warner (rwarner@interspatial.ru)&lt;br /&gt;
//Robert Harris (rbrt_harris@yahoo.ru)&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.*;&lt;br /&gt;
import org.eclipse.swt.layout.*;&lt;br /&gt;
import org.eclipse.swt.widgets.*;&lt;br /&gt;
/**&lt;br /&gt;
 * This class demonstrates ScrolledComposite&lt;br /&gt;
 */&lt;br /&gt;
public class ScrolledCompositeTest {&lt;br /&gt;
  public void run() {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    createContents(shell);&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;
  private void createContents(Composite parent) {&lt;br /&gt;
    parent.setLayout(new FillLayout());&lt;br /&gt;
    // Create the ScrolledComposite to scroll horizontally and vertically&lt;br /&gt;
    ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL&lt;br /&gt;
        | SWT.V_SCROLL);&lt;br /&gt;
    // Create a child composite to hold the controls&lt;br /&gt;
    Composite child = new Composite(sc, SWT.NONE);&lt;br /&gt;
    child.setLayout(new FillLayout());&lt;br /&gt;
    // Create the buttons&lt;br /&gt;
    new Button(child, SWT.PUSH).setText(&amp;quot;One&amp;quot;);&lt;br /&gt;
    new Button(child, SWT.PUSH).setText(&amp;quot;Two&amp;quot;);&lt;br /&gt;
    /*&lt;br /&gt;
     * // Set the absolute size of the child child.setSize(400, 400);&lt;br /&gt;
     */&lt;br /&gt;
    // Set the child as the scrolled content of the ScrolledComposite&lt;br /&gt;
    sc.setContent(child);&lt;br /&gt;
    // Set the minimum size&lt;br /&gt;
    sc.setMinSize(400, 400);&lt;br /&gt;
    // Expand both horizontally and vertically&lt;br /&gt;
    sc.setExpandHorizontal(true);&lt;br /&gt;
    sc.setExpandVertical(true);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    new ScrolledCompositeTest().run();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&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;
== Scroll a child control automatically ==&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;
/*&lt;br /&gt;
 * Composite example snippet: scroll a child control automatically&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&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.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.ScrollBar;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class Snippet9 {&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, SWT.SHELL_TRIM | SWT.H_SCROLL&lt;br /&gt;
        | SWT.V_SCROLL);&lt;br /&gt;
    final Composite composite = new Composite(shell, SWT.BORDER);&lt;br /&gt;
    composite.setSize(200, 400);&lt;br /&gt;
    final ScrollBar hBar = shell.getHorizontalBar();&lt;br /&gt;
    hBar.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        Point location = composite.getLocation();&lt;br /&gt;
        location.x = -hBar.getSelection();&lt;br /&gt;
        composite.setLocation(location);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    final ScrollBar vBar = shell.getVerticalBar();&lt;br /&gt;
    vBar.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        Point location = composite.getLocation();&lt;br /&gt;
        location.y = -vBar.getSelection();&lt;br /&gt;
        composite.setLocation(location);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.addListener(SWT.Resize, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        Point size = composite.getSize();&lt;br /&gt;
        Rectangle rect = shell.getClientArea();&lt;br /&gt;
        hBar.setMaximum(size.x);&lt;br /&gt;
        vBar.setMaximum(size.y);&lt;br /&gt;
        hBar.setThumb(Math.min(size.x, rect.width));&lt;br /&gt;
        vBar.setThumb(Math.min(size.y, rect.height));&lt;br /&gt;
        int hPage = size.x - rect.width;&lt;br /&gt;
        int vPage = size.y - rect.height;&lt;br /&gt;
        int hSelection = hBar.getSelection();&lt;br /&gt;
        int vSelection = vBar.getSelection();&lt;br /&gt;
        Point location = composite.getLocation();&lt;br /&gt;
        if (hSelection &amp;gt;= hPage) {&lt;br /&gt;
          if (hPage &amp;lt;= 0)&lt;br /&gt;
            hSelection = 0;&lt;br /&gt;
          location.x = -hSelection;&lt;br /&gt;
        }&lt;br /&gt;
        if (vSelection &amp;gt;= vPage) {&lt;br /&gt;
          if (vPage &amp;lt;= 0)&lt;br /&gt;
            vSelection = 0;&lt;br /&gt;
          location.y = -vSelection;&lt;br /&gt;
        }&lt;br /&gt;
        composite.setLocation(location);&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;
}&lt;br /&gt;
&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;
== Scroll a control in a scrolled composite ==&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;
/*&lt;br /&gt;
 * ScrolledComposite example snippet: scroll a control in a scrolled composite&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.ScrolledComposite;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&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 Snippet5 {&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.setLayout(new FillLayout());&lt;br /&gt;
    // this button is always 400 x 400. Scrollbars appear if the window is&lt;br /&gt;
    // resized to be&lt;br /&gt;
    // too small to show part of the button&lt;br /&gt;
    ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER&lt;br /&gt;
        | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    Button b1 = new Button(c1, SWT.PUSH);&lt;br /&gt;
    b1.setText(&amp;quot;fixed size button&amp;quot;);&lt;br /&gt;
    b1.setSize(400, 400);&lt;br /&gt;
    c1.setContent(b1);&lt;br /&gt;
    // this button has a minimum size of 400 x 400. If the window is resized&lt;br /&gt;
    // to be big&lt;br /&gt;
    // enough to show more than 400 x 400, the button will grow in size. If&lt;br /&gt;
    // the window&lt;br /&gt;
    // is made too small to show 400 x 400, scrollbars will appear.&lt;br /&gt;
    ScrolledComposite c2 = new ScrolledComposite(shell, SWT.BORDER&lt;br /&gt;
        | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    Button b2 = new Button(c2, SWT.PUSH);&lt;br /&gt;
    b2.setText(&amp;quot;expanding button&amp;quot;);&lt;br /&gt;
    c2.setContent(b2);&lt;br /&gt;
    c2.setExpandHorizontal(true);&lt;br /&gt;
    c2.setExpandVertical(true);&lt;br /&gt;
    c2.setMinWidth(400);&lt;br /&gt;
    c2.setMinHeight(400);&lt;br /&gt;
    shell.setSize(600, 300);&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;
}&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;
== scroll an image (flicker free, no double buffering) ==&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;
/*&lt;br /&gt;
 * Canvas example snippet: scroll an image (flicker free, no double buffering)&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.GC;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&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.FileDialog;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.ScrollBar;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class Snippet48 {&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, SWT.SHELL_TRIM&lt;br /&gt;
        | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL&lt;br /&gt;
        | SWT.H_SCROLL);&lt;br /&gt;
    Image originalImage = null;&lt;br /&gt;
    FileDialog dialog = new FileDialog(shell, SWT.OPEN);&lt;br /&gt;
    dialog.setText(&amp;quot;Open an image file or cancel&amp;quot;);&lt;br /&gt;
    String string = dialog.open();&lt;br /&gt;
    if (string != null) {&lt;br /&gt;
      originalImage = new Image(display, string);&lt;br /&gt;
    }&lt;br /&gt;
    if (originalImage == null) {&lt;br /&gt;
      int width = 150, height = 200;&lt;br /&gt;
      originalImage = new Image(display, width, height);&lt;br /&gt;
      GC gc = new GC(originalImage);&lt;br /&gt;
      gc.fillRectangle(0, 0, width, height);&lt;br /&gt;
      gc.drawLine(0, 0, width, height);&lt;br /&gt;
      gc.drawLine(0, height, width, 0);&lt;br /&gt;
      gc.drawText(&amp;quot;Default Image&amp;quot;, 10, 10);&lt;br /&gt;
      gc.dispose();&lt;br /&gt;
    }&lt;br /&gt;
    final Image image = originalImage;&lt;br /&gt;
    final Point origin = new Point(0, 0);&lt;br /&gt;
    final ScrollBar hBar = shell.getHorizontalBar();&lt;br /&gt;
    hBar.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        int hSelection = hBar.getSelection();&lt;br /&gt;
        int destX = -hSelection - origin.x;&lt;br /&gt;
        Rectangle rect = image.getBounds();&lt;br /&gt;
        shell.scroll(destX, 0, 0, 0, rect.width, rect.height, false);&lt;br /&gt;
        origin.x = -hSelection;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    final ScrollBar vBar = shell.getVerticalBar();&lt;br /&gt;
    vBar.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        int vSelection = vBar.getSelection();&lt;br /&gt;
        int destY = -vSelection - origin.y;&lt;br /&gt;
        Rectangle rect = image.getBounds();&lt;br /&gt;
        shell.scroll(0, destY, 0, 0, rect.width, rect.height, false);&lt;br /&gt;
        origin.y = -vSelection;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.addListener(SWT.Resize, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        Rectangle rect = image.getBounds();&lt;br /&gt;
        Rectangle client = shell.getClientArea();&lt;br /&gt;
        hBar.setMaximum(rect.width);&lt;br /&gt;
        vBar.setMaximum(rect.height);&lt;br /&gt;
        hBar.setThumb(Math.min(rect.width, client.width));&lt;br /&gt;
        vBar.setThumb(Math.min(rect.height, client.height));&lt;br /&gt;
        int hPage = rect.width - client.width;&lt;br /&gt;
        int vPage = rect.height - client.height;&lt;br /&gt;
        int hSelection = hBar.getSelection();&lt;br /&gt;
        int vSelection = vBar.getSelection();&lt;br /&gt;
        if (hSelection &amp;gt;= hPage) {&lt;br /&gt;
          if (hPage &amp;lt;= 0)&lt;br /&gt;
            hSelection = 0;&lt;br /&gt;
          origin.x = -hSelection;&lt;br /&gt;
        }&lt;br /&gt;
        if (vSelection &amp;gt;= vPage) {&lt;br /&gt;
          if (vPage &amp;lt;= 0)&lt;br /&gt;
            vSelection = 0;&lt;br /&gt;
          origin.y = -vSelection;&lt;br /&gt;
        }&lt;br /&gt;
        shell.redraw();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.addListener(SWT.Paint, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        GC gc = e.gc;&lt;br /&gt;
        gc.drawImage(image, origin.x, origin.y);&lt;br /&gt;
        Rectangle rect = image.getBounds();&lt;br /&gt;
        Rectangle client = shell.getClientArea();&lt;br /&gt;
        int marginWidth = client.width - rect.width;&lt;br /&gt;
        if (marginWidth &amp;gt; 0) {&lt;br /&gt;
          gc.fillRectangle(rect.width, 0, marginWidth, client.height);&lt;br /&gt;
        }&lt;br /&gt;
        int marginHeight = client.height - rect.height;&lt;br /&gt;
        if (marginHeight &amp;gt; 0) {&lt;br /&gt;
          gc&lt;br /&gt;
              .fillRectangle(0, rect.height, client.width,&lt;br /&gt;
                  marginHeight);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.setSize(200, 150);&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;
}&lt;br /&gt;
&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;
== Scroll SWT widgets into view when they get focus ==&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;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.custom.ScrolledComposite;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.layout.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&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.Control;&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.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
/*&lt;br /&gt;
 * Scroll widgets into view when they get focus&lt;br /&gt;
 * &lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets&lt;br /&gt;
 */&lt;br /&gt;
public class Snippet188 {&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.setLayout(new GridLayout());&lt;br /&gt;
    Button b1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    b1.setText(&amp;quot;top&amp;quot;);&lt;br /&gt;
    b1&lt;br /&gt;
        .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false,&lt;br /&gt;
            1, 1));&lt;br /&gt;
    final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER&lt;br /&gt;
        | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));&lt;br /&gt;
    Composite c = new Composite(sc, SWT.NONE);&lt;br /&gt;
    c.setLayout(new GridLayout(10, true));&lt;br /&gt;
    for (int i = 0; i &amp;lt; 300; i++) {&lt;br /&gt;
      Button b = new Button(c, SWT.PUSH);&lt;br /&gt;
      b.setText(&amp;quot;Button &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    Button b2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    b2.setText(&amp;quot;bottom&amp;quot;);&lt;br /&gt;
    b2&lt;br /&gt;
        .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false,&lt;br /&gt;
            1, 1));&lt;br /&gt;
    sc.setContent(c);&lt;br /&gt;
    sc.setExpandHorizontal(true);&lt;br /&gt;
    sc.setExpandVertical(true);&lt;br /&gt;
    sc.setMinSize(c.ruputeSize(SWT.DEFAULT, SWT.DEFAULT));&lt;br /&gt;
    Listener listener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        Control child = (Control) e.widget;&lt;br /&gt;
        Rectangle bounds = child.getBounds();&lt;br /&gt;
        Rectangle area = sc.getClientArea();&lt;br /&gt;
        Point origin = sc.getOrigin();&lt;br /&gt;
        if (origin.x &amp;gt; bounds.x)&lt;br /&gt;
          origin.x = Math.max(0, bounds.x);&lt;br /&gt;
        if (origin.y &amp;gt; bounds.y)&lt;br /&gt;
          origin.y = Math.max(0, bounds.y);&lt;br /&gt;
        if (origin.x + area.width &amp;lt; bounds.x + bounds.width)&lt;br /&gt;
          origin.x = Math&lt;br /&gt;
              .max(0, bounds.x + bounds.width - area.width);&lt;br /&gt;
        if (origin.y + area.height &amp;lt; bounds.y + bounds.height)&lt;br /&gt;
          origin.y = Math.max(0, bounds.y + bounds.height&lt;br /&gt;
              - area.height);&lt;br /&gt;
        sc.setOrigin(origin);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    Control[] controls = c.getChildren();&lt;br /&gt;
    for (int i = 0; i &amp;lt; controls.length; i++) {&lt;br /&gt;
      controls[i].addListener(SWT.Activate, listener);&lt;br /&gt;
    }&lt;br /&gt;
    shell.setSize(300, 500);&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;
}&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>
			</entry>

	</feed>