Results 1 to 3 of 3
Thread: Question about buttons in SWT
- 04-17-2014, 09:47 PM #1
Member
- Join Date
- Apr 2014
- Posts
- 4
- Rep Power
- 0
Question about buttons in SWT
Hi.
I have a problem. I've created SWT button, and now i'm trying to understand how to change variable x by pressing on it.
My code is:
Java Code:public class Main{ public static void main(String[] args) { int x; Display display = new Display(); Shell shell = new Shell(display); Button button = new Button(shell, SWT.NONE); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { x = 1; System.out.println(x); } }); button.setBounds(69, 42, 75, 25); button.setText("123"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
- 04-17-2014, 10:38 PM #2
Re: Question about buttons in SWT
Move it outside of the method and make it static.
If you don't understand my response, don't ignore it, ask a question.
- 04-17-2014, 11:37 PM #3
Member
- Join Date
- Apr 2014
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Radio buttons to open list of more radio buttons
By mcconnelln89 in forum New To JavaReplies: 1Last Post: 11-16-2013, 03:31 AM -
Set Buttons on top of each other
By Taylor91 in forum AWT / SwingReplies: 4Last Post: 11-21-2012, 05:38 AM -
GUI buttons question...
By glenrowan in forum New To JavaReplies: 3Last Post: 01-18-2011, 06:23 PM -
Help with Buttons
By wld4ubabay in forum New To JavaReplies: 20Last Post: 05-17-2010, 09:13 AM
Bookmarks