`
文章列表
一个字符串在另一个字符串中出现的次数   public static int getStringAppearTimers(String target, String token) { int times = 0; for (String tmp = target; tmp != null && tmp.length() >= token.length(); ) { if(tmp.indexOf(token) == 0) { times ++; ...
configurer.getWindowConfigurer().getWindow().addPerspectiveListener(new IPerspectiveListener { public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { if(perspective.getId().equals(STANDARD_PERSPECTIVE_ID)){ configurer.getWindowConfigurer().setShowMenu ...
控件和背景图片一样大小   import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.RowData; import org.eclipse.swt.layout.RowLayout; im ...
切换到某个透视图隐藏菜单 在ApplicationActionBarAdvisor中添加: configurer.getWindowConfigurer().getWindow().addPerspectiveListener(new IPerspectiveListener(){ public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { if(perspective.getId().equals(PERSPECTIVE_ID)){ ...

定制tooltip

public class HelloToolTip { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Hello table"); shell.setLayout(new RowLayout()); shell.setSize(300, ...

Java hashcode

    博客分类:
  • Java
 
原文:http://www.ibm.com/developerworks/cn/java/j-jtp05273/     虽然Java语言不直接支持关联数组 -- 可以使用任何对象作为一个索引的数组 -- 但在根 Object 类中使用 hashCode() 方法明确表示期望广泛使用 HashMap (及其前辈 Hashtable )。理想情况下基于散列的容器提供有效插入和有效检索;直接在对象模式中支持散列可以促进基于散列的容器的开发和使用。 定义对象的相等性 Object 类有两种方法来推断对象的标识: equals() 和 hashCode() 。一般来说,如果您 Overrid ...
public class UsingStackLayout { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); final Composite parent = new Composite(shell, SWT.NONE); parent.setLayoutData(new GridData(Gr ...
由于Java的原始类型里没有无符号类型,如果你需要某个宽度的无符号类型,恐怕得用下一个宽度的带符号类型来模拟。例如你需要的是无符号的short,就得用int来模拟。要达到这样的模拟很简单:   int toUnsigned(short s) { return s & 0x0FFFF; }   type: int toUnsigned(Byte b) { return b & 0xFF; }  
public class TransparentImage { public static ImageData[] readImage(String fileName) { ImageLoader loader = new ImageLoader(); return loader.load(fileName); } public static void saveImage(String fileName, ImageData[] data, int format) { ImageLoader loader = new ImageLoader(); ...
原文:http://www.ibm.com/developerworks/cn/linux/opensource/os-ecgui1/        

databing

link: http://www.vogella.com/articles/EclipseDataBinding/article.html   源代码不是太好下载:自己整理了一下,原来用了还是挺方便的,可以把一些改成Databing的模式了。
PlatformUI.getWorkbench().getSharedImages().getImage(f.getName())     IMG_DEC_FIELD_ERROR IMG_DEC_FIELD_WARNING IMG_DEF_VIEW IMG_ELCL_COLLAPSEALL IMG_ELCL_COLLAPSEALL_DISABLED IMG_ELCL_REMOVE IMG_ELCL_REMOVE_DISABLED IMG_ELCL_REMOVEALL IMG_ELCL_REMOVEALL_DISABLED IMG_ELCL_STOP IMG_EL ...

数组操作

    博客分类:
  • Java
1 数组倒叙:Snippet181 写道 int[] order = table.getColumnOrder(); for (int i = 0; i < order.length / 2; i++) { int temp = order[i]; order[i] = order[order.length - i - 1]; order[order.length - i - 1] = temp; }   2 数组增加,排序 写道 data = new int[0]; // add 10 random numbers to array and sort int grow ...

maskToFunction

public class Util { public static String maskToFunction(final String mask, int fanin) { Assert.isLegal(fanin <= 4, "virtex/virtex2 prim lut <= lut4"); int mask_int = 0; mask_int = Integer.parseInt(mask, 16); int bit_count = 1 << ...
public class RightLeftAnchor { public static void main(String args[]) { Shell shell = new Shell(); shell.setText("Draw2d Hello World"); shell.setSize(400, 400); shell.open(); // create content 4 shell. createContent4Shell(shell); while (!shell.isDisposed ()) ...
Global site tag (gtag.js) - Google Analytics