• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

applying dot functionality in java

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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-------
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
buntyide.png
[Thumbnail for buntyide.png]
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic