BestJewSinceJC 700 Posting Maven

Hi John, thanks for using code tags. In the first part of the code tags though, it should say CODE=Java which will put line numbers. If you do that and then tell us which line numbers are relevant (i.e. where you arrive at the end of the copying, and what line causes the Exception according to the error you are getting) that would be helpful. Thanks & welcome to Daniweb

BestJewSinceJC 700 Posting Maven

The problem is that timeRepaintIn - Calendar.getInstance().getTimeInMillis() is a negative value. Which means that Calendar.getInstance().getTimeInMillis() is greater than timeRepaintIn. So you might want to rethink your logic on deciding how long to sleep for.

BestJewSinceJC 700 Posting Maven

Thanks for the offer. . I'll let you know if I need that. What do you mean by doing a callback btw?

BestJewSinceJC 700 Posting Maven
public class SampleAudio{
	public static void main(String[] args){
	try
	{
	File f = new File("pathname.mp3");
	Player m_Player = Manager.createPlayer(f.toURI().toURL());
	m_Player.start();
	}
	catch (Exception e)
	{
		
	}
	}
}

The above code is JMF and actually works for playing an mp3. However, the quality is pretty bad, and it seems to occasionally mess up (either wrong rate or something like that).

Also, as far as the QT for Java download thing being crappy, yes, the directions I found on apple's site were definitely incorrect. But I just went into my build path under my project in eclipse, clicked configure, add external jars, and went under program files, quicktime, and found QT Java (its a zip file) under one of the folders there. Then I added that, so hopefully it will actually work.

VernonDozier commented: I have nothing to add to this topic, never having worked with sound, but I figured I'd +rep to cheer you up! :) +17
BestJewSinceJC 700 Posting Maven

edit: nevermind

BestJewSinceJC 700 Posting Maven

This is incredibly frustrating. The installation instructions for QT for Java say to download the normal QT program, then in custom install, specify that you want QT for java. But there is no custom install... it just installs itself on my computer.

BestJewSinceJC 700 Posting Maven

Ok, I will look into that then. I saw that mentioned as well at some point when I was wading through the countless Java Sound examples from 1998-2003, looking for something up to date. Lol.

BestJewSinceJC 700 Posting Maven

wait: I just remembered, I think the reason I was looking into JMF to begin with is because the other java sound api doesn't support mp3 format by default. I'm going to sleep. Too frustrated.

BestJewSinceJC 700 Posting Maven

edit: I see a lot of other threads on Daniweb on this. But after 2+ hours of reading about Sound in Java, I'm even more frustrated, so I have some questions.

1. Is the Java Sound API sufficient for the following operations: Playing mp3 audio files, pausing, and fast forward/rewinding to various points in the song? I've been looking at JMF but it is frustrating me and I don't need any of the capabilities except what I just mentioned. JMF seems to have massive capabilities which I am sick of wading through, but I will if it is absolutely necessary.
2. This question assumes the Java sound API is good to use for my purposes: The Java Sound API says that a Clip allows you to "play sound from an arbitrary position in the clip". This would be helpful to implement fast forward and rewind, I would think. But it also says that a Clip is preloaded. . will a 4-8 minute song fit into memory ok, or should I use a SourceDataLine instead?
3. Does anyone have any other tips or resources?

BestJewSinceJC 700 Posting Maven

I'd say your first problem is your inability to use code tags, leading to nobody caring enough to waste their time to read your code.

BestJewSinceJC 700 Posting Maven

http://www.cs.usfca.edu/~wolber/SoftwareDev/C/CStructs.htm

Use a Struct, put both of your linked lists in there. I forget how to make a linked list in C but I think all you need is two pointers, one for each linked list. Beyond that I can't help you, because if your linked list had to have more than one piece of data I would think that each Node in the list would also have to be a Struct. But it sounds like you already know how to handle the linked lists and just need somewhere to store them both... if that is the case, then like I said, use a Struct.

BestJewSinceJC 700 Posting Maven

I'm sure google would be pretty helpful with that question.

int[] array = new int[10];
array[0] = 0;
array[1] = 1;
array[2] = 2;
array[3] = 3;
.
.
.
array[10] = 10; //ERROR! An array declared as having 10 can only be indexed at 0-9.

BestJewSinceJC 700 Posting Maven

Yep, no problem. Somebody else on this forum told me that solution a while back as well. Also, mark this thread as solved

BestJewSinceJC 700 Posting Maven

Yep, no problem... I would guess that Ezzaral knows what it is, he always seems to know the Swing issues.

BestJewSinceJC 700 Posting Maven

At the start of the paint method, call super.paintComponent. This should have the effect of clearing the screen. If it doesn't, draw a new rectangle on the screen that is the color you want (white or gray probably) that fills the whole screen.

BestJewSinceJC 700 Posting Maven

ahh, sorry, I see now. That is indeed very strange, since the API says that calling the remove method on the container is equivalent to calling the removeLayoutComponent method directly.

@ adatapost: Yes, but he is saying the removeLayoutComponent method is not working, while the other method is. This might indicate that the other method is doing some extra work that removeLayoutComponent does not do. Perhaps removing the Component from the Layout and removing it from the Container are different? I don't think so though.

BestJewSinceJC 700 Posting Maven

Suggestion - You never called validate on the JFrame after removing the previous center panel and adding the new one. If you were to call validate, then call repaint, I think the call to the ZOrder method might not be needed. The reason for this suggestion is because calling validate causes the layout manager to re-lay out its components. If it re lays out its components, and there is only one component in the center, you should not have to set the Z order. The Z order is just the "Z" positioning of a Component, if you thing of an X-Y-Z axis graph, I think.

kvprajapati commented: I agree. +3
BestJewSinceJC 700 Posting Maven

When I hear people say stuff like "I love programming" and "if it doesn't pay well, what's the point?" in the same sentence, I think that one of the statements is a lie.

But it does pay well, so I don't know why anyone would say those things in the same sentence to begin with. And the answer is yes, it is worth it. Once you put in the initial couple years of work, the relearning stage isn't nearly as difficult. But even the initial learning stage is pretty cool because you learn a lot of interesting things about computers, programming languages, and the capabilities of technology. It can be frustrating at times, but how do you expect to learn something truly worthwhile if it is not challenging? To be perfectly honest, I would not be a programmer for a living if it did not pay well. But don't make it sound as if it isn't an enjoyable field, or as if the frustration and difficulty that everyone who is good at programming has faced wasn't worth it, because for me, it was definitely worth it.

Also, I'm sure you realized Narue, but only the first part of my post was directed at you, the rest was directed at the OP.

BestJewSinceJC 700 Posting Maven

To make an Integer Object, use

int myInt = 0;
Integer myInteger = new Integer(myInt);

Also read about automatic boxing and unboxing. To make you own class that allows you to change the int value, it is extremely simple:

public class ChangableInteger{
int theInt = 0;
public ChangableInteger(int intPassed){
theInt = intPassed;
}
//Put your set method here, I'll leave it to you to write.
}
BestJewSinceJC 700 Posting Maven

What the poster above posted might look confusing, but what he is saying is a good way of doing this: Each String in the array will be the "name" of the index it is at. So index 0 of the array is named zero, and so on. This means in order to find the name of "20", you would use array[20] and it would return "twenty" since that is what you stored there.

The implementation is a little different - for example in C, I think an array of Strings is actually a 2D array of chars, but you get the point, I hope.

BestJewSinceJC 700 Posting Maven

This should help you out:
http://www.devx.com/tips/Tip/14510

Just add a pop-up message when the if evaluates to false, and you're good to go!

Good luck

And how does that longer code that needs to be adapted offer improvement over my answer? Besides which, that code seems like it will keep going regardless of any errors. So it would take 123ddd45 and produce the String 12345, would it not? Maybe I read it incorrectly. Not trying to start an argument here, just asking.

BestJewSinceJC 700 Posting Maven

It is, but I was suggesting that the center panel could have its own layout, and that layout could be a CardLayout. That way you could flip to the next frame simply by using the CardLayout's show method, and none of the repaint etc would be necessary. Since your project works now its kind of pointless though, but its a thought for the future.

VernonDozier commented: Good suggestion regarding CardLayout. +17
BestJewSinceJC 700 Posting Maven

http://www.daniweb.com/forums/thread199998.html

Look at post number 3 in that thread. If you create a Pattern based on the word the user enters, you can loop through your input, counting the number of times you encounter that Pattern.

BestJewSinceJC 700 Posting Maven

That's a good question, and one I can't answer. Question though: is there any reason you didn't use a CardLayout for the center panel or whichever one was displaying the frames? I think that would make the display easier to manage.

BestJewSinceJC 700 Posting Maven

No, it is not a "reserved method". He means for you to create the method, so that after your Object is created, you can use that method to pass it to the other class. A small example:

public class ExampleClass{
     String myString;
     public void setString(String otherString){
          myString = otherString;
     }
}
BestJewSinceJC 700 Posting Maven

You'd need to make use of the knowledge that each line is 11 columns long. So every first number you read in goes in the first column and so on. You can use the modulus % operator to figure out which column things go in. If the number of columns in your file can vary, then you will need to count how many items are on the first line. You could do this a number of different ways - I'd personally go with reading the entire line into a Scanner Object, then figuring out how many were in that line from there.

BestJewSinceJC 700 Posting Maven

Maybe I didn't understand the conversation here - but why can't you use a JComboBox as an editor for a single column? Does this tutorial help at all, or do you already know the info?. . Because it seems like it would be easy to save and implement. And Ezzaral already told you how to get the values from the combo box, right?

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#combobox

BestJewSinceJC 700 Posting Maven

This depends on how the user is indicating that they are done filling out the JTextField. Are they clicking a button? Is an event fired when the key is pressed? Since you didn't say I'll assume the user is clicking a button once they put their input in the text field. Then implement ActionListener for that button, and in the actionPerformed method, get the text field's text. Then use Double.parseDouble(textFieldsTextHere); -- if it does not throw an Exception, then the entry was a number. There might be a better way but that is pretty easy to do and will probably fit your needs.

BestJewSinceJC 700 Posting Maven

Ok, thank you, I see what you're saying now. I'm glad you mentioned that because it might have escaped testing.

BestJewSinceJC 700 Posting Maven

I finished my program hours ago and it works for case sensitive input. . appreciate the tip on the CASE_INSENSITIVE argument. I notice your comment, "The method Pattern.quote is required to escape all the regex special characters and treat them as literals." Why would I want to do that in this case? Or were you just mentioning it as a general tip? Because in this case, I want to match any characters found before what the user entered and any characters found afterwards.

BestJewSinceJC 700 Posting Maven

We just did it with regex Patterns. How do I make this pattern so that the "ptrn" portion, which is a String the user entered, could be in lower OR uppercase? But so that this wouldn't cause errors if the user didn't enter alphabet characters?

patrnStr = ".*" + ptrn + ".*";

BestJewSinceJC 700 Posting Maven

What would be the best way to implement dynamic search? So, for example, given the words:

the, then, behemoth, abchemto

Typing in 'he' would return all of the above words since they all have he in them. Is the best way to do this using a Trie?

BestJewSinceJC 700 Posting Maven

For "going through the maze" I'd recommend searching daniweb and reading the other five hundred maze threads.

BestJewSinceJC 700 Posting Maven

Also, consider the fact that you can jump to the next word by reading in the next chars after each word until you find the space. You know the next word is after that space.

BestJewSinceJC 700 Posting Maven

I don't know what line 12 is because you didn't use the code tags correctly. If you had, it would have put line numbers there. Anyway:

Check out the String class's toCharArray() method. Once you get your char array, iterate backwards over it, printing out each character. If you want to store the backwards String, then do the same, except put each character in a second array, or continuously add it to a String like this: String whatever = whatever + theChar;

BestJewSinceJC 700 Posting Maven

Probably because your data is stored on servers, possibly multiple different servers, and you need some way of accessing it.

BestJewSinceJC 700 Posting Maven

Its hard to measure in terms of difficulty. Classes typically use a programming language whereas my internship, and probably most others, use enterprise programming tools. These tools are typically either about bringing multiple technologies (could be multiple languages) together in order to make a cohesive application or are about making coding easier by providing functionality for you without you having to do much coding.

example of some tools:
using MySQL as a database, SOAP: XML & JSON for middleware, front end/GUI could be done in Eclipse RCP or AJAX.

The only one I've got a decent amount of experience in is Eclipse RCP. I can definitely tell you that if you even know what terms like SOAP, SOA, Cloud computing, MVC, etc mean, that will make you look good in a lot of interviews that you would have. So to answer your question about difficultly, both class and my internship are challenging in different ways. My internship has been much more practical though. Nobody is going to ask you to write an entire standalone application in Java. Real work will usually involve servers, databases, possibly more than one user interface, and separate teams to bring it all together (for example on a three tier type architecture).

That's the best explanation I can give you right now, feel free to ask any more questions. Someone like Ezzaral might be better if you want to get more specific, but keep in mind it sounds like he works in …

BestJewSinceJC 700 Posting Maven

Yeah, seriously. How could you be nearing graduation and never have typed "ls" on the command line. That depresses me.

BestJewSinceJC 700 Posting Maven

The most precise unit is as precise as you can get, so Rashakil's analogy does not make sense to me. You can get less precise, but not more precise.

BestJewSinceJC 700 Posting Maven

Try opening it with this constructor:

public FileInputStream(File file);

First, create the File Object. See if creating the File object also throws an Exception; if so, print the Exception's contents and getMessage() message in here. Also use the File class's file.canRead() method and tell me if it returns true or false. These are just some thoughts - there's no harm in using a different class to try to find out information about the problem, although this may not yield any answers.

BestJewSinceJC 700 Posting Maven

It looks like I could have helped, your explanation is quite confusing though. What I don't get is why you don't simply post an example of what you are trying to accomplish. For example,

I'm trying to transform 1 into 2
1. array that holds: 1 2 3 4 5
2. array that holds: 1 1 2 2 3 3 4 4 5 5

BestJewSinceJC 700 Posting Maven

Which is exactly what Masijade seems to be addressing, except he did not go into much detail. At the very least, you'd need your PDF data in a separate class, and a simple "controller" that provided access to the data.

BestJewSinceJC 700 Posting Maven

Start by thinking about what inventory management is, and what processes it typically involves. Then continue by making each of those processes into a piece of functionality, dividing the functionality, and coding

:)

BestJewSinceJC 700 Posting Maven

If you want to write an Object out to a file, you need to implement the Serializable interface, look up "Java Serializable". If you just want to write text into a file, that is different, and you could use

BufferedWriter out = new BufferedWriter(new FileWriter("outfilename"));
out.write("aString");
out.close();

Or a billion other ways. (Another)

PrintWriter pw = new PrintWriter("c:\\temp\\printWriterOutput.txt");
pw.println("PrintWriter is easy to use.");
pw.println(1234);
pw.close();
BestJewSinceJC 700 Posting Maven

Maybe I don't understand your hierarchy, but I believe you can also use super.methodName() to call the superclass's method instead of the class's method.

BestJewSinceJC 700 Posting Maven

Use a Scanner to read the numbers from the text file, and read them in as ints, not as Strings.

Scanner scanner = new Scanner(new File("filePath"));
int next = scanner.nextInt();

Good luck.

PS the reason your current code doesn't work, at first glance, seems to be because you are reading in the numbers one line at a time, not one number at a time. So you have an array of Strings, but if the text file was:

12 11 10 9 8 7 6
5 4 3 2 1 0

The array would have two strings:

1) 12 11 10 9 8 7 6
2) 5 4 3 2 1 0.

Integer.parseInt(String intRepresentation) can only parse something which is an integer. Obviously, that entire line is not an integer - its a whole bunch of integers. Again, this is what I think at a quick glance, I could be wrong, but I'm tired.

BestJewSinceJC 700 Posting Maven

You can use regular expressions. I'm not good with them since I hardly use them, but they aren't that bad, just a set of rules to specify which characters to match basically. Look up regex or regular expressions java on google.

BestJewSinceJC 700 Posting Maven

1. Read the forum rules.
2. Read how to use code tags in the sticky
3. Explain what your code is meant to do, what it does, a description of what exactly you need help with, and where you think the problem is.

BestJewSinceJC 700 Posting Maven

What do you mean by experience... major? Next year I'll be a senior but when I got my internship, I was a Junior. The majority of programming I've done at school has been done in Java, but the courses have been fairly intense and focus on different things from class to class - in other words, they aren't Java classes, they are classes focused on specific things that use Java while learning those things. And what money you can expect really depends on what company you join and what your goals are. You can get an internship as a sophomore (do it!) and get the same wages as a junior in the same internship. I've seen internship wages ranging from $7-$20+ hourly. The big companies pay mostly around 17-25. I don't really know about smaller companies, I only really interviewed with a few big ones before getting and accepting an offer, at which point I stopped interviewing.

BestJewSinceJC 700 Posting Maven

I'm an intern right now for a fairly large company - they gave me a job offer so I'll be working full time next year. I've been talking a lot to people at my company, and learning about a lot of technology currently used in industry, so I'd be glad to answer any questions you have about those types of things. Salary and benefits are very good, but they vary a lot from company to company. You'll find that companies like Lockheed Martin, Northrup Grumman, Booz Allen Hamilton, etc are offering a lot of positions and great wages these days. IT is not suffering in the US economy like most fields. Oh, and yes, I'm a Java developer and I'm currently using Eclipse RCP (Rich Client Platform). I'm working for Booz Allen Hamilton (if you look it up it will say its a consulting firm - its actually difficult to summarize what BAH does without telling you about a lot of the projects, (info I don't know the vast majority of) but basically, BAH finds solutions to technical problems - how they can be improved - and implements those solutions. And interns (and full time employees) at BAH work from the office, but have a lot of leeway with hours and things. For example, a full time employee only has to average 40 hours a month, not necessarily 8 a day. And with permissions of a manager, employees can work from home temporarily. I know of some employees who work …