62,614
社区成员
发帖
与我相关
我的任务
分享
import Core.Executer;
import Core.ExpressionView;//这个就是控制生成界面的类
class Expression extends Thread{
public static void main(String[] args){
final ExpressionViewer view=new ExpressionViewer();
view.createSShell
//下面加入了按钮事件,以及按钮事件的处理代码。没有其他东西了
}
}
package Core;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.custom.CLabel;
public class ExpressionViewer {
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="214,-5"
public Button button = null;
private Label label = null;
public Text text = null;
public Table table = null;
private CLabel cLabel = null;
public Label result = null;
/**
* This method initializes sShell
*
*/
public void createSShell() {
sShell = new Shell(SWT.BORDER | SWT.SHELL_TRIM);
sShell.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
sShell.setText("表达式分析");
sShell.setLayout(null);
sShell.setSize(new Point(564, 368));
button = new Button(sShell, SWT.UP);
button.setBounds(new Rectangle(284, 24, 107, 22));
button.setText("开始分析");
label = new Label(sShell, SWT.NONE);
label.setBounds(new Rectangle(33, 27, 66, 12));
label.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
label.setText("输入表达式");
text = new Text(sShell, SWT.BORDER);
text.setBounds(new Rectangle(102, 25, 157, 18));
table = new Table(sShell, SWT.BORDER);
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.setEnabled(false);
table.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_LIST_BACKGROUND));
table.setBounds(new Rectangle(15, 73, 521, 251));
TableColumn col1 = new TableColumn(table, SWT.LEFT);
col1.setText("步骤");
col1.setWidth(100);
TableColumn col2 = new TableColumn(table, SWT.LEFT);
col2.setText("栈");
col2.setWidth(100);
TableColumn col5 = new TableColumn(table, SWT.LEFT);
col5.setText("当前字符");
col5.setWidth(100);
TableColumn col3 = new TableColumn(table, SWT.LEFT);
col3.setText("剩余字符串");
col3.setWidth(100);
TableColumn col4 = new TableColumn(table, SWT.LEFT);
col4.setText("操作");
col4.setWidth(100);
cLabel = new CLabel(sShell, SWT.NONE);
cLabel.setText("分析结果:");
cLabel.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
cLabel.setBounds(new Rectangle(24, 51, 58, 23));
result = new Label(sShell, SWT.NONE);
result.setBounds(new Rectangle(94, 57, 112, 12));
result.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
result.setText("");
}
}