Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just ran across a link to this thread so I thought I would update: I quit two months ago. One less smoker in the world.

Ancient Dragon commented: Great Job :) +36
jasimp commented: Congratulations :) +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try it with your code base one level higher, like this

<html>
<applet code="Sorter"
        width="800" height="300"
        [B]CODEBASE="C:\Documents and Settings\Paul\My Documents\NetBeansProjects\Sort2\build\classes">[/B]
</applet>
</html>

It looks like you had the package directory in the previous code base.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use the following query to get a list of the non-system tables

select name from MSysObjects where type=1 and flags=0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ouch :(

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Hope you aren't low on time or disk space ;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This took about 2 minutes to create:

(It actually took longer to screen shot it and get the attachment posted than it did to create it)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why not just create the GUI itself with Netbeans (or some other GUI tool) and a little bit of dummy data? You don't have to actually wire it up at this point.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I just fixed the behavior that he was unhappy with, but yes, it is a bit more efficient. He was re-processing the entire content of the document when he only needed to re-process up to the current insertion point for the highlighting.

sciwizeh commented: Very good information, thanks +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your caret is going to the end of the document because you're removing and re-inserting the entire content. The caret is just staying at the position of the last insert. You can fix that by changing these two lines in your SyntaxDocument2.insertString() method

String str2 = super.getText( 0, super.getLength() );
        
        super.remove( 0, super.getLength() );

slightly to get only the "upstream" portion of the document plus the string you are entering

String str2 = super.getText( 0, [B]offs+str.length()[/B] );

        super.remove( 0, [B]str2.length()[/B] );

That way you are only operating on the portion up to and including your current insert position and the caret stays at that position.

There is probably an easier way to do that with a DocumentFilter that doesn't require removing and re-inserting all of that content, but I've never used styled documents much so I can't say exactly without playing around with it more. You might take a look at them and see if it could save you all that insert, remove, and re-insert overhead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Third. It was posted twice just today. Try counting again.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Duncan, yours is the third posting of that URL. I believe the point has been made.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I agree with the others above: enough with this public crush thing you have going on. At best, it's disrespectful and you should be old enough to realize that.

mitrmkar commented: Well said. +7
William Hemsworth commented: :) +7
Comatose commented: Pwnage! +12
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, you can. You do have to import the class, but you don't have to instantiate it. Static methods are invoked directly from the class name.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, you don't need to instantiate the class to call static methods. Just prefix the method with the class name. So using stultuske's class above you would simply call

String response = Messages.askInput("Enter some data");
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That is exactly what the static methods on the utility class that stultuske suggested above would do for you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I never posted in Community Introduction either.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Because you have declared and added that text area as a local variable in your constructor here

JTextArea txtAreaArticle = new JTextArea(15,40);

That is declaring a new JTextArea of the same name local to the constructor block. You need to drop the "JTextArea" type from that statement if you want to initialize the one you have already declared at the class level.

txtAreaArticle = new JTextArea(15,40);
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

By 21 posts, you should know how to use [code] [/code] tags.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And did you try it with larger values? Run this with various values for the sleep time

long start = 0;
for (int i=0; i<20; i++){
    start = System.currentTimeMillis();
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
    }
    System.out.println((System.currentTimeMillis() - start));
}

And the doc on currentTimeMillis() has the following to say

public static long currentTimeMillis()
Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That is the currently selected file, so you could do this

JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File("Write your file name here"));

Personally, I don't see why you would want to, but that will do it.

(And there is no one named "u" here. Leave the lazy chat speak at the door)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at SwingWorker. You may want to read this tutorial as well: http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I can follow the language just fine. It is the concept of cheating as some kind of "buffer" that eludes me.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What? I cannot make any sense out of what you are trying to say there at all.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i dont violate any copyrights or so, so from their perspective my potential thoughts do not cause any problem. i dont violate any laws.

I did not mention violation of laws. Show them this thread if you are so proud of it.

By the way, one of the christian missioners in my company gave me two dvds and i am totally persuaded that darwinism is just impossible because even the most primitive cell requires all at ones and simultaneous structures. i will post the name of that dvds later.

This has nothing to do with the discussion at hand and belongs in the lounge.

stephen84s commented: Bang on target !!! +7
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think the entire thread should be deleted. It's certainly in conflict with the "We only give homework help to those who show effort" mantra that can be found posted through the site.

I also have to wonder how your employer and coworkers would feel about the level of ethical flexibility you've pronounced in this thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't think you should have to do anything special with it since Java uses unicode by default. Perhaps the file itself is using some other encodiing? Maybe this link could be helpful: http://www.exampledepot.com/egs/java.nio.charset/ConvertChar.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So you are just posting answers to homework questions so students can Google them easier?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, those look like XML tags, so an XML parser is one possibility.

The regex package is another. http://java.sun.com/docs/books/tutorial/essential/regex/index.html

If the text is simple enough, the methods on the String class itself, such as indexOf(), will probably suffice.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just to provide a little more explanation why that works and why you had the previous difficulties, you were executing your animation loop code that slept and called repaint() on the event dispatch thread - which is the same thread that is responsible for processing those repaint() calls you were sending. By moving the animation code to it's own thread, you free up the event dispatch thread to respond to the repaints() that you are requesting.

You can read more about concurrency concerns in Swing here if you like: http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html

VernonDozier commented: Good link. +11
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Those are things determined by the OS. Windows display the icon of the file type association. Altering any of those would require Windows-specific code to alter the registry for that association. Java itself does not get involved with those things.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You only need to return a single value from that method: the value the user selected from the menu.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at the list of properties that are always available through System.getProperties(). OS is one of them.

You can also dump a list of all of them to sysout easily with the following code

System.getProperties().list(System.out);
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't need JUnit at this point, you just need to place some debugging println statements throughout your methods so you can see what is going on inside them (if you don't have or know how to use an IDE debugger).

Trying to learn how to use JUnit is not going to speed up solving this problem at all - it's just going to add a lot of unnecessary confusion.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

System.getProperty("user.home") will give you the users home directory.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

masijade means that the TextField variables themselves might be null, as in you have not initialized them with "new TextField()". He wasn't referring to them being empty.

The code you posted above doesn't really answer that question, because you didn't post the addField() method code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, two things:
1) Load the Image through an ImageIcon

img = new ImageIcon("gifTest2.gif").getImage() ;

ImageIO.read() returns a BufferedImage, which doesn't update the ImageObserver. I couldn't tell you the exact reason why because I don't really mess with images much, but perhaps an animated gif needs a VolatileImage instead of the BufferedImage the read methods gives you.

2) Make sure your signature matches when you override a method. Instead of imageUpdated(), you need

public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
        repaint();
        return true;
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Do you see any variable named "A" declared in your main() method?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Drop the [] from "A[]" in this portion array_sum(A[],first,last-1) , you only need those in the declaration, not when using the variable. The array itself is merely "A".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So use String.valueOf(int).

notuserfriendly commented: strongly approve and thanks so much +3
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can't place this line

passGet.setEchoChar('*');

in the class body directly. It must be within a method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, assuming that you have imported the TextArea class, those two lines compile just fine in my IDE.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You've probably missed a type designation on a variable or parameter somewhere above that code then, because there is nothing wrong with those two lines. Which line specifically is indicated as the cause?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Most likely because the formula you implemented to determine "match all digits" doesn't do that at all. Those are rather odd relationships that you are expecting between the division and mod results. You need to break the numbers into their components before you make the comparison checks.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should probably explain what it is doing wrong, what you expect it to do, and any errors you receive, rather than expecting people here to pick through it and play "find the problem with this".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This uses the JDOM packages.

org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
Document doc = builder.build(new File("test.xml"));
XPath xp = XPath.newInstance("table[tr/td/b/font='Nohup Files']");
List<Element> result = xp.selectNodes(doc.getRootElement());
XMLOutputter out = new XMLOutputter();
for(Element e: result){
    System.out.println(out.outputString(e));
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
<html>Name1<br>
Grade1<br>
Name2<br>
Grade2</html>
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

table[tr/td/b/font='Nohup Files'] seems to work for getting the table element, if that's what you are wanting. I tried it out with the following structure

<root>
    <table>
        <tr><td><b><font>Not this one</font></b></td></tr>
    </table>
    <table>
        <tr><td><b><font>Nohup Files</font></b></td></tr>
    </table>
    <table>
        <tr><td><b><font>Other</font></b></td></tr>
    </table>
</root>
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm think you can set the working directory through the project properties in Eclipse, but I don't have it here to look myself. I would think the root working directory would be "Desktop/CS Programs/CS 2410/CS 2420" but that may not be the case.