wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes applying dot functionality in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "applying dot functionality in java" Watch "applying dot functionality in java" New topic
Author

applying dot functionality in java

vibhas bhingarde
Greenhorn

Joined: Feb 22, 2011
Posts: 11
i have prepared a application to compile the program written in jtextarea now i want to add some more functionality such as dot,example when a user presses System. all possible classes and interfaces should popup in jtextarea please tell me how to do this in java swing
eg: when user writes
import java. ---------all possible classes must be displayed---------
label1. ---------all possible functions should be displayed-------------
System.out. ---------------alll methods should be displayed-------
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38483
    
  23
Welcome to the Ranch

How would you do it in a non-GUI application? If you wanted the list of classes in a package to be printed, how would you do it? If you wanted all the methods of a class printed, how would you do it?
vibhas bhingarde
Greenhorn

Joined: Feb 22, 2011
Posts: 11
its a gui application ,that is i am making it in java swing
i have no idea how would i do it,
if there is some java lib or jar file consisting of all avaliable classes & interfaces ...is something i am thinking of but i have no clear idea how to implement it when dot operator is encountered in jtextarea
please help me out its my college project
i have attached image of my gui
check it out


[Thumbnail for buntyide.png]

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38483
    
  23
vibhas bhingarde wrote: . . . i have no idea how would i do it . . .
Nor have I.

But if you could work out how to do it without the GUI, that would be a big step. If you have a class, eg Object, and write a dot, how are you going to get the list of members of that class? If you can do that, getting it onto a GUI is relatively easy. You are going to have to go back to a paper and pencil (and a large eraser) and work it out from there. Also read through the Java™ Tutorials and the standard API; I can think of something in the java.lang package which might give you a hint.

You should also consider how many marks you will get for this enhancement, and whether the work involved will be rewarded with many marks, or whether you should consider some other part of the assignment. If, for example, you have to write a description of the work, and you have nothing written yet, you might earn more marks by writing the report and omitting the dot functionality.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  19

So, you're basically going to write your own IDE. Tough project.

You'll need to have fully functioning parser. To be able to list all methods for "label1" your code needs to know what "label1" is, especially its type. Likewise for System.out. Furthermore, it needs to be able to map from "List" to the "java.util.List" class if "java.util.List" is in your imports. In other words, for all variables and classes you need a mapping from that variable to its declared class. Reflection will do the rest.

The import auto completion is going to be tricky as well. Reflection does not allow you to list a package's classes or "nested" packages. That means you'll need to go to the file system. You'll need to check the rt.jar file, all JAR and ZIP files in the JRE's lib\ext folder, and all manually added JAR files and folders in the class path.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Don't get me started about those stupid light bulbs.
 
subject: applying dot functionality in java