⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swingawtclass.java

📁 eclipse cookbook the source code of the book
💻 JAVA
字号:
package org.cookbook.ch09;

import java.awt.event.*;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.awt.SWT_AWT;

public class SwingAWTClass {

	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setText("Using Swing and AWT");
		shell.setSize(350, 280);
		
		Composite composite = new Composite(shell, SWT.EMBEDDED);
		composite.setBounds(20, 20, 300, 200);
		composite.setLayout(new RowLayout());

		java.awt.Frame frame = SWT_AWT.new_Frame(composite);
		java.awt.Panel panel = new java.awt.Panel();
		frame.add(panel);

	    final javax.swing.JButton button = new javax.swing.JButton("Click Me");
	    final javax.swing.JTextField text = new javax.swing.JTextField(20);

	    panel.add(button);
	    panel.add(text);

		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				text.setText("Yep, it works.");
			}
		});
	    
		shell.open();
		while(!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -