TS 69 JavaFX Hints

Author: Alexandr Scherbatiy
Version: 1.3
Last update: 4 August 2010
Introduction:
Comments:


Contents


Semantic

Unused variables

  • Copy the code to the editor:
         
var a = 10;
var b = 20;
var c = a + 30;
  • EXPECTED RESULT: The 'b' variable is indicated as unused

Unused attributes

  • Copy the code to the editor:
         
class A{
    public var a;
}
  • EXPECTED RESULT: The 'a' attribute is indicated as unused

Unused functions

  • Copy the code to the editor:
  
class A{
    public function f(){}
}
  • EXPECTED RESULT: The 'f' function is indicated as unused

Dynamic Hints

Remove unused imports

  • Copy the code to the editor:
  
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;

Circle{}
  • Click on the hint
  • Select Remove unused import...
  • EXPECTED RESULT: The unused import is deleted


Generate variable

  • Copy the code to the editor:
  
public class A {
    function f() {
          value;
    }
}

  • Click on the hint
  • Select Create variable value in the javafxapplication.Main.A
  • EXPECTED RESULT: The 'var value;' attribute is generated
  
public class A {
    var value;

    function f() {
          value;
    }
}

Generate local variable

  • Copy the code to the editor:
  
public class A {
    function f() {
          value;
    }
}

  • Click on the hint
  • Select Create local variable value in the javafxapplication.Main.A
  • EXPECTED RESULT: The 'var value;' local variable is generated
  
public class A {
    function f() {

          var value;
          value;
    }
}

Generate class

  • Copy the code to the editor:
  
var a = A{};
  • Click on the hint
  • Select Create A Class in the javafxapplication
  • EXPECTED RESULT: The 'A' class is generated under the javafxapplication package


Generate class in a file

  • Copy the code to the editor:
  
var a = A{};
  • Click on the hint
  • Select Create A Class in the javafxapplication.Main
  • EXPECTED RESULT: The 'A' class is generated in the Main file
  
var a = A{};

class A {
    //TODO Not implemented yet.
}


Static Hints

Surround with try-catch

  • Copy the code to the editor:
  
import javafx.scene.shape.Circle;

Circle{}
  • Select the Circle{} line
  • Click on the Hint
  • Select Surround with try{...
  • EXPECTED RESULT: The try-catch block is added
  
try{
    Circle{}
}catch(e){
    
}


Surround with if-else

  • Copy the code to the editor:
  
value
  • Select the value line
  • Click on the Hint
  • Select for if (exp) {...|} else {...}
  • EXPECTED RESULT: The if block is added
  
if (exp) {
 
}else {
}

Surround with for (idx in arr){...

  • Copy the code to the editor:
  
value
  • Select the value line
  • Click on the Hint
  • Select for (idx in arr){...
  • EXPECTED RESULT: The for block is added
  
for (idx in arr) {
}


Surround with while (exp) {...

  • Copy the code to the editor:
  
value
  • Select the value line
  • Click on the Hint
  • Select for while (exp) {...
  • EXPECTED RESULT: The while block is added
  
while (exp) {

}

Implement all abstract methods

Argument with Sequence type

  • Copy the code to the editor:
         
abstract class A{
    abstract function f (seq:Boolean[]);
}

class B extends A{

}
  • Implement all abstract methods .
    • EXPECTED RESULT: Implementation of the abstract methods should be added
  
import java.lang.UnsupportedOperationException;

abstract class A{
    abstract function f (seq:Boolean[]);
}

class B extends A{
    override function f (seq : Boolean[]) : Object { 
        throw new UnsupportedOperationException('Not implemented yet');
    }
}


Generic interface

  • Copy the code to the editor:
         
import java.lang.Comparable;

class Vector extends Comparable {
}
  • Implement all abstract methods .
    • EXPECTED RESULT: Implementation of the abstract methods should be added
import java.lang.Comparable;
import java.lang.UnsupportedOperationException;

class Vector extends Comparable {
    override public function compareTo (arg) : Integer {
        throw new UnsupportedOperationException('Not implemented yet');
    }
}



Create Hints

Create class in current package

  • Copy the code to the editor:
         
public class NewJavaFXClass extends Test {}
  • Press hints
  • Select Create class Test in current package
    • EXPECTED RESULT: Test.fx class is created

Create class in current file

  • Copy the code to the editor:
         
public class NewJavaFXClass extends Test {}
  • Press hints
  • Select Create class Test in current file
    • EXPECTED RESULT: Test class is created in current file
         
public class NewJavaFXClass extends Test {}

class Test {
    //TODO Not implemented yet.
}
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo