String sReturn = System.getProperty("line.separator");
String s = "abcd" + sReturn + "efg";sReturn是换行符
- package test.ftp00;
- import org.eclipse.swt.SWT;
- import org.eclipse.swt.graphics.Color;
- import org.eclipse.swt.graphics.Rectangle;
- import org.eclipse.swt.layout.FillLayout;
- import org.eclipse.swt.layout.GridData;
- import org.eclipse.swt.layout.GridLayout;
- import org.eclipse.swt.widgets.Button;
- import org.eclipse.swt.widgets.Composite;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.Link;
- import org.eclipse.swt.widgets.Monitor;
- import org.eclipse.swt.widgets.Shell;
- public class LinkWindow {
- Display display;
- Shell shell;
- GridLayout gridLayout;
- GridData layoutData;
- Composite composite;
- static int height = 0;
- Color color;
- Link link;
- public LinkWindow() {
- }
- public void showGui() {
- display = Display.getDefault();
- shell = new Shell(display);
- // 初始化shell
- initShell();
- composite = new Composite(shell, SWT.None);
- gridLayout = new GridLayout();
- composite.setLayout(gridLayout);
- color = display.getSystemColor(SWT.COLOR_WHITE);
- composite.setcolor);
- Button button = new Button(composite, SWT.PUSH);
- button.setText("你好");
- String sReturn = System.getProperty("line.separator");
- String s = "abcd" + sReturn + "efg";
- button.setToolTipText(s);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- }
- /**
- * 设置窗口的标题、位置、大小、图标
- *
- * @return Shell
- */
- public Shell initShell() {
- shell.setText("添加内容");
- shell.setSize(150, 200);
- Monitor monitor = shell.getMonitor();
- Rectangle bounds = monitor.getBounds();
- Rectangle rect = shell.getBounds();
- int x = bounds.width - rect.width;
- int y = bounds.y;
- shell.setLocation(x, y);
- shell.setLayout(new FillLayout());
- return shell;
- }
- public static void main(String[] args) {
- new LinkWindow().showGui();
- }
- }