Arun Sanker

Ranch Hand
+ Follow
since Mar 21, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Arun Sanker

Hi Guys,

Iam trying to read a file from a directory as follows:

String name = new String(filePath + fileName + ".apr");
File file = new File(name);

My problem is that the file extension ".apr" could be in any case(For Example:- "apr","APR","Apr")

So my reading of the file fails if the file extension differs from ".apr" to any of the extension I listed above.

So in short when Iam reading a file,would like to ignore the case of the file extension.Cant rely just on the filename ignoring the file extension as there could be files with the same name but different file extension.

Is there any utility method in java to do it or how could it be done....

Thanks

Pazzuzu
9 years ago
My color objects are of type rgb,cmyk,hilightcolor.
so each object is a different color object.
[ November 28, 2008: Message edited by: Arun Sanker ]
9 years ago
Hi Guys,

I have 2 kinds of map ,a HashMap and a HashTable - in which I store some userdefined objects,Say a "Color" object.

So my collection set will look as follows:

HashMap<Color,Color> objects(userdefined "Color" objects).
Hashtable<Color,Color> objects(userdefined "Color" objects).

For example:-

(color1,color20)
(color2,color21)
(color3,color22)
(color4,color23)
(color4,color24)
(color5,color25)


So,Now to my question.
In java documentation it says that

>>To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method.

[1]How should I implement these "hashcode" and "equals" method in my Color object.

Class rgbColor implements Color{


}

[2]As my "key" and and "value" in the maps are both "Color" objects.Does it cause a problem?(I mean implementing the "equals" and "hashcode" method).


Would be great if some one could put some light into it?

Thanks
P
9 years ago
Thanks a Lot....
9 years ago
Hi Guys,

I have a set in which I store some unique userdefined objects,say a "Color" object.
So my collection set will look as follows:

set<Color> objects.

For example:-
(color1)
(color2)
(color3)
(color4)
(color5)
(color6)
(color7)
(color8)
(color9)
(color10)



I also have a HashMap which stores objects as follows:

HashMap<Color,Color> objects(Also userdefined "Color" objects).

For example:-

(color1,color20)
(color2,color21)
(color3,color22)
(color4,color23)
(color4,color24)
(color5,color25)

My need is that I want to merge this set and hashmap so that the resulting collection looks as follows:


(color1,color20)
(color2,color21)
(color3,color22)
(color4,color23)
(color4,color24)
(color5,color25)
(color6,null)
(color7,null)
(color8,null)
(color9,null)
(color10,null)


How could this be achieved.
Any help is appreciated.
Thanks....
P
9 years ago
Thanks all....Will look into the tutorial.

I also have to find out how to pass the password to the process using the ouput stream and execute it....

Thanks any way....
9 years ago
Hi Joe,

Could you post a sample code on how to do it in my case.....

That would be a great Help.....

Thanks
P
9 years ago
Hi Guys,

From Java,I want to change the current user to "su",providing the password as well under linux.Do some tasks and go back to the last user.

For example,I tried something as follows which didnt work!

String cmd[]={"su","password"};
Runtime.getRuntime().exec(cmd);

Finish some tasks with the super user like deleting some files

Go back to the previous user.
//
String cmd[]={"Exit"};
Runtime.getRuntime().exec(cmd);

These are the commands normally used on a Linux shell command.How to do it from a java program.I use Java5.

Thanks
P
9 years ago
Hi guys,

Have a situation in which I have a function called "Test()"as shown below.It has to wait until a flag becomes "1".
So Iam running it in an infinite loop until the flag becomes "1".

The "Test()" function is running in one thread.

Have another function called "eventListener"(See Below), which changes the flag to "1". This function gets called from another thread.


This works....

But I want to get rid of this infinite looping mechanisam because it is running the processor time...
Don't want to use the "sleep" or "join" stuffs to make the thread sleep..

Is there any elegant way of handling this. May be like some mutexes.....

Would be nice if someone could show what should be done in the following code to achieve that....

Thanks

9 years ago
Hi guys,

Have made a small test application to tell my problem.
Have rendered a table with a comboBox.Everything works fine,the way I wanted it to be, apart from the following things.


[1]
When the user Doubleclicks on one of the combocells,the comboitem in the combobox is already displayed on the tablecell.I dont want it to be like that.

I want the comboitem to be displayed on the tablecell only when the user explicitly goes and selects the comboitem.If the user doublciks on the cell as said before,the old cell value should remain.

[2]
How to catch a combo close up event when the user explicitly selects an item from the combo.Because I want to do something when the user does so....

see Pic:

http://i337.photobucket.com/albums/n399/turniphorse/ComboSelection.jpg


Iam attaching the code(running) also along with this....

Any help is greatly appreciated.

Thanks.

9 years ago
Hi Guys,

Iam developing under java swing and found it difficult to achieve the following goals which I wanted to.

Iam rendering JTable with combobox.
Somethings which I want is still not happening and I dont know why?

Iam attaching an image also along with this.

http://i337.photobucket.com/albums/n399/turniphorse/TableCombo1-1.jpg

How could I achieve the following things.

[1] The "First" and "Last" column show the same comboItem.Want the comboitem in the "Last" column to be last.Is using only 1 renderer and editor for both the columns. Need only 1 selection in the cell(yellow background)

[2]The table cells shouldnt display the comboitems.They should be blank.Only when the user selects a comboitem from the combobox,then only it should be displayed in the corresponding cell.

[3]The Table "setValue" call from the button is not changing the cell value.As you can see in the "getTableCellRendererComponent".Iam using the table value.
How could this be done?The comboboxes are noneditable.

This code is compilable.Would be nice if anyone could point out the changes that should be made in the current code.Would really appreciate it



Thanks in advance..
P
9 years ago
Hi Craig,

At the end of the day after playing with the program,I have 1 more question left...
Is it possible to prevent drag from a column in the Drag Table so that a NO_dROP cursor appears in that cell,when the user tries to perform a drag from there...

Sorry for the trouble....

Thanks
10 years ago
Thanks craig.As always, that change did the trick....
Really appreciate,for the time you have spend on this.Was actually waiting for your post....

Now I know whom to put forward any swing questions,If I have some...

Thanks once again..
10 years ago
Hi Craig,

Iam using j2se 1.5.So I tried to follow your lead by implementing the DragSource and DragTarget.

But I have still problems.As I have said earlier in my post ,I want to Drag and drop from Table1 to table2.

The stumblingblock for me was

[1]Want to change the cursor to change to "NO_DROP" in Table2(Column-0),as I dont want drop in this column.Thats not happening...

[2] Also when a drop is performed in a column other that (column-0) in table 2,the cursor changes to the "move" cursor(Exactly what I want.Thats fine.)But when I move the same drag to Column1 -The cursor doesnt change to the "NO_DROP" cursor...


Have put the code for Table1 and Table2....Guess something has to be done in the "dragEnter" of DragSource Listener ,but unfortunately dont know what....#

Could you give me a hand on this....

Thanks....

10 years ago