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

📄 tab.java

📁 SUN公司eclipse3.2.2经典例子
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		otherGroup = new Group (controlGroup, SWT.NONE);		otherGroup.setLayout (new GridLayout ());		otherGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false));		otherGroup.setText (ControlExample.getResourceString("Other"));			/* Create the controls */		enabledButton = new Button(otherGroup, SWT.CHECK);		enabledButton.setText(ControlExample.getResourceString("Enabled"));		visibleButton = new Button(otherGroup, SWT.CHECK);		visibleButton.setText(ControlExample.getResourceString("Visible"));		backgroundImageButton = new Button(otherGroup, SWT.CHECK);		backgroundImageButton.setText(ControlExample.getResourceString("BackgroundImage"));		popupMenuButton = new Button(otherGroup, SWT.CHECK);		popupMenuButton.setText(ControlExample.getResourceString("PopupMenu"));				/* Add the listeners */		enabledButton.addSelectionListener (new SelectionAdapter () {			public void widgetSelected (SelectionEvent event) {				setExampleWidgetEnabled ();			}		});		visibleButton.addSelectionListener (new SelectionAdapter () {			public void widgetSelected (SelectionEvent event) {				setExampleWidgetVisibility ();			}		});		backgroundImageButton.addSelectionListener (new SelectionAdapter () {			public void widgetSelected (SelectionEvent event) {				setExampleWidgetBackgroundImage ();			}		});		popupMenuButton.addSelectionListener (new SelectionAdapter () {			public void widgetSelected (SelectionEvent event) {				setExampleWidgetPopupMenu ();			}		});			/* Set the default state */		enabledButton.setSelection(true);		visibleButton.setSelection(true);		backgroundImageButton.setSelection(false);		popupMenuButton.setSelection(false);	}		/**	 * Creates the "Background Mode" group.	 */	void createBackgroundModeGroup () {		// note that this method must be called after createExampleWidgets		if (getExampleControls ().length == 0) return;				/* Create the group */		backgroundModeGroup = new Group (controlGroup, SWT.NONE);		backgroundModeGroup.setLayout (new GridLayout ());		backgroundModeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false));		backgroundModeGroup.setText (ControlExample.getResourceString("Background_Mode"));			/* Create the controls */		backgroundModeCombo = new Combo(backgroundModeGroup, SWT.READ_ONLY);		backgroundModeCombo.setItems(new String[] {"SWT.INHERIT_NONE", "SWT.INHERIT_DEFAULT", "SWT.INHERIT_FORCE"});		backgroundModeImageButton = new Button(backgroundModeGroup, SWT.CHECK);		backgroundModeImageButton.setText(ControlExample.getResourceString("BackgroundImage"));		backgroundModeColorButton = new Button(backgroundModeGroup, SWT.CHECK);		backgroundModeColorButton.setText(ControlExample.getResourceString("BackgroundColor"));			/* Add the listeners */		backgroundModeCombo.addSelectionListener (new SelectionAdapter () {			public void widgetSelected (SelectionEvent event) {				setExampleGroupBackgroundMode ();			}		});		backgroundModeImageButton.addSelectionListener (new SelectionAdapter () {			public void widgetSelected (SelectionEvent event) {				setExampleGroupBackgroundImage ();			}		});		backgroundModeColorButton.addSelectionListener (new SelectionAdapter () {			public void widgetSelected (SelectionEvent event) {				setExampleGroupBackgroundColor ();			}		});			/* Set the default state */		backgroundModeCombo.setText(backgroundModeCombo.getItem(0));		backgroundModeImageButton.setSelection(false);		backgroundModeColorButton.setSelection(false);	}		/**	 * Create the event console popup menu.	 */	void createEventConsolePopup () {		Menu popup = new Menu (shell, SWT.POP_UP);		eventConsole.setMenu (popup);		MenuItem cut = new MenuItem (popup, SWT.PUSH);		cut.setText (ControlExample.getResourceString("MenuItem_Cut"));		cut.addListener (SWT.Selection, new Listener () {			public void handleEvent (Event event) {				eventConsole.cut ();			}		});		MenuItem copy = new MenuItem (popup, SWT.PUSH);		copy.setText (ControlExample.getResourceString("MenuItem_Copy"));		copy.addListener (SWT.Selection, new Listener () {			public void handleEvent (Event event) {				eventConsole.copy ();			}		});		MenuItem paste = new MenuItem (popup, SWT.PUSH);		paste.setText (ControlExample.getResourceString("MenuItem_Paste"));		paste.addListener (SWT.Selection, new Listener () {			public void handleEvent (Event event) {				eventConsole.paste ();			}		});		new MenuItem (popup, SWT.SEPARATOR);		MenuItem selectAll = new MenuItem (popup, SWT.PUSH);		selectAll.setText(ControlExample.getResourceString("MenuItem_SelectAll"));		selectAll.addListener (SWT.Selection, new Listener () {			public void handleEvent (Event event) {				eventConsole.selectAll ();			}		});	}	/**	 * Creates the "Example" group.  The "Example" group	 * is typically the left hand column in the tab.	 */	void createExampleGroup () {		exampleGroup = new Group (tabFolderPage, SWT.NONE);		exampleGroup.setLayout (new GridLayout ());		exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true));	}		/**	 * Creates the "Example" widget children of the "Example" group.	 * Subclasses override this method to create the particular	 * example control.	 */	void createExampleWidgets () {		/* Do nothing */	}		/**	 * Creates and opens the "Listener selection" dialog.	 */	void createListenerSelectionDialog () {		final Shell dialog = new Shell (shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);		dialog.setText (ControlExample.getResourceString ("Select_Listeners"));		dialog.setLayout (new GridLayout (2, false));		final Table table = new Table (dialog, SWT.BORDER | SWT.V_SCROLL | SWT.CHECK);		GridData data = new GridData(GridData.FILL_BOTH);		data.verticalSpan = 2;		table.setLayoutData(data);		for (int i = 0; i < EVENT_NAMES.length; i++) {			TableItem item = new TableItem (table, SWT.NONE);			item.setText ((String)EVENT_NAMES[i][0]);			item.setChecked (eventsFilter[i]);		}		final String [] customNames = getCustomEventNames ();		for (int i = 0; i < customNames.length; i++) {			TableItem item = new TableItem (table, SWT.NONE);			item.setText (customNames[i]);			item.setChecked (eventsFilter[EVENT_NAMES.length + i]);		}		Button selectAll = new Button (dialog, SWT.PUSH);		selectAll.setText(ControlExample.getResourceString ("Select_All"));		selectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));		selectAll.addSelectionListener (new SelectionAdapter() {			public void widgetSelected(SelectionEvent e) {				TableItem [] items = table.getItems();				for (int i = 0; i < EVENT_NAMES.length; i++) {					items[i].setChecked(true);				}				for (int i = 0; i < customNames.length; i++) {					items[EVENT_NAMES.length + i].setChecked(true);				}			}		});		Button deselectAll = new Button (dialog, SWT.PUSH);		deselectAll.setText(ControlExample.getResourceString ("Deselect_All"));		deselectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));		deselectAll.addSelectionListener (new SelectionAdapter() {			public void widgetSelected(SelectionEvent e) {				TableItem [] items = table.getItems();				for (int i = 0; i < EVENT_NAMES.length; i++) {					items[i].setChecked(false);				}				for (int i = 0; i < customNames.length; i++) {					items[EVENT_NAMES.length + i].setChecked(false);				}			}		});		new Label(dialog, SWT.NONE); /* Filler */		Button ok = new Button (dialog, SWT.PUSH);		ok.setText(ControlExample.getResourceString ("OK"));		dialog.setDefaultButton(ok);		ok.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));		ok.addSelectionListener (new SelectionAdapter() {			public void widgetSelected(SelectionEvent e) {				TableItem [] items = table.getItems();				for (int i = 0; i < EVENT_NAMES.length; i++) {					eventsFilter[i] = items[i].getChecked();				}				for (int i = 0; i < customNames.length; i++) {					eventsFilter[EVENT_NAMES.length + i] = items[EVENT_NAMES.length + i].getChecked();				}				dialog.dispose();			}		});		dialog.pack ();		dialog.open ();		while (! dialog.isDisposed()) {			if (! display.readAndDispatch()) display.sleep();		}	}	/**	 * Creates the "Listeners" group.  The "Listeners" group	 * goes below the "Example" and "Control" groups.	 */	void createListenersGroup () {		listenersGroup = new Group (tabFolderPage, SWT.NONE);		listenersGroup.setLayout (new GridLayout (3, false));		listenersGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true, 2, 1));		listenersGroup.setText (ControlExample.getResourceString ("Listeners"));		/*		 * Create the button to access the 'Listeners' dialog.		 */		Button listenersButton = new Button (listenersGroup, SWT.PUSH);		listenersButton.setText (ControlExample.getResourceString ("Select_Listeners"));		listenersButton.addSelectionListener (new SelectionAdapter() {			public void widgetSelected (SelectionEvent e) {				createListenerSelectionDialog ();				recreateExampleWidgets ();			}		});				/*		 * Create the checkbox to add/remove listeners to/from the example widgets.		 */		final Button listenCheckbox = new Button (listenersGroup, SWT.CHECK);		listenCheckbox.setText (ControlExample.getResourceString ("Listen"));		listenCheckbox.addSelectionListener (new SelectionAdapter () {			public void widgetSelected(SelectionEvent e) {				logging = listenCheckbox.getSelection ();				recreateExampleWidgets ();			}		});		/*		 * Create the button to clear the text.		 */		Button clearButton = new Button (listenersGroup, SWT.PUSH);		clearButton.setText (ControlExample.getResourceString ("Clear"));		clearButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));		clearButton.addSelectionListener (new SelectionAdapter() {			public void widgetSelected (SelectionEvent e) {				eventConsole.setText ("");			}		});				/* Initialize the eventsFilter to log all events. */		int customEventCount = getCustomEventNames ().length;		eventsFilter = new boolean [EVENT_NAMES.length + customEventCount];		for (int i = 0; i < EVENT_NAMES.length + customEventCount; i++) {			eventsFilter [i] = true;		}		/* Create the event console Text. */		eventConsole = new Text (listenersGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);		GridData data = new GridData (GridData.FILL_BOTH);		data.horizontalSpan = 3;		data.heightHint = 80;		eventConsole.setLayoutData (data);		createEventConsolePopup ();		eventConsole.addKeyListener (new KeyAdapter () {			public void keyPressed (KeyEvent e) {				if ((e.keyCode == 'A' || e.keyCode == 'a') && (e.stateMask & SWT.MOD1) != 0) {					eventConsole.selectAll ();					e.doit = false;				}			}		});	}		/**	 * Returns a list of set/get API method names (without the set/get prefix)	 * that can be used to set/get values in the example control(s).	 */	String[] getMethodNames() {		return null;	}	void createSetGetDialog(int x, int y, String[] methodNames) {		final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MODELESS);		dialog.setLayout(new GridLayout(2, false));		dialog.setText(getTabText() + " " + ControlExample.getResourceString ("Set_Get"));		nameCombo = new Combo(dialog, SWT.READ_ONLY);		nameCombo.setItems(methodNames);		nameCombo.setText(methodNames[0]);		nameCombo.setVisibleItemCount(methodNames.length);		nameCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));		nameCombo.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(SelectionEvent e) {				resetLabels();			}		});		returnTypeLabel = new Label(dialog, SWT.NONE);		returnTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));		setButton = new Button(dialog, SWT.PUSH);		setButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));		setButton.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(SelectionEvent e) {				setValue();				setText.selectAll();				setText.setFocus();			}		});		setText = new Text(dialog, SWT.SINGLE | SWT.BORDER);		setText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));		getButton = new Button(dialog, SWT.PUSH);		getButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));		getButton.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(SelectionEvent e) {				getValue();			}		});		getText = new Text(dialog, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);		data.widthHint = 240;		data.heightHint = 200;		getText.setLayoutData(data);		resetLabels();		dialog.setDefaultButton(setButton);		dialog.pack();		dialog.setLocation(x, y);		dialog.open();	}	void resetLabels() {		String methodRoot = nameCombo.getText();		returnTypeLabel.setText(parameterInfo(methodRoot));		setButton.setText(setMethodName(methodRoot));		getButton.setText("get" + methodRoot);		setText.setText("");		getText.setText("");		getValue();		setText.setFocus();	}	String setMethodName(String methodRoot) {		return "set" + methodRoot;	}	String parameterInfo(String methodRoot) {		String typeName = null;		Class returnType = getReturnType(methodRoot);		boolean isArray = returnType.isArray();		if (isArray) {			typeName = returnType.getComponentType().getName();		} else {

⌨️ 快捷键说明

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