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

📄 normalview.java

📁 一些介绍J2ME的经典源码,对于在手机上开发应用很有帮助
💻 JAVA
字号:
package com.ibm.ejface.sample.views;import org.eclipse.ercp.swt.mobile.Command;import org.eclipse.jface.resource.FontRegistry;import org.eclipse.jface.resource.ImageRegistry;import org.eclipse.jface.resource.JFaceColors;import org.eclipse.jface.resource.JFaceResources;import org.eclipse.jface.resource.StringConverter;import org.eclipse.swt.SWT;import org.eclipse.swt.events.SelectionEvent;import org.eclipse.swt.events.SelectionListener;import org.eclipse.swt.graphics.Font;import org.eclipse.swt.graphics.FontData;import org.eclipse.swt.graphics.Image;import org.eclipse.swt.layout.RowLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Composite;import org.eclipse.swt.widgets.Label;import org.eclipse.ui.part.ViewPart;/** * This sample class demonstrates how to plug-in a new * workbench view. The view shows data obtained from the * model. The sample creates a dummy model on the fly, * but a real implementation would connect to the model * available either in this or another plug-in (e.g. the workspace). * The view is connected to the model using a content provider. * <p> * The view uses a label provider to define how model * objects should be presented in the view. Each * view can present the same model objects using * different labels and icons, if needed. Alternatively, * a single label provider can be shared between views * in order to ensure that objects of the same type are * presented in the same way everywhere. * <p> * @param <ColorRegistry> */public class NormalView extends ViewPart {		/*	 * The content provider class is responsible for	 * providing objects to the view. It can wrap	 * existing objects in adapters or simply return	 * objects as-is. These objects may be sensitive	 * to the current input of the view, or ignore	 * it and always show the same content 	 * (like Task List, for example).	 */		/**	 * This is a callback that will allow us	 * to create the viewer and initialize it.	 */	public void createPartControl(final Composite parent) {		RowLayout layout= new RowLayout();		layout.type = SWT.VERTICAL;		layout.wrap = false;		parent.setLayout(layout);		//ImageRegistry demo		final ImageRegistry ir = new ImageRegistry();	    ir.put("image1",new Image(parent.getDisplay(),getClass().getResourceAsStream("/icons/lb2heading.png")));	    ir.put("image2",new Image(parent.getDisplay(),getClass().getResourceAsStream("/icons/lb1heading.png")));		Label ImagelabelDest = new Label (parent, SWT.LEFT);		ImagelabelDest.setText("ImageRegistry");		final Label Imagelabel = new Label (parent, SWT.LEFT);		Imagelabel.setImage(ir.get("image1"));		ImagelabelDest.pack();		Imagelabel.pack();				Button imageButton = new Button(parent, SWT.PUSH);		imageButton.setText("Change ImageRegistry Image");		imageButton.pack();		imageButton.addSelectionListener(new SelectionListener() {			public void widgetDefaultSelected(SelectionEvent arg0) {						}			public void widgetSelected(SelectionEvent event) {								Imagelabel.setImage(ir.get("image2"));				Imagelabel.redraw();			}					});				//FontRegistry demo		FontRegistry fr = new FontRegistry(parent.getDisplay());		FontData[] fd = new FontData[2];		fd[0]= new FontData("Tacoma",20, SWT.NORMAL);		fd[1]= new FontData("Times New Roman",12, SWT.NORMAL);		fr.put("SysFont", fd);				final Label Fontlabel = new Label (parent, SWT.LEFT);		Fontlabel.setText("FontRegistry");		Font normalfont = new Font(parent.getDisplay(),fr.getFontData("SysFont")[0]);		Fontlabel.setFont(normalfont);				Fontlabel.pack();				JFaceResources.setFontRegistry(fr);		Button fontButton = new Button(parent, SWT.PUSH);		fontButton.setText("Change FontRegistry Font");		fontButton.pack();		fontButton.addSelectionListener(new SelectionListener() {			public void widgetDefaultSelected(SelectionEvent arg0) {						}			public void widgetSelected(SelectionEvent event) {				Font font = new Font(event.display, JFaceResources.getFontRegistry().getFontData("SysFont")[1]);								Fontlabel.setFont(font);				Fontlabel.redraw();			}					});								//JFaceColors demo		final Label JFaceColorslabel = new Label (parent, SWT.LEFT);		JFaceColorslabel.setText("JFaceColors");		JFaceColors.setColors(JFaceColorslabel, parent.getDisplay().getSystemColor(SWT.COLOR_DARK_YELLOW), parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));		JFaceColorslabel.pack();		JFaceColorslabel.setSize(100,50);				Button colorButton = new Button(parent, SWT.PUSH);		colorButton.setText("Change JFaceColors color");		colorButton.pack();		colorButton.addSelectionListener(new SelectionListener() {			public void widgetDefaultSelected(SelectionEvent arg0) {						}			public void widgetSelected(SelectionEvent event) {								JFaceColors.setColors(JFaceColorslabel, parent.getDisplay().getSystemColor(SWT.COLOR_BLACK), parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));							}					});				final Button stringButton = new Button(parent, SWT.PUSH);		stringButton.setText("eJface   Developer    Works");		stringButton.pack();		stringButton.addSelectionListener(new SelectionListener(){			public void widgetDefaultSelected(SelectionEvent arg0) {			}			public void widgetSelected(SelectionEvent arg0) {				String[] stringArray = StringConverter.asArray(stringButton.getText());				String newString = new String();				for(int i = 0; i< stringArray.length; i++)				{					newString+=stringArray[i];				}				stringButton.setText(newString);				stringButton.redraw();			}					});								Command RecoverCommand = new Command(parent, Command.OK, 0);		RecoverCommand.setText("Default Setting");		RecoverCommand.addSelectionListener(new SelectionListener() {			public void widgetSelected(SelectionEvent e) {				Imagelabel.setImage(ir.get("image1"));				Imagelabel.redraw();								Font font = new Font(e.display, JFaceResources.getFontRegistry().getFontData("SysFont")[0]);								Fontlabel.setFont(font);				Fontlabel.redraw();								JFaceColors.setColors(JFaceColorslabel, parent.getDisplay().getSystemColor(SWT.COLOR_DARK_YELLOW), parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));				stringButton.setText("eJface   Developer    Works");			}			public void widgetDefaultSelected(SelectionEvent e) {			}		});						parent.pack();		 					}	public void setFocus() {		// TODO Auto-generated method stub			}	}

⌨️ 快捷键说明

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