Poorav Chaudhari

Ranch Hand
+ Follow
since Sep 17, 2002
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Poorav Chaudhari

Thanks Armitage,

I'll look into this tutorial.

11 years ago

James Boswell wrote:What you are trying to achieve is not currently possible i.e. trying to run a class within a jar which requires jar files also contained with the same jar - see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4648386.

Thanks, is this still an issue with 1.6. Your suggestion definitely works after extracting the contained jar files.
11 years ago
I am trying to run my jar file on a Mac (Haven't yet tried on any other platform). When I run using java -jar MyApp.jar I get the following error

So, as you can see the main class is recognized. This is the manifest file.

And the folder structure in the jar file as follows

tabalchiApp/TabalchiApp.class <-- this is the main class

I have read many posts about running .jar file but none of the solutions have worked for me. I would really appreciate your help on this one.

I am creating the jar file by exporting from eclipse. If I export to a runnable jar file then I cannot control the making of the manifest file. I need to add the splash image in the manifest file. And I am having some other issues with the runnable jar export.

The application is running without issues in eclipse.

11 years ago
I am noticing this error since I did the Mac update. The Mac update included the java update. Right now the java version is 1.6.0_31. My Mac OS X version is 10.7.3. I am seeing the problem for all the soundfont files that I am trying to load. The error i get is.

javax.sound.midi.InvalidMidiDataException: cannot get soundbank from stream
at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:565)
at myPackage.MyMusicApp.main(MyMusicApp.java:14)

Below is a small program I built that shows the code.

I am not sure what the previous build of java I was on, but i know that it was a 1.6 version. Any ideas of what could have caused this?

12 years ago
I realized I needed to call the matcher.match() or the matcher.find() method before calling matcher.start().
12 years ago
I am trying to find the position of string that matches the regular expression in a given 'word'. But for some reason I get the following Exception.

Exception in thread "main" java.lang.IllegalStateException: No match available
at java.util.regex.Matcher.start(Matcher.java:325)
at myworkspace.TestRegEx.<init>(TestRegEx.java:16)
at myworkspace.TestRegEx.main(TestRegEx.java:21)

I have created a small program that demonstrates the problem, posted below. I would really appreciate some input on this. thanks

12 years ago

I am looking into syntax highlighting and I came across this tool XML Text Editor. The highlighting job is done in the drawUnselectedText of the PlainView component. I am trying to understand how it works, the API really doesn't give me much and I have not been able to find any useful resources that explain the specific purpose of this method. To understand this i downloaded the code and put some println statements to see when it is exactly executed and the parameters passed. But i still haven't really gotten a grasp on it. For one thing, it seems that this method is called numerous times, not just when something is typed into the text area.

I would really appreciate some input on this.


12 years ago

Darryl Burke wrote:
Rob Camick's No Wrap Text Pane may help there.

In fact that's exactly where I got the idea to extend the TextPane.

Darryl Burke wrote:The Caret belongs to the UI delegate, not the component.

Does that mean I cannot disable the selection functionality if using textpane? I would imagine that it is possible.

Darryl Burke wrote:Not really. I'm not a programmer and have absolutely no education, formal or otherwise, in programming.

Could have fooled me :-)

Darryl Burke wrote:However, there are many skilled and experienced professionals here who would be in a position to advise you on design.

Hopefully, somebody will give their input.

Darryl Burke wrote:Sounds a lot like syntax highlighting <- Google

Darryl Burke wrote:Have you considered using a DocumentListener? or maybe a DocumentFilter?

Thanks for the tip. I'll look into both.
12 years ago
Hi Daryl, In fact the textpane will have lots of custom behaviour, and maybe you can give me some more pointers on how you think i should approach this. I am fairly new to swing development and I haven't realized the 'power' of extending components. For starter, I have extended the JTextPane component because i needed to disable to line wrapping functionality. So my first question ixts, can i still implement a similar approach as you suggested with JTextPane instead of BasicTextPaneUI. I looked at the JTextPane API and I don't see any method similar to createCaret, so I don't know how this can be possible.

Secondly, I would love to hear your input on some design related question. In my application, the text entered in the textpane is going to be a 'coded' language. So it should be able to parse the text and mark invalid words. certain words will be highlighted automatically, others will be highlighted depending on its 'property'. So, each word will have an object associated with it and it's properties can be changed. Properties will be changed by clicking on the word and a dialog box will come up to change its properties. Words will be further divided into subwords, and these could be highlighted differently from the rest of the word (but we can leave that from this discussion).

My challenges are tracking the word with the object, especially because if you delete a word or insert a word in the sentence.

At the moment I am achieving some of this by just going through the entire text everytime a key is pressed and marking the invalid words and highlighting others. But somehow i don't feel this is a very good design and if it makes sense to extend the textpane to handle this inherently, and if yes how?

I would really appreciate some inputs on this.

12 years ago

Darryl Burke wrote:A more correct but possibly L&F dependent approach would be to create a custom UI extending BasicTextPaneUI and override createCaret to return a custom subclass of BasicCaret that overrides mouseClicked(...) / mousePressed(...) to return without action when getButton() == BUTTON1 && getClickCount() > 1, otherwise invoke the super implementation.

edit: What about selection by dragging? or via the keyboard?

Thanks for the input Darryl, I think I prefer the second approach, I will look into this approach further. What did you mean by L&F dependent apporach?

Selection via dragging and keyboard will also require some custom handling. I guess again in that case also extending the TextPaneUI and handling keyboard inputs etc. would be more practical.

12 years ago
For my application i want to disable the textpane from selecting a word when double click is performed on the word. Is there a way to do this?

12 years ago

Rob Camick wrote:Don't use a null layout for you main components.

Use a Glass Pane with a null layout to hold the slider so it paints on top of other components. For example:

Thanks Rob for your suggestion here. It took me a while to get back to this. I worked with Glasspane and it resolved my issue. I am having some issues with some additional behaviour i am trying to implement. but I am working throught it.
12 years ago
Hi, I have set the layout manager to null, and I think the code below should be complete in order to view the example.

12 years ago
Hi, I have created an SSCCE. I use netbeans to develop my swing application. I have tried to remove most of the automatically generated code which I saw as unnecessary. Hopefully you should see this behaviour when you run the file. Once you run the file click anywhere in the textpane, and you should see the slider move to the same x position as the mouse, but is lower below.

12 years ago
I don't understand what is going on. I am using the location of the mouse using the mouseevent. I am trying to place the slider at the location of the mouse. But when i pass the mouse location information to the jSlider.setLocation(), the x position is correct, but the y position of the slider is way below the position of the mouse. Any clues?

12 years ago