BestJewSinceJC 700 Posting Maven

If you just want something to practice then just go to a college's website, find the level course that matches your skill level, and do a random project on there. We aren't here to give project ideas.

BestJewSinceJC 700 Posting Maven
If you truly made an effort to use the code tags you would have used them correctly. There is a sticky at the top of the forum showing how to use them. There is a button on the post reply box that inserts code tags. You can also "reply w/ quote" to this post and you'll see how to do it correctly.
BestJewSinceJC 700 Posting Maven

"...and in a specific spot on the page?" I don't understand. Where on the page do you want it to print?

BestJewSinceJC 700 Posting Maven

If your inner classes are implemented in a way that does not cause a compiler error, I do not think you can get errors such as memory leaks or anything of that nature. However, when defining inner classes inside an abstract class, I'd be careful about what techniques and syntax are/aren't allowed.

BestJewSinceJC 700 Posting Maven

I'm not sure of your level of experience so I'll post this just in case you don't know stack issues, which you may:

http://en.wikipedia.org/wiki/Stack_overflow

BestJewSinceJC 700 Posting Maven

Good question, I'm actually not sure. I'm not a mod - it just makes it very hard to help people if things aren't in those code tags that color, format, and number the code. But yeah, go ahead and put errors in code tags as well.

BestJewSinceJC 700 Posting Maven

Sorry, that post was very long. However there are a few other comments I have:

1) The for loop that I made some changes to is obviously incomplete. I intentionally erased some of your working code. The idea is to show you how to create a DVD and put it in the array - I'm not saying that your other code doesn't work.

2) In the for loop that you wrote, I noticed that you have an "if something is < 0" statement, followed by an "else" statement. The else statement doesn't have any brackets around it. . I'm not sure if that was a mistake or not. It's line 66 in post 3 (your second post you made in this thread).

BestJewSinceJC 700 Posting Maven

Ok I think I have a good start going here, though I do have a few more questions;
1) (Inventory class) @line 47 I should be using "input.nextLine();" to be able to enter more than one word in the title, but when I do it will stop with an error saying "Exception in thread 'main' java.util.inputMismatchException"
2) (inventory class) @line 39 As you suggested I used "DVD[] myDVD = new DVD[count]" and says local variable is never read. I have the same problem @line 25 with "restockFee". Is this a problem with them not being initialized or am I not calling the method in my sub-class?

1) Your program says, "how many DVDs would you like to enter?". Then, you get the response from the user and you read it in as an int. However, what the user entered was not just an int. Let's say the user enters 10 and then presses enter. Their input was 10 and a newline ( \n ). However, when you said input.nextInt(), you only read in the 10, and you left the newline there. So change your code to the following:

System.out.println("How many DVDs would you like to enter?");//prompt for length of array
		count = input.nextInt();//accept user input
		String getRidOfThisNewline = input.nextLine();

You have to think about "how to read in data" as what the user entered, not in terms of what you want to get. Thinking about it as "I want to read in an int" is what you …

BestJewSinceJC 700 Posting Maven

I'm not knocking adatapost's suggestion - he gives great suggestions - but his suggestion might be a little too advanced for what you're doing right now. Either way, you might want to explain exactly what your assignment is, because "naming Nodes" doesn't make sense to any of the three people who have commented here and we like to consider ourselves good java programmers :)

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

An easier way to do it might be to have a JPanel inside a JPanel. The outer JPanel would use a BorderLayout, and the JPanel that you add to that one would have a GridLayout with one column. The idea being that when you added the second JPanel to the first, you'd add it to BorderLayout.LINE_END. . then anything you added to that JPanel would show up on the right side.

This is my idea, however, I'm now working with swt not swing, so it might not work in swing. . I might be combining my knowledge of the two layout tools.

BestJewSinceJC 700 Posting Maven

Post the code for your class in the code=java code tags and I'll help you solve this error. I've gotten similar errors before as well. If you don't know how to use code tags then read the sticky at the top of this forum.

BestJewSinceJC 700 Posting Maven

No, you did not say that. You said, "I've tried playing with the preferred size . ." As you know, setPreferredSize and setSize are two completely different methods. But anyway, I'm glad you got it working. Cheers

:)

BestJewSinceJC 700 Posting Maven

Use the setSize method. The preferred size is just that - preferred. The layout manager is probably ignoring your preference, whereas if you use setSize, you might have better luck. Oh, and set the size of the scroll pane, which contains the other object. If that doesn't work try setting both.

BestJewSinceJC 700 Posting Maven

You can't "dynamically name" variables in Java. I don't know of any language where you can do that, although one might exist. I might be confused by what you're trying to do, but there is a LinkedList class in Java. If you were to use

LinkedList<YourClassnameHere> list = new LinkedList<YourClassnameHere>();

A linked list would be created where you could store and add and remove your Objects from the list, among many other useful functionality. You could simulate the user being able to "store only what they wanted" by simply having a String variable in the Objects that are in the Linked List or something like that.

BestJewSinceJC 700 Posting Maven

Correct. You have no entry point for your application (it can not run). The correct declaration is public static void main(String[] args). You're missing the brackets. Also, the code tags that you would have used had you read the forum rules.

:)

BestJewSinceJC 700 Posting Maven

First of all it looks like you have a bunch of arrays that contain related information. . the item number, price of DVD, and name of a DVD all go together, correct? If the answer is yes, then you should create a class, perhaps called DVD, that has the necessary fields to encapsulate this information. For example:

public class DVD{
String title = null;
double itemNumber = 0.0; 
double dvdPrice = 0.0;
double stockValue = 0.0;
}

You'd need to add a constructor so that you could create a new DVD. This would transform the above class into the following:

public class DVD{
String title = null;
double itemNumber = 0.0; 
double dvdPrice = 0.0;
double stockValue = 0.0;

public DVD(String theTitle, double item, double price, double value){
title=theTitle;
itemNumber=item;
dvdPrice=price;
stockValue=value;
}
}

Additionally, you would probably need getters and setters for that class. But by using that class, you would avoid the need to have four different arrays when the information is all related - since it is related, it should be stored in the same Object. This would mean in your main class, you would have the following array:

DVD[] myDVDs = new DVD[count];

Then, when you asked the user what the prices were and whatnot, you could use the constructor of your DVD class to create a new DVD. And you would then put that DVD into your array. Looking at the methods that your teacher says you need to write, you could …

BestJewSinceJC 700 Posting Maven

Yes. Use the getResource method. You can find a lot of stuff on daniweb in this forum about loading images. Try this first though.

http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html

]

BestJewSinceJC 700 Posting Maven
BestJewSinceJC 700 Posting Maven

Easy to use or easy to build? I recommend Java, although surely I'm pretty quick to recommend Java so you might want some other opinions as well. Java is great for user interfaces - ease of programming and ease of use, but I'm not so sure about processor and time intensive tasks like tracking sleep patterns and such. There are a lot of arguments about how Java compares speed wise to languages like C++, but I think recently they have been compared as closer to equal, with C++ being the victor in most cases, as in the past. Again, might want to do your own research on this or wait for other opinions.

BestJewSinceJC 700 Posting Maven

I don't understand your description. You want to "break" after a parameter like value is displayed? What? And how can you do something after 30 threads, when you only have one thread running in your program?

BestJewSinceJC 700 Posting Maven

Maybe I'm not sure what you are saying.

But image that you created a bunch of private JFrames in Java. Would you expect other applications to be able to get the references to those JFrames?

BestJewSinceJC 700 Posting Maven

Yeah, we've used StringBuilder before. Personally I would have used Scanner, which could have been used just as effectively, but I'm glad you got it working.

Also, what is the reason for the 'continue' statement? Doesn't it just do nothing in your case? Btw, you could equivalently say:

if (search != '.' && search != ',' && search != '!' && search != '?') result.append(search)
BestJewSinceJC 700 Posting Maven

php is not a programming language it is a scripting language.

BestJewSinceJC 700 Posting Maven

you didn't use code tags. read the stickies. all of them. completely.

BestJewSinceJC 700 Posting Maven

Yeah - you can put \n in any String Object and it will do the same thing. Also, click 'Mark as Solved' once people solve your issues or once you work them out on your own.

@ Sneaker:

No problem, I was just making sure the OP was aware.

BestJewSinceJC 700 Posting Maven

I'm not sure if you want to consider process different from process. or if you want to consider them the same thing. Which is it? If you create a Scanner, read in things one by one, put them into an ArrayList if they are unique words, and increment a counter for that word - then process and process. would be considered different since the Scanner by default would read in the words as "process" and "process." and a search of the ArrayList when you got to "process." would not match "process". If you want them to match, then strip punctuation and any special chars that you don't want from the end of every word.

PS nice help Jenn.

BestJewSinceJC 700 Posting Maven

Yeah, have your class implement the Comparable interface, then use Collections.sort(ArrayList goes here). With ints it is probably even easier than that though,.

BestJewSinceJC 700 Posting Maven

After you set the size call frame.revalidate(). It might be frame.validate() though. If you're expecting the actual thing to resize in the netbeans editor window, you're going to be disappointed. That resizes the frame in the running application. At least I think it works, it's been awhile since I've done swing though.

BestJewSinceJC 700 Posting Maven

See my post above yours. Then declare "c" on the correct scope level (i.e. declare it outside of the for loop). Then see if you're still getting errors. Post any errors you're getting.

BestJewSinceJC 700 Posting Maven

It doesn't work because you declared a variable, "c", inside of a for loop. When that for loop ended, that variable went out of scope (was destroyed). So in the next for loop where you tried to refer to "c", the compiler has no idea what you're talking about.

BestJewSinceJC 700 Posting Maven

Nope. And even more strangely, if I put that code that I showed you guys inside the main method - it works. But if I put it inside the constructor - it doesn't work. (And I can't run it from the main method since it isn't going to be the main app).

BestJewSinceJC 700 Posting Maven

The important code:

Browser browser = new Browser(shell, SWT.NONE);
	URL url = this.getClass().getResource("/example.html");
	browser.setUrl(url.toString());
	shell.open();

P.S. I've carefully considered what Masijade and others told me in the other thread; the example.html file is located in multiple locations, including in the same directory as the .class file. . I also tried url.getFile(), and I also tried "example.html", among a lot of other attempts, none worked. I got the html page to display once or twice with getResource(), and it always works if I specify the exact path, but I cannot do that in the real product. If anyone sees any errors please let me know. I also looked at the example on the swt website at eclipse.org, but their example forces the user to specify the pathname (by browsing their machine) so it is fundamentally different than mine.


The full code:

final Shell shell = new Shell(display);
	shell.setText("Basic Tutorial");
	shell.setLayout(new GridLayout());
	shell.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	Browser browser = new Browser(shell, SWT.NONE);
	browser.setLayout(new GridLayout());
	browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	URL url = this.getClass().getResource("/example.html");
	browser.setUrl(url.toString());
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	shell.dispose();
BestJewSinceJC 700 Posting Maven

You could start by posting this in the javascript forum. If the mods don't move it first.

BestJewSinceJC 700 Posting Maven

Netbeans is not a compiler, it is an IDE and it helps you build GUI programs in swing, so it will compile things for you but it itself is not a compiler. I don't know what bluej is (sounds familiar).

edit: posted at the same time.

BestJewSinceJC 700 Posting Maven

You didn't explain what happy vs. unhappy is. And you didn't post your code in code tags.

BestJewSinceJC 700 Posting Maven

If you declare the variable as final, it will work. Otherwise you won't be able to access from within an inner class. And I'd be wary of taking sneaker's advice because I'm not sure that it is completely correct. You might want to do more research if you are concerned about the issue.

PS an IDE like Eclipse would have suggested to you that you should make the variable final, and all you would have had to do is click the link on their suggestion and it would have done it for you.

BestJewSinceJC 700 Posting Maven

You compiled it and had a problem? Then post your error including the line number. .

BestJewSinceJC 700 Posting Maven
JButton Reset = new JButton("Reset"); 
    centerpanel2.add(new JButton("Reset"));

Should be:

JButton Reset = new JButton("Reset"); 
    centerpanel2.add(Reset);

Again, follow coding conventions - it should be named "reset" not "Reset" - this would have made it easier to see this mistake. Anyway, simple mistake, your program should work now. You added the actionListener correctly, but you then created a completely different JButton which didn't have the actionListener attached. Anyway, what you should get out of this is to avoid assuming your problem lies in one area, always investigate all possibilities.

MasterGoGo commented: Fixed my problem +1
BestJewSinceJC 700 Posting Maven

Use the modulus operator, %. If you type modulus in google you can learn everything you need to know about it, and you'll see why you need to use it, so I won't explain further.

BestJewSinceJC 700 Posting Maven

MasterGoGo. . is there any reason you're using Panel, Frame, Button, etc instead of JPanel, JFrame, JButton, etc? Reason being because I believe the latter are more up to date. As another note, variable names are by convention lowercase for the first letter, for example names that follow convention: reset, theResetButton, otherButton, etc.

Oh: And it would probably be easy to help you with the NullPointerException, but you need to post in CODE=Java tags, because I don't know what line number your NullPointerException is referring to.

BestJewSinceJC 700 Posting Maven

You can use the File class: construct a File object, specifying the directory (folder that contains your audio files), then use the File object to get a list of the audio files. Then use the code snippet that I posted on the other page to loop through each file in that directory, and play each. Your question would be the first thing in the loop, and once that question was answered the file would be played, then that process would repeat.

BestJewSinceJC 700 Posting Maven

Huh? Can you clarify what you're trying to do?

BestJewSinceJC 700 Posting Maven

With a for loop. And threads. See Ezzaral's response. I'm at work so I can't be mroe helpful right now but look

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

BestJewSinceJC 700 Posting Maven

Making variables global for the sake of easily doing something is usually a bad programming practice. Instead, you'd usually make get methods and set methods to get your data and to modify it.

BestJewSinceJC 700 Posting Maven

Ooh. Thank you. :)

BestJewSinceJC 700 Posting Maven

Other than the comparison method (which I don't have time right now to look at), the rest of it looks good.

ArrayList restOfTheRow; could be changed to ArrayList<String> restOfTheRow; and you also need to make sure to instantiate it so ArrayList<String> restOfTheRow = new ArrayList<String>();

BestJewSinceJC 700 Posting Maven

No, it is not in a jar file. And yes, I have all the needed permissions, and no permissions are denied, I just checked under the file's Properties. I'm trying to make it so that when this application is distributed the file can be located.

File path: C:\Documents and Settings\Kyle\workspace\First Build\SummaryReport.rptdesign

Java file location: C:\Documents and Settings\Kyle\workspace\First Build\src\first_build\BIRT\BirtCard.java

.class file location: C:\Documents and Settings\Kyle\workspace\First Build\bin\first_build\BIRT

URL myurl = this.getClass().getResource("SummaryReport.rptdesign");
			System.out.println(myurl.getFile());

Causes:
java.lang.NullPointerException. The exception comes from the second line, myurl.getFile(), because myurl was previously set to null because getResource returned null.

And I'm looking into access rights.

BestJewSinceJC 700 Posting Maven

The purpose was more than likely to do it with some sort of loop. Regardless, don't post full code solutions to entire programs.

BestJewSinceJC 700 Posting Maven
URL myurl = this.getClass().getResource("/SummaryReport.rptdesign");
			File file = new File(myurl.getFile());
			System.out.println("Name=" + file.getAbsolutePath());

The above code seems to get the resource. But I guess I am going about creating a file connected to that resource wrong? Because I cannot subsequently open a FileReader connected to that file. . I am assuming this is because the File is not set up correctly. I'm pretty tired right now, but I followed this pretty far including searches on daniweb etc, and am not getting anywhere so I'd appreciate any help.

BestJewSinceJC 700 Posting Maven

why don't you look at my post on the previous page that shows how to do this. All you need to do besides using that code is to install the JMF stuff which you can do by following directions on google.