Leo Max

Ranch Hand
+ Follow
since Sep 27, 2009
Merit badge: grant badges
For More
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 Leo Max

Sorry I was trying to explain my situation. I brought up the editable text area in my first msg in order to show you what I want to happen when I press the home key.
so yes you're right. you want to find the index in the string where the caret would be if it were displayed and the home key was pressed?" <- EXACTLY


In my last message, I told you exactly what I was trying to accomplish. I'm trying to automate the process of "fixing" a line that has both languages in it such that the order of words will be correct.
11 years ago
Hi. I do wish to simulate the the HOME key because I'm only dealing with strings. There is no editable text area.




Okay I shall tell you exactly what I'm trying to do

I wrote two lines as an example in my first message. Take the first one and paste it in notepad. Click anywhere on the sentence and then press the HOME key. You'll see that the cursor moves to the end of the second arabic word. Right click on that spot (or just press the button in the keyboard that simulates a right mouse button) and choose INSERT UNICODE CONTROL CHARACTER then choose RLE RIGHT TO LEFT EMBEDDING.
You'll see that the order of the sentence has changed (look left to right) to arabic english arabic arabic.

Right click anywhere in notepad and choose SHOW UNICODE CONTROL CHARACTER. You'll see that this special character is put at the end of the line. I know the unicode rep of this character \u202B. I tried adding it but it didn't work. So I figured I'd do it like I usually do but couldn't find a way to simulate the HOME key.
11 years ago
I have a string: hi there my name is Leo
I want to move the cursor to the beginning of the sentence. That line that flashes whenever you click on any text editable area. I want it to move to the beginning of the line so that I can write something. I don't want to use \r or newstring + oldstring. It HAS TO BE HOME The line I'm writing isn't necessarily in English.

Ex: English: hi there my name is Leo <-- the HOME button takes me to right before hi (look at it from left to right)
Ex: English + Arabic: مرحباً أنا name ليو <-- the HOME button takes me to right after the second word (look at it from left to right)
11 years ago
How am I supposed to test it? Write a timer function and see how long it takes? And I didn't claim anything. But from your response, I'm going to go with method 1. Thank you.
11 years ago
In the arabic language, sometimes you need to draw two tiny forward slashes on top of or under letters. For example, the word also in arabic has these slashes on top of the o so also//

now i want to write a spell checker in java that looks into things like this.

method 1:
- use a 2D array where column1 has all the words that require the slashes but don't include them in it so index00 will be also and column2 has the same words but with the slashes in the appropriate places so index01 will be also//
- use a for loop to go through each line where in each line, we use stringtokenizer to go thru each word comparing it to the words in column1. Once you find it, replace it with column2.

method 2: same 2D array but first you use a regular expression. i create one that has all the words in column1. then i write if (m.find()) change found to true (default false) and exit. then i check if found is true. if it is, i use stringtokenizer. you know the rest


I'm looking for the efficient way to do this as the title says.

Pros of method2 (Yes im starting with 2) using regular expressions saves you the trouble of having to go through the for loop as some lines might be correct the Big O notation of using a regular expressions is at least O(n) just like the while loop which means that it's efficient because a while loop with a for loop in it is On squared

Cons of method2 it might be efficient but the lines and their spelling depends on the user writing them so you might find that you're not really saving much time using this method

As for method1, there's not much to say. Well it depends on your opinion of the pros and cons of method2. You might surprise me and tell me that the notation of regular expressions is worse than O(n) so I might as well stick to the for loop. Only O(n) and I will be entering the for loop anyways.

What do you think?
11 years ago
So to confirm, any of the 3 books (the forth is uml which you said was removed) would suffice ya? Also, just like scja was renamed to ocaj, so was the exam number right?
11 years ago
Hello,
I have a follow up question please. I checked the books recommended in the faq section. They're several years old. For the last 5 years, haven't there been any updates/developments on 5/6 that Oracle requires its OCAJ takers to know? Is SE 6 like an OS? Once it's out, it's out and the patches added aren't important compared to the OS itself?
11 years ago
Ya I know how I can do this myself. I jsut figured it'd be easier if it already existed But I don't know what JSPLITPANE is. I had to google it just now when I read your reply. I was thinking I'd use a frame, container set to borderlayout or any other one since it's only two panels i'll b using, and of course the two panels. one to set my jtree and the other to display list of names of files and folders. So thank you for the reply. I will be using JSPLITPANE instead. It's new.
12 years ago
I know the code that will list all the drives available. I also know the code that will list all the files and folders in a given directory. Finally, I just learned that we can use jfilechooser in open/save scenarios and jtree to list the folders the same way windows explorer does. You have the collapse/expand column on the left and on the right you see the avialable files/folders in that location. My question is:
Is there a code that does all this or does everyone have to write it themselves? I just want to know if java has something like this before or not because I haven't foudn one but that could be because I'm googling the wrong keywords
12 years ago
Fixed it. I hope this code helps whoever's in need



the list of jar files you need to add when setting the classpath are:
dom4j-1.6.1.jar
xmlbeans-2.3.0.jar
poi-3.8-beta3-20110606.jar
poi-ooxml-3.83-20110606.jar
poi-ooxml-schemas-3.8-beta3-20110606.jar

i got these jar files from http://www.apache.org/dyn/closer.cgi/poi/dev/src/poi-src-3.8-beta3-20110606.zip just extract the contents to a folder
i would like to read the contents of an ms word 2007 document. does anyone have a code that i can read for this? I found the jar file online. finally. even tho i dont get an exception anymore, it's still not printing anything. so i wrote a fewy sys.print lines to find out where exactly am i gettin gstuck at and it's the same prb. for some reason, that line /****/ simply wont execute -_-
Hello. Ya I found out when I googled the error I got. I'm trying to find the jar file but with no luck. I downloaded xmlbeans from http://xmlbeans.apache.org/sourceAndBinaries/ but there was no jar extension. i downloaded it and extracted the contents but couldn't find a file called xmlbeans or xbeans or xmlbeans 2.4.0. I'm trying to find it online but no luck.
Now i'll apologize for asking the following but when you say class path, where exactly are you point to?
My app takes in the location of hte .docx document and prints the first 3 lines. I'm getting an error at the line i marked xxx. The exception is: Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException



any ideas?

Thank you.
well it's working on my pc and laptop now. whe ni open 2003 ms word it works. but no luck with 2007. i thought it would work since they said 97-2007. well at least i got it to work. i went tback to using exe4j and this time i added the jar file (generated by ide) and the 2 jar files from poi and it worked just as well. guess that answers my question then.
alas 2007 isn't supported. either that or im doing something wrong again

Any thoughts btw? When I enter the location of the ms 2007 docx file, it shows nothing. but when i show it a doc created by 2003 it shows me whts inside.


EDIT: im here now reading webpage and it says that i need a diff package for 2007? instead of hwpf i need xwpf. but i cant find it when i type the import line. import org.apache.poi.xwpf doesnt exist >.>


EDIT: found it! i totlaly forgot that for the import lines to work i needed to right click on the prj-properties-libraries-add jar/folder. the jar file needed for 2007 is poi-ooxml-3.8-beta3-20110606.jar

well this was fun. We all learned something. Thank for your help. And yes, it's still in it's early stages. The method I use to print the contents doesn't help me if I wanted to get them one line at a time so I need to write some workaround code.
12 years ago
Like I said, after some reading i discovered that instead of installing ant and going through hell, that my ide, netbeans already prepares a jar file for me
I'd like to ask a different question please. I read somewhere that Sun doesn't have the libraries needed to reading ms documents but apache does; poi. Is there a version limit on it? I'm running the app on a different laptop that has ms 2007 running and it's not printing anything.
12 years ago