having a class as parameter
              in 
             Library and Tool Development 
              •  
              10 months ago    
            
 
           
             (I shortended some of the classes in this example)
            
            
             I have a basic class:
            
            - public class Tool {
 - public Tool() {
 - }
 - }
 
             If i want to create a pen tool or selection tool i need to extend Tool
            
            - public class PenTool extends Tool {
 - public PenTool() {
 - }
 - }
 
             Then i have a class ToolHandler,
            
            
             this is a method from that class (where the problem is i assume)
            
            - public boolean setActiveTool(Class<Tool> tool) {
 - for(Tool t : tools) {
 - if(t.getClass() == tool) {
 - activeTool = t;
 - return true;
 - }
 - }
 - return false;
 - }
 
             In processing i want to use this:
            
            - ToolHandler toolHandler = new ToolHandler(this);
 - toolHandler.setActiveTool(PenTool);
 
             notice that i pass the Class as a parameter and not a instance.
            
            
             However processing says "cannot find anything named "PenTool""
            
            
             Is what i want possible? I don't want to use Enums for reasons i'm not gonna explain here.
            
 
            
              
              1  
            
 
            