Esmaeil Ashrafi

Ranch Hand
+ Follow
since Feb 22, 2010
in my computer
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 Esmaeil Ashrafi

Rob Camick wrote:

What's your suggestions?

Use a JTable, there is no need to reinvent the wheel. Add the table to a scroll pane and add the scroll pane the the option pane.

Hi Rob,
Honestly i didn't use JTable before. Of course it is nice having to learn how to use that, but in some programs i saw there is capability of editing cell contents; while i don't want this. So is it possible,? if so, i will go through tutorials and documentations.

Thank you
11 years ago
Hi there,
I have an application, and somewhere i want to show a message that would contain a table (generally meaning).

I am using a JOptionPane as the dialog and want to have a table i attached its picture.

The matter is no modification required to the table, just as a message to the user to confirm the informations contained within it.

Well now, i think JTable would be a more complicated component and has its own situations to use!

Some approaches i can guess is to using panels for each cell and make lined border for them !

What's your suggestions?

Thank in advance
11 years ago
There is just one small problem in the final program (program in previous post) :
Sometimes , when a letter that several values in the list starts with that, is typed, popup doesn't show itself! and when for example i maximize the window, it appears as expected.
I even put the before , but has no affect.

Attached picture explains more

Thanks in advance.
11 years ago
Guess what !
I checked the source code of BasicComboBoxEditor and see there shouldn't be any problem with ComboBoxEditor.getItem() method, aaaaaaaaaaaaaaaaaaaaaaaaaaaaand:

I tried both keyTyped and keyPressed methods of KeyListener, but never keyReleased !!!

So the first approach (the simple one) will also do the job. (by means of invoking keyReleased(KeyEvent e) mehod)

This seems better and just perfect...

It seems to be resolved. Thank you
11 years ago
Edited seems i am mistaken, i should be sure.....

sombody please delete this post...
11 years ago
Oh Rob, thank you so much

Actually I always use System.out.println(...), but this time i didn't put it at the right place to debug. upon your suggestion
i put two of it just as the fist statements in the loop and found out that the typed in string value obtained by (String) editor.getItem() is null (actually prints nothing > "") !

I did a lot of modifications to the listener and the final is as below:

Although it seems to work fine mostly as expected, but is gotten kinda complicate, and the issue is:
Why editor.getItem() doesn't return the expected value (in the first snippet?

I am going to check its source and if got any better approach, will inform you, but i will watch if you have better suggestion to apply to this case and will appreciate...

11 years ago
Did you noticed that MS Windows file system uses back slash ("\") character instead of slash ("/") !?

I'm not sure, but you can try it and also you can use extension mechanism...
11 years ago

Rohit Kedia wrote:Please let us know what do you want ... I executed it and every time I type a key then some predefined data is being added to the Combo...

You are right, i added a few comments to the snippet...

I expect that in KEY_TYPED event (process of keyTyped method i implemented in class ComboBoxEditorKeyListener), JUST values which of array "values" that has a prefix equal to user typed in String, to be added to combo box, but in any key event, without consideration of comparison, the whole array elements will be added to combo box
11 years ago
OK, lets see :

Please run it, it seems that something is going wrong in line #41 , I'm not sure it is JComboBox problem or not?!

Would somebody please explain that ?

Thanks in advance
11 years ago

That's probably the easiest option. Of course, you have to remember the standard issues when editing an existing file

The Java Swing API has an HTML parser, but it's strictly a one-way operation (i.e. it can't change and write a document like the XML DOM parser).

I think so.
after writing the first post until now, i googled a lot and furthermore i read several API documentations most from javax.swing.text.html and today i became hopeless to find something useful to change any particular attribute value of any tag, on the fly.

Of course the are lots of features to parse and display (however seems very sophisticated in most cases for a tyro on HTMLs like me, except the calling back parser...), and also HTMLDocument class gives some kind of modifications (although I'm not sure this modifications are in source or not)

Best thing is create a copy of the original file and make changes there and then rename the file or copy the changes into the old file.

The matter is not copying, actually one goal of writing this application, for me, is to exercise the nio2 from jdk7...(so i will copy the whole file tree to another place first, then want to change the HTMLs)

The issue is: finding the best performance oriented way to do the changes
Substantially I'm looking for a way to keep me away having to read throughly contents of the HTML source file and just jump to the specified tag and attribute...
11 years ago
Uuuumm, i can say as a Java nerd, i've got good information to extends my knowledge about Java!

Thank you very much
11 years ago
I'm writing a simple application that should read the source of a HTML file and change the value of some tags.
For instance:
change the value in tag below

to the value

actually i want to do only this modification.

Some essential way could be opening a character stream and reading source untill encounter the <a href and then doing modification, but i think that's not a good approach.

I'm totally unfamiliar with HTMLs and currently searching in javax.swing.text.html package to see if there is better way to jump to the specified tag and do the modification...

So, any suggestion or direction will be gratifying...
Thanks in advance
11 years ago
Thanks Rob, it is now much more clear to me;

Could following interpretation be right?
in my example,Cipher (the abstract class) is made from one of its subclasses, so when this instance calls the encrypt method (defined in superclass) that calls method encode (the abstract in superclass), firstly looking for method implementation in the instance (subclass) make sense to JVM

And about standard API, when JVM sees no implementation (for example for DirectoryStream<Path>) in my class or package, follows the ways you explained. If so, it seems somehow confusing to understand, it should be predefined in JVM, i think! that is call to newDirectoryStream() cause JVM to call specified class Hard-Coded into JVM...

I also uncompressed the file rt.jar in the lib directory of private JRE folder in jdk7 and found those classes...

Rob Prime wrote:...
...The native method probably just returns an instance of one of those classes; the class is hard coded into the JVM which is OK because the Linux JVM is naturally different from the Windows JVM.

what that means (phrase in bold) ?

Sincerely yours
11 years ago
@ Campbell Ritchie
I did it before, and again did that as you suggested:
this method returns an interface (DirectoryStream<Path>), i did the following snippet:

an got the following output:

So, i don't know how to deal with these informations to figure out what i'm trying to!

@ kunu patil
It's of course OS specific and without trying i can say for UIX/Linux that will be a different class implements that.But how JVM knows!?...please follow to the last of this post to figure out what I'm trying to see

@ David Newton
Of course it *is* implemented...

Actually i don't care about the implementation or details of implementations performed by implementer class!
what I'm confusing about, is the procedure that JVM uses when encounters to such this abstract methods
And to make it more clear, i try to give you a semantic view by the following snippet:

Then the tester class, where JVM automatically jumps from encrypt to suitable encode (i think...)

Obviously there is some mechanism to call expected class to implement the encode method from encrypt method, it is somehow more simple than that i firstly illustrated
How could it (Path.newDirectoryStream() for instance) be explained upon this example

11 years ago
I am so sorry, still i can not believe that i made such an ignorant and just dropped my question here before take a precise look at documentations....
I used this component several times already, but always with predefined values and couldn't imagine that can be editable.

Thank you for mentioning
11 years ago