18 novembro 2014

Web Article - Top 10 Best free Rich Text Editors


1) Best Rich Text Editor – NicEdit

2) Rich Text Editor – Xinha
3) Free Rich Text Editor – WYSIWYG Editor
4) Best Web Text Editor- FCKeditor
5) Best Javascript Markup Editor – MarkITUp
6) Rich Text Editor – WidgEditor
7) Best Leading Text Editor – XStandard
8) Free Web Based Text Editor – Whizzywig
9) Best Web based XHTML Editor – WYMeditor
10) Top free Rich Text Editor – FreeTextBox

Source: Devzum.com

17 novembro 2014

08 novembro 2014

Web Article: Java Synchronized keyword Example

Example 1
package com.javacodegeeks.snippets.core.synchronizedexample;

import java.util.ArrayList;

public class SynchronizedMethodClass {

 private ArrayList < Integer > nums1;
 private String pos1;

    public SynchronizedMethodClass() {
     nums1 = new ArrayList < Integer >();
     nums1.add(0);
     pos1 = "0";
    }

 public ArrayList < Integer > getNums1() {
  return nums1;
 }

 public void setNums1(ArrayList < Integer > nums1) {
  this.nums1 = nums1;
 }

 public String getPos1() {
  return pos1;
 }

 public void setPos1(String pos1) {
  this.pos1 = pos1;
 }

 public synchronized void syncMethod(String threadName) {
     Integer number = nums1.get(nums1.size() - 1) + 1;
        pos1 = String.valueOf(number);
        nums1.add(number);
        System.out.println("Thread " + threadName + " : " 
+ nums1.get(nums1.size() - 1) + " - " + pos1);
    }
}
Example 2
package com.javacodegeeks.snippets.core.synchronizedexample;

import java.util.ArrayList;

public class SynchronizedBlockClass {

    private ArrayList < Integer > nums2;
    private String pos2;
    private int counter;
    
    public SynchronizedBlockClass() {
     nums2 = new ArrayList < Integer >();
     nums2.add(0);
     pos2 = "0";
    }
 
 public ArrayList < Integer > getNums2() {
  return nums2;
 }

 public void setNums2(ArrayList < Integer > nums2) {
  this.nums2 = nums2;
 }
 
 public String getPos2() {
  return pos2;
 }

 public void setPos2(String pos2) {
  this.pos2 = pos2;
 }

 public int getCounter() {
  return counter;
 }

 public void setCounter(int counter) {
  this.counter = counter;
 }

    public void syncBlock(String threadName) {
     counter++;
     System.out.println("Thread " + threadName + " - counter: " + counter);
        synchronized (this) {
         Integer number = nums2.get(nums2.size() - 1) + 1;
            pos2 = String.valueOf(number);
         nums2.add(number);
            System.out.println("Thread " + threadName + " Added to list: " 
              + nums2.get(nums2.size() - 1) + " - " + pos2);
           }
    }

}

Source: javacodegeeks

Web Article - ClassLoader Example

package com.jcg;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author ashraf
 * 
 */
public class JavaClassLoader extends ClassLoader {
 
 public void invokeClassMethod(String classBinName, String methodName){
  
  try {
   
   // Create a new JavaClassLoader 
   ClassLoader classLoader = this.getClass().getClassLoader();
   
   // Load the target class using its binary name
         Class loadedMyClass = classLoader.loadClass(classBinName);
         
         System.out.println("Loaded class name: " + loadedMyClass.getName());
         
         // Create a new instance from the loaded class
         Constructor constructor = loadedMyClass.getConstructor();
         Object myClassObject = constructor.newInstance();
         
         // Getting the target method from the loaded class and invoke it using its name
         Method method = loadedMyClass.getMethod(methodName);
         System.out.println("Invoked method name: " + method.getName());
         method.invoke(myClassObject);

  } catch (ClassNotFoundException e) {
   e.printStackTrace();
  } catch (Exception e) {
   e.printStackTrace();
  }
  
 }
}

Running the example
package com.jcg;


/**
 * @author ashraf
 * 
 */
public class ClassLoaderTest extends JavaClassLoader {

 public static void main(String[] args) {

  JavaClassLoader javaClassLoader = new JavaClassLoader();
  javaClassLoader.invokeClassMethod("com.jcg.MyClass", "sayHello");
  
 }
 
}

Source: javacodegeeks

04 novembro 2014

Adding a library/JAR to an Eclipse Android project

Steps:
  1. Download the library to your host development system.
  2. Create a new folder, libs, in your Eclipse/Android project.
  3. Right-click libs and choose Import -> General -> File System, then Next, Browse in the filesystem to find the library's parent directory (i.e.: where you downloaded it to).
  4. Click OK, then click the directory name (not the checkbox) in the left pane, then check the relevant JAR in the right pane. This puts the library into your project (physically).
  5. Right-click on your project, choose Build Path -> Configure Build Path, then click the Libraries tab, then Add JARs..., navigate to your new JAR in the libs directory and add it. (This, incidentally, is the moment at which your new JAR is converted for use on Android.)
NOTE
Step 5 may not be needed, if the lib is already included in your build path. Just ensure that its existence first before adding it.

Source: stackoverflow