button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { Button b = (Button) e.widget;
hideButton.addListener(SWT.Selection, new Listener()
Button btn = new Button(); btn.addListener(new ClickListener() { if (selectedVector != null) { VectorLayer vl = (VectorLayer) selectedVector.getParent(); vl.setSelectedVector(null); } });
Button btn = new Button(new SpriteDrawable(yourIdleSprite), new SpriteDrawable(yourPressedSprite)); btn.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { //your code } }); Stage stage= new Stage(); stage.addActor(btn);
private Label fieldLabel = new Label(shell, SWT.NONE); public void testMethod() { Button button = new Button(shell, SWT.PUSH); button.setText("Print"); final Label finalLabel = new Label(shell, SWT.NONE); button.addListener(SWT.Selection, new Listener(){ @Override public void handleEvent(Event e) { fieldLabel.setText("TEXT"); finalLabel.setTexT("TEXT"); } }) }
button.addListener(new Button.ClickListener(){ @Override public void buttonClick(ClickEvent event) {
final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("StackOverflow"); shell.setLayout(new GridLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("Open new Shell"); button.addListener(SWT.Selection, (event) -> { Shell child = new Shell(shell); child.setText("Child"); child.setVisible(true); child.setSize(300,200); }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose();
button.addListener(SWT.Selection, new Listener()
button.setText("Search"); button.addListener(SWT.Selection, new Listener()
public static void main( String[] args ) { String html = "<html><head></head><body>"; for( int i = 0; i < 100; i++ ) { html += "<h2 id=\"id" + i + "\">This is header " + i + "</h2>"; } html += "</body></html>"; Display display = new Display(); Shell shell = new Shell( display ); shell.setLayout( new GridLayout( 1, false ) ); Button button = new Button( shell, SWT.PUSH ); button.setText( "Focus header 17" ); Browser browser = new Browser( shell, SWT.BORDER ); browser.setText( html ); browser.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); button.addListener( SWT.Selection, new Listener() { @Override public void handleEvent( Event event ) { if( !browser.execute( "document.getElementById( 'id17' ).focus();" ) ) { throw new RuntimeException( "Failed to execute Javascript" ); } } } ); shell.open(); while( !shell.isDisposed() ) { if( !display.readAndDispatch() ) display.sleep(); } display.dispose(); }
public static void main( String[] args ) { Listener listener = new Listener() { @Override public void handleEvent( Event event ) { System.out.println( event ); } }; Display display = new Display(); Shell shell = new Shell( display ); shell.setText( "Shell" ); shell.addListener( SWT.MouseDown, listener ); Button button = new Button( shell, SWT.PUSH ); button.setText( "Button" ); button.setBounds( 100, 100, 400, 100 ); button.addListener( SWT.MouseDown, listener ); shell.setSize( 600, 600 ); shell.open(); while( !shell.isDisposed() ) { if( !display.readAndDispatch() ) display.sleep(); } display.dispose(); }
public class Page2 extends Composite { Button btnPage1; public Page2(Composite parent, int style) { super(parent, style); Label lblPage2 = new Label(this, SWT.NONE); lblPage2.setLocation(10, 10); lblPage2.setSize(80, 15); lblPage2.setText("I'm on Page 2"); btnPage1 = new Button(this, SWT.NONE); btnPage1.setLocation(10, 30); btnPage1.setSize(80, 25); btnPage1.setText("Go to Page 1"); } public void addLink(final Vector<Composite> pageVector) { btnPage1.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { App.stackLayout.topControl = pageVector.get(0); App.parent.layout(); } }); } }
left.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); left.addListener(SWT.Resize, new Listener()
public class Page1 extends Composite { Button btnPage2; public Page1(Composite parent, int style) { super(parent, style); Label lblPage1 = new Label(this, SWT.NONE); lblPage1.setLocation(10, 10); lblPage1.setSize(80, 15); lblPage1.setText("I'm on Page 1"); btnPage2 = new Button(this, SWT.NONE); btnPage2.setLocation(10, 30); btnPage2.setSize(80, 25); btnPage2.setText("Go to Page 2"); } public void addLink(final Vector<Composite> pageVector) { btnPage2.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { App.stackLayout.topControl = pageVector.get(1); App.parent.layout(); } }); } }
button.addListener(SWT.Selection, new Listener()
b.addListener(SWT.Selection, new Listener()
button.addListener(SWT.Selection, new Listener()
button.setText("Change cursor"); button.addListener(SWT.Selection, new Listener() {
b.setText("b"); a.addListener(SWT.Selection, new Listener()
TextField DBName; TextField DBUserName; TextField DBPassword; DBName = new TextField("Enter DB Name"); DBName.setColumns(20); DBUserName = new TextField("Enter UserName"); DBUserName.setColumns(20); DBPassword = new TextField("Enter Password"); DBPassword.setColumns(20); Button b = new Button("Connect"); b.setImmediate(true); b.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { // post form values using java url connection } })