Image Button : Button « SWT JFace Eclipse « Java






Image Button


/******************************************************************************
 * Copyright (c) 1998, 2004 Jackwind Li Guojie
 * All right reserved. 
 * 
 * Created on Jan 26, 2004 8:19:53 PM by JACK
 * $Id$
 * 
 * visit: http://www.asprise.com/swt
 *****************************************************************************/



import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class ImageButton {
  Display display = new Display();
  Shell shell = new Shell(display);
  Image image = new Image(display, "java2s.gif");
  
  public ImageButton() {
    //shell.setLayout(new RowLayout());
    
    Button button = new Button(shell, SWT.PUSH);
    button.setBounds(10, 10, 200, 200);
    
    button.setImage(image);
    button.setText("button");
    
    System.out.println(button.getImage());

    shell.pack();
    shell.open();
    //textUser.forceFocus();

    // Set up the event loop.
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        // If no more entries in event queue
        display.sleep();
      }
    }

    display.dispose();
  }

  private void init() {

  }

  public static void main(String[] args) {
    new ImageButton();
  }
}


           
       








Related examples in the same category

1.SWT ButtonSWT Button
2.SWT Button Example DemoSWT Button Example Demo
3.SWT Button ActionSWT Button Action
4.Icon SelectorIcon Selector
5.Default ButtonDefault Button
6.Button StylesButton Styles
7.Widget StylesWidget Styles
8.Demonstrates ButtonsDemonstrates Buttons
9.Button ExampleButton Example
10.Arrow Button ExampleArrow Button Example
11.Button Selection Event
12.Make a toggle button have radio behaviorMake a toggle button have radio behavior
13.Set the default buttonSet the default button