import org.eclipse.swt.widgets.*; public class SWTHelloWorld { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Hello World!"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } |
import javax.swing.JFrame; public class SwingHelloWorld { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("Hello World!"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setSize(400, 400); frame.setVisible(true); } } |
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.ToolItem; import org.eclipse.swt.SWT; public class NewToolBar extends org.eclipse.swt.widgets.ToolBar { public static void main(String[] args) { try { Display display = Display.getDefault(); Shell shell = new Shell(display); new NewToolBar(shell, SWT.NULL); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } } public NewToolBar(Shell parent, int style) { super(parent, style); new ToolItem(this, SWT.NULL); } } |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |