Java Reference
In-Depth Information
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class NoJavaFXSceneInSWTExample {
public static void main(final String[] args) {
Model model = new Model();
View view = new View(model);
Controller controller = new Controller(model, view);
controller.mainLoop();
}
private static class Model {
public static final RGB LIGHT_GRAY = new RGB(0xd3, 0xd3, 0xd3);
public static final RGB GRAY = new RGB(0x80, 0x80, 0x80);
public static final RGB DARK_GRAY = new RGB(0xa9, 0xa9, 0xa9);
public static final RGB BLACK = new RGB(0x0, 0x0, 0x0);
public RGB fillColor = LIGHT_GRAY;
public RGB strokeColor = DARK_GRAY;
}
private static class View {
public Display display;
public Shell frame;
public Canvas canvas;
public Button changeFillButton;
public Button changeStrokeButton;
public Label mouseLocation;
public boolean mouseInCanvas;
private View(final Model model) {
this.display = new Display();
frame = new Shell(display);
frame.setText("No JavaFX in SWT Example");
RowLayout frameLayout = new RowLayout(SWT.VERTICAL);
frameLayout.spacing = 10;
frameLayout.center = true;
frame.setLayout(frameLayout);
Composite canvasPanel = new Composite(frame, SWT.NONE);
RowLayout canvasPanelLayout = new RowLayout(SWT.VERTICAL);
canvasPanelLayout.spacing = 10;
canvasPanel.setLayout(canvasPanelLayout);
Search WWH ::




Custom Search