• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SWT event handling

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a question about good design in SWT.

Given an ApplicationWindow that has two Components, X and Y:



I want to attach a listener to button_X that reacts to mouse clicks. I want to change the label of BOTH buttons, button_X and button_Y when button_X is clicked. To change the laben of button_X in reaction to the mouse click, it is clear that I need to do something like this:

button_X.addListener(SWT.MouseDown, new SimpleListener("Display mouse down Listener"));
addListener (int eventType, Listener handler)

button_X.addMouseListener(new MouseListener() {
public void mouseDown(MouseEvent e) {
button_X.setText("Mouse Button Down");
}
}

But how can I modify properties on button_Y at the same time? I could work with static methods to get a reference to the button, but is this really the way people do this? I suppose there is a more elegant and API conforming solution.


Thanks for any hints!
 
Peter Jersey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone? This ain't such a hard question, is it?
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We don't have that many SWT users anymore, I fear...
 
Peter Jersey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but why that? Have I missed the next big step after SWT/JFace?
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I honestly cannot tell you. All I know is that most threads here are about Swing problems.
 
reply
    Bookmark Topic Watch Topic
  • New Topic