String sReturn = System.getProperty("line.separator");
String s = "abcd" + sReturn + "efg";

sReturn是换行符

 

 
  
  1. package test.ftp00;  
  2.  
  3. import org.eclipse.swt.SWT;  
  4. import org.eclipse.swt.graphics.Color;  
  5. import org.eclipse.swt.graphics.Rectangle;  
  6. import org.eclipse.swt.layout.FillLayout;  
  7. import org.eclipse.swt.layout.GridData;  
  8. import org.eclipse.swt.layout.GridLayout;  
  9. import org.eclipse.swt.widgets.Button;  
  10. import org.eclipse.swt.widgets.Composite;  
  11. import org.eclipse.swt.widgets.Display;  
  12. import org.eclipse.swt.widgets.Link;  
  13. import org.eclipse.swt.widgets.Monitor;  
  14. import org.eclipse.swt.widgets.Shell;  
  15.  
  16. public class LinkWindow {  
  17.     Display display;  
  18.     Shell shell;  
  19.     GridLayout gridLayout;  
  20.     GridData layoutData;  
  21.     Composite composite;  
  22.     static int height = 0;  
  23.     Color color;  
  24.     Link link;  
  25.  
  26.     public LinkWindow() {  
  27.  
  28.     }  
  29.  
  30.     public void showGui() {  
  31.         display = Display.getDefault();  
  32.         shell = new Shell(display);  
  33.         // 初始化shell  
  34.         initShell();  
  35.         composite = new Composite(shell, SWT.None);  
  36.         gridLayout = new GridLayout();  
  37.         composite.setLayout(gridLayout);  
  38.         color = display.getSystemColor(SWT.COLOR_WHITE);  
  39.         composite.setcolor);  
  40.  
  41.         Button button = new Button(composite, SWT.PUSH);  
  42.         button.setText("你好");  
  43.  
  44.         String sReturn = System.getProperty("line.separator");  
  45.         String s = "abcd" + sReturn + "efg";  
  46.         button.setToolTipText(s);  
  47.  
  48.         shell.open();  
  49.         while (!shell.isDisposed()) {  
  50.             if (!display.readAndDispatch())  
  51.                 display.sleep();  
  52.         }  
  53.     }  
  54.  
  55.     /**  
  56.      * 设置窗口的标题、位置、大小、图标  
  57.      *   
  58.      * @return Shell  
  59.      */  
  60.     public Shell initShell() {  
  61.         shell.setText("添加内容");  
  62.         shell.setSize(150, 200);  
  63.  
  64.         Monitor monitor = shell.getMonitor();  
  65.         Rectangle bounds = monitor.getBounds();  
  66.         Rectangle rect = shell.getBounds();  
  67.         int x = bounds.width - rect.width;  
  68.         int y = bounds.y;  
  69.  
  70.         shell.setLocation(x, y);  
  71.  
  72.         shell.setLayout(new FillLayout());  
  73.         return shell;  
  74.     }  
  75.  
  76.     public static void main(String[] args) {  
  77.  
  78.         new LinkWindow().showGui();  
  79.     }