自己可以随便加些TextBox 什么的了。。
设置一下视图:
1.Window -> Show View -> Other 选 Java -> Java Beans
2.Window -> show View -> Other 选 General -> Properties
我设置好后的样子
这样设置完以后,就可以像 .net 那样调整控件的属性了
但调整之前,最好点一下Form ,Layout 调成Null ,要不然,控件是不能拖放的,也不能调大小
package xl.test;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.graphics.Rectangle;
public class first {
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="16,17"
private Button button = null;
private Menu menuBar = null;
private Text text = null;
/**
* This method initializes sShell
*/
public void createSShell() {
sShell = new Shell(SWT.SHELL_TRIM);
sShell.setText("XL");
sShell.setLayout(null);
sShell.setSize(new Point(584, 335));
menuBar = new Menu(sShell, SWT.BAR);
sShell.setMenuBar(menuBar);
text = new Text(sShell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.H_SCROLL);
text.setOrientation(50554600);
text.setToolTipText("Tips");
text.setEchoChar('d');
text.setText("t");
text.setBackground(new Color(Display.getCurrent(), 0, 255, 255));
text.setBounds(new Rectangle(3, 3, 526, 166));
text.setForeground(new Color(Display.getCurrent(), 255, 0, 0));
button = new Button(sShell, SWT.NONE);
button.setText("MyButton");
button.setBounds(new Rectangle(461, 249, 60, 22));
button.setForeground(new Color(Display.getCurrent(), 109, 148, 95));
button.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
System.out.println("mouseDown()"); // TODO Auto-generated Event stub mouseDown()
MessageDialog.openInformation(null, "Hello", "Hello World!");
}
});
}
public Shell getSShell() {
return sShell;
}
}
package xl.test;
import org.eclipse.swt.widgets.Display;
public class TestMain {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
first fst = new first();
Display display = new Display();
fst.createSShell();
fst.getSShell().open();
while (!fst.getSShell().isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
System.out.println("finishing...");
display.dispose();
}
}
如果你觉得好。就给我顶一个。。