SWT is an Eclipse project used for writing desktop programs.
There are multiple index models under SWT, among which the index model of the control is xworker.swt.Widgets. In addition to control model indexes, SWT also has layout model indexes, event type model indexes, and so on.
Take the control model as an example. The control model is generally used by container class controls, so container class controls will inherit xworker.swt.Widgets.
The code for the create() method of a typical SWT model is as follows, taking the create method of BlueButton in the video below as an example:
import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import xworker.swt.widgets.ControlCreator; //Create button object, parent is putted by parent model def button = new Button(parent, SWT.NONE); button.setBackground(button.getDisplay().getSystemColor(SWT.COLOR_BLUE)); //Apply control common features ControlCreator.init(button, self, actionContext); //Set button attributes with model button.setText(self.getMetadata().getLabel()); //Invoke children's create method, put button as parent actionContext.peek().put("parent", button); for(child : self.getChilds()){ child.doAction("create", actionContext); } //Put button to global context actionContext.g().put(self.getMetadata().getName(), button); //Return return button;
Copyright © 2007-2019 XWorker.org 版权所有 沪ICP备08000575号