• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Global Editor project

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am doing my project for my final year. The project is a Global editor by which you can compile and execute programs written in Java, C, C++. My problem is that when I compile and run a program in Java which requires user inputs through the editor, the computer gets hung. Kindly help me with it. The code is as follows:



Thanks,
Mithra

[ EJFH: Truncated a long line to fix formatting ]
[ February 24, 2007: Message edited by: Ernest Friedman-Hill ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Three things: first, this is way too much code for anyone to wade through. Thanks for using CODE tags to post it with formatting, but it's really more than anyone is going to have the patience to investigate. You're going to need to post just the parts that are relevant.

Second, I see, at the end, an empty catch block -- i.e., catch(Exception ex {} -- which is a way of saying "I don't care if something bad has happened; don't tell me about it." You need to go back and do something inside of all those catch blocks so you get notified when there are problems.

And third, a flat out guess as to what your problem is: I looks like you've posted one enormous class above, which makes me think you're probably doing everything right inside event handlers. You can't do that or, as you've found, your program will appear to "hang", as the event thread, which is also responsible for painting the screen, is busy running your code and so can't do any painting. If any event handler does something that will take more than a half-second or so, then you must do the work in a new, separate Thread. Do you know how to do that?

I'm going to edit your post a bit to fix the too-wide-window problem.
 
Marshal
Posts: 79961
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am glad you answered first Mr Friedman-Hill.

Welcome to the Ranch, Mithravedi Ramachandran.

I considered running your app earlier to see whether I could replicate the hanging,
but it would have been impossible because I lack some of the resources, viz the .gif and .bat files.
Please try out EFH's suggestions.
If they don't work, I think you are going to have to do it the hard way. Put
the entire code onto an IDE (Eclipse, NetBeans, etc), and set a breakpoint.
Anywhere. You click on the left margin, alongside a line, where the line numbers are, and you get a little round blob which represents the breakpoint.

At this point you discover a major difference between Eclipse and NetBeans:
Eclipse breakpoints are blue and NetBeans breakpoints (if I remember correctly) ARE RED.

Then don't run the code normally, but use the "debug" option.
The code will run until control reaches the line with the breakpoint. On all
debuggers, you now have three options:-
  • Step into. This means a normal method call; you go into the method and can observe what is happening.
  • Step over. Go to the next line from wherever you are. If there is a method call, this is completed without your seeing the details.
  • and, Step return. Skip seeing the details of the method you are in at present, and back to the previous method.
  • At any point during the proceedings, you can inspect the object, all its instance and local variables, etc.
    That may help you see where you are going, and what is going wrong.

    If I were marking your project (be grateful I am not ) you would lose marks for poor code style;
    I don't think b1 b2 b3 fulfil the requirement that you should be able to tell what every identifier means by reading its name.
    Also if I were marking you would lose marks for the use of AddActionListener(this) passim.
    The length of your actionPerformed() method and the number of else-if blocks in it are an object lesson
    in why addActionListener(this) does not constitute good object-oriented programming.
    You will have to learn how to write actionListeners for each individual button.
    I have posted on that subject several times in the past, but can't find them now; try a search with my ID 109202.

    Hope that is of some help.

    CR

    Edited for minor spelling and formatting errors only.
    [ February 25, 2007: Message edited by: Campbell Ritchie ]
     
    You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic