Java Reference
In-Depth Information
Composite buttonPanel = new Composite(frame, SWT.NONE);
RowLayout buttonPanelLayout = new RowLayout(SWT.HORIZONTAL);
buttonPanelLayout.spacing = 10;
buttonPanelLayout.center = true;
buttonPanel.setLayout(buttonPanelLayout);
changeFillButton = new Button(buttonPanel, SWT.NONE);
changeFillButton.setText("Change Fill");
changeStrokeButton = new Button(buttonPanel, SWT.NONE);
changeStrokeButton.setText("Change Stroke");
mouseLocation = new Label(buttonPanel, SWT.NONE);
mouseLocation.setLayoutData(new RowData(50, 15));
frame.pack();
}
}
private static class Controller {
private View view;
private Controller(final Model model, final View view) {
this.view = view;
view.changeFillButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final Paint fillPaint = model.getFill();
if (fillPaint.equals(Color.LIGHTGRAY)) {
model.setFill(Color.GRAY);
} else {
model.setFill(Color.LIGHTGRAY);
}
}
});
view.changeStrokeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final Paint strokePaint = model.getStroke();
if (strokePaint.equals(Color.DARKGRAY)) {
model.setStroke(Color.BLACK);
} else {
model.setStroke(Color.DARKGRAY);
}
}
});
view.rectangle.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
view.mouseInCanvas = true;
}
});
Search WWH ::




Custom Search