• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SWT event handling

 
Peter Jersey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Anyone? This ain't such a hard question, is it?
 
Rob Spoor
Sheriff
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
but why that? Have I missed the next big step after SWT/JFace?
 
Rob Spoor
Sheriff
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I honestly cannot tell you. All I know is that most threads here are about Swing problems.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic