4

I was looking for tool on Java that does the same (similar) functionality of "inspect element" of "Google Chrome". Does anyone has information whether this is available and how it can be implemented?

The question refers to cases when you have the Source code and you don't know the inside of it. Thus, the idea is to inspect elements (objects) on UI while running code!

asterix55
  • 93
  • 1
  • 2
  • 8
  • Why would you need that, you can use the eclipse or netbeans module to draw the gui and inspect at the design time but not at the run time – lc2817 Nov 20 '11 at 21:25
  • It's about inspecting at the run time. It's the case when you code from others and not your code, so you want to inspect objects on Java UI. – asterix55 Nov 20 '11 at 21:27
  • Could you access the source code? – lc2817 Nov 20 '11 at 21:29
  • Yes, you have the source code but you don't know which part of the code generates which output. Sorry for not stating that fact! – asterix55 Nov 20 '11 at 21:38
  • By using introspection, you could be able to add a module that would let you know the state of a given UI element let's say in a console. But that means that you have the source code and can modify it (or at least know a lot about it). Please note that it is an overkill solution to an overkill issue – lc2817 Nov 20 '11 at 21:42

4 Answers4

2

Since you have access to the code you can use the Java Object Inspector. Just add one line of code at the right place:

Inspector.inspect(objectToInspect);
Boomer
  • 3,360
  • 20
  • 28
0

Inspect Element in Chrome/Firefox and View Source in Safari are there because the internet is open sourced. The HTML code pushed to a user's machine is viewable by them (obviously not the spreadsheets or other static files held on a server.)

Compiled projects don't have this feature for practical reasons.

  • In many languages it is impossible to "decompile" an object into its source.
  • If you could go to Microsoft Word and Inspect any element, you could just copy and paste their application without paying.

So no, you cannot take a compiled Java object and click to see its source code.

Chris
  • 11,819
  • 19
  • 91
  • 145
  • Actually, it is for cases when you have the Source code and you don't know the inside of the code. Thus, the idea is to inspect elements (objects) on UI while running code! – asterix55 Nov 20 '11 at 21:36
  • Why would you like to do so? Is it Swing UI or something else, please give us details... – lc2817 Nov 20 '11 at 21:40
  • To locate parts of the code which generate specific output on UI. And yes it can be on Swing UI! – asterix55 Nov 20 '11 at 21:43
  • Just for people coming here now, you can decompile Java source code with ease. + the internet isn't open sourced as such, but that's just me being picky – TheKodeToad May 18 '22 at 18:00
0

I remember hearing about a project that did something like that a few years ago. I can't recall the name, but I ran across this while searching for it. https://github.com/cozycode/Swing-Inspector Based on the description, at least. it looks like it might be useful. If I remember what the original project was i'll post a follow up.

BillRobertson42
  • 12,602
  • 4
  • 40
  • 57
-3

for you to find the java code, in the inspect element go to Sources. Look in the picture below. I inspected google and went to Sources this what i found. press on the files. that say js, and the java code will appear.

if you cant see the pic, tell me. or try to download it, and open it on paint.

enter image description here

leen
  • 1
  • 2
    Your answer is off-topic. First thing, Java is not the same as JavaScript. No relation. Second, OP needs a tool to inspect a running Java program, not a way to inspect JavaScript source files of a web page. – Eric Aya Aug 31 '20 at 11:33