eclipse便签代码
时间: 2023-12-07 17:04:22 浏览: 29
以下是Eclipse中创建便签代码的步骤:
1. 创建一个新的Java项目。
2. 在src文件夹中创建一个新的Java类。
3. 在Java类中添加以下代码:
```java
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class NotePad {
protected Shell shell;
private Text text;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
try {
NotePad window = new NotePad();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
/**
* Create contents of the window.
*/
protected void createContents() {
shell = new Shell();
shell.setSize(450, 300);
shell.setText("Notepad");
text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
text.setBounds(10, 10, 414, 242);
}
}
```
4. 运行程序,将会看到一个简单的便签应用程序。