124 Posted Topics
Re: My suggestion: When te button is clicked: - disable the button. - Make a new thread, with a while loop in it. - Check whether the startTime - currentTime is bigger then the needed time. - If it is, enable the button. You should pass the button as a parameter … | |
Re: My idea: make a jPanel for each card, and use an Affine Transform object to: - Reduce the width of the panel to 0 - Paint the other image - Enlarge the width of the panel to the previous width Like James said, you'll need to some some timing. | |
Re: Well, you make a for loop, just like you suggested. Loop through all the data, and add/subtract the value from a value that you return. Start making some code, if you run into problems, we can help you. We wont do your homework. | |
Re: There is no 'printf()' in Java. This is C++ syntax. Use [CODE]System.out.println("Sum is " + sum);[/CODE] or [CODE]System.out.println(String.format("Sum is %f", sum));[/CODE] is you want to format. Also, be careful using (i-2)/i. i is an Integer, and (i-2)/i will always result in 0 if you don't explicitly tell Java to use … | |
Re: [CODE]pbT.directory(new File("/"));[/CODE] Try: [CODE]pbT.directory(new File("/text.txt"));[/CODE] | |
Re: Why would you make two classes? Just make one, and draw the entire drawing with it? | |
Re: [CODE]if (stdIDComp(stdIDInput, stdRec[j].studentID))[/CODE] As far as I can tell, you are using the variable 'j', but it has not been initialised yet. You are not in the for loop, so 'j' has no value. | |
Re: (You can just call on colour: new Colour(255,0,255). I think it is easier using RGB then what you are trying now.) You initialize drawLine as false. Every time the Applet redraws, and the drawLine variable is still false, the oval will paint. Everytime you do something with the applet, repaint() … | |
Re: With calling repaint, the GUI should call on paintComponent(Graphics g). Have you overridden that? Put a console output there to check if it is called. | |
Re: You can do two things: - Get the user input as a string (probably the easiest). - Get the user input as an integer. When you take the string: - make substrungs - parse the integer - put the four integers in the array. When you use the integer - … | |
Re: [CODE]double fedwithHolding = "FedTax * GrossPay";[/CODE] There and probably with the other one too: You are declaring a double (a number with decimal points). Then, you assign a Strkng to it. Double and String are two types, and you must make variables which the type that marches with the content. … | |
Re: Make sure you take the width and the height of the panel, when the panel have been initialized. In the constructor of the panel, both the width and the height are 0. | |
Re: I think Java is a good solution on combining a program and SQL. There is a large SQL library, that is very usable for SQL queries. I would definately not say that this is a bad idea, the question would me more like 'Can I make a usable GUI, with … | |
Re: What is your exact question? I get your assignment, please ask one. | |
Re: 1. Simple: yes! 2: Not that I know of. The methods you make are just as they are on runtime, only compiled. | |
Re: I think it would help to start programming classes with Capital Letters. This makes reading the code so much easier: [CODE]Film[] films = new Film[100]; static int numberFilm = 0; Film[] arrFilms = new Film[numberFilm]; //... new Film();[/CODE] instead of: [CODE]film[] films = new film[100]; static int numberFilm = 0; … | |
Re: Write a small program, implementing keyListener. On the key pressed method, you print out te character. | |
Re: One question from my side: Do you want to save 1 digit after the comma, or you you want to remove the last digit of the number? Assuming you want to remove one digit: - Make a string out of the double, adding - Copy the string, but without the … | |
Re: If you post all your code, we can help you with the errors. Usually, the errors have a long explanation what they are, and on what line they occur. Check that. | |
Re: I think it would help if you let the LinkedBinaryTree class implement Iterable<E>. Then, you should be able to iterate in a for loop. | |
Re: What is your question exactly? You have posted this in the java forum, not in C#, why? Please use capital letters and normal sentences, I cannot help here... | |
Re: What exactly is wrong with the method you have in your piece of code? It searches for the string that starts with K, and has a length of 4. What output is the method generating, that is wrong? | |
Re: Are you seriously using goto (or something similar using labels)? That is the worst thing you can ever do in java. I suggest the following: - Lose any labels and goto you have (I think that is solvable by using more methods than you are now) - Make more methods, … | |
Re: Please reduce the code. What methods are called when you do what? And what methods should be called when you click or select? Use a debugger and use the results to improve your code. Then, if you know all that information, you can ask here, and I'll try to help … | |
Re: Did you search on Google on Linked List? Look at the class, at the functions, and what you need to make yourself. Linked List is a great Java class, use it, like the assignment says! | |
Re: Taywin is right here. You don't want to check is a+b > c, that is valid for any triangle. You should check for a+b < c. Make sure that your isValid method includes: a+b < c, a+c < b and b+c < a. If any of them are true, you … | |
Re: I think you messed up the position variable in the button handler a bit. I changed the code to this, and it works: [CODE]public void actionPerformed(ActionEvent event) { if (event.getSource () == nextButton) { if (position < productArray.length - 1) position++; else position = 0; } else if (event.getSource () … | |
Re: I think it would be better to return null instead of "". That way, the rest of the methods can check easier if there was any 'real' return. | |
Re: Nice program :) The problem is the use of static. When you use static, the value of the variable is class dependent, and not object dependent. Example: [CODE]class A { A(int a) { this.a = a; } public static int a; // Note: STATIC } class B { void doSomething … | |
Re: Does this even compile? Errors like parenthesis should fail to compile. | |
Re: You can do anything there. It's just a method like any other method you want. You can also name it differently if you want! | |
Re: Please give a little more information on what you want to know. | |
Re: 1. The way you do it in your piece of code will work. I like FileOutputSteam better: [CODE]public class MyFirstFileWritingApp { // Main method public static void main (String args[]) { // Stream to write file FileOutputStream fout; try { // Open an output stream fout = new FileOutputStream ("myfile.txt"); … | |
Re: It may seem stupid, but I learned all my Java from the internet. I used YouTube to follow tutorials, and found out the rest myself (just looking on Google). Maybe a thing to try, and see if you like it :). | |
Re: You can also use an ArrayList<Deck>, or an ArrayList<ArrayList<Card>>. I like arrayLists because of the easy manipulation and editing of the contents. [CODE]ArrayList<Deck> deckAL= new ArrayList<Deck>(); for (int i = 0; i < 8; i++) { deckAL.add(new Deck(...)); }[/CODE] Or: [CODE]ArrayList<ArrayList<Card>> cardAL= new ArrayList<ArrayList<Card>>(); for (int i = 0; i … | |
Re: Please use normal sentences, and capital letters. Do you have Eclipse as your IDE? Even when you don't, you should debug. Make a breakpoint at the method you want to analyze, and check all your variables when the program is running at that point. Most likely some method will show … | |
Re: The problem is in the last few lines I think. When I look at your code, you are trying to make a panel. Use a JPanel instead, if you want to use a panel. I think you don't need any panel, just add the JTextArea to your applet straight away, … | |
Re: Please use Capital Letters. Also don't ask anyone to do your homework. If you have any specific question, or errors you do not understand, don't hesitate to ask, I'd love to help you! | |
Re: A null pointer exception means you are trying to access a variable, which has not been initialized. The line number is also displayed with the error, so you know which variable the error is about. Try fixing that, and if you run into trouble, ask me. | |
Re: Use a do {} while (); loop. Pseudo-code: [CODE] String input; do { input = getInputFromUser(); } while (input != 'n' && input != 'y' && input != 'Y' && input != 'N'); doWhatEverYouWant(); [/CODE] | |
Re: First point: you don't have Java at home? Then it makes no sense trying to learn programming. You got to compile, watch the errors flow, recompile, and improve. That's where you learn. My tips: download Java and Eclipse (the program you write java in), and 90% of the errors currently … | |
Re: [QUOTE]And it's due tomorrow too! BUMMER. Please! Please! Please! S.O.S p/s: I'm waiting patiently for a reply thread here ASAP. Thanks in advance.[/QUOTE] Please use code tags, and don't beg people for doing your homework... As you say, there are 6 errors. What do these errors say? Often there are … | |
Re: A class is a collection of properties, which can be initialised into any amount of objects. An object is an instance of a class, which has all the properties defined in the class. To use a class: [CODE]public class MyName { private: int myInt; float myFloat; bool myBool; public: int … | |
Re: I'll answer for him: First of all, please write with normal sentences, and capital letters, like me. It makes your text a lot more humanly readable. Your constructor is right. You copy something by saying [CODE]Triangle triangle2 = triangle.copy();[/CODE] So, make a copy method, that returns a Triangle object, as … | |
Re: That sentence in the book is indeed confusing. You should assume that Java will always use the type as you declare it. If you say int i = 0, Java will use an integer for that, and when you say short s = 0, Java will use a short for … | |
Re: First of all: get a better title. Help is what all threads are about. Could you tell me what exactly is wrong? Does the code compile? It looks fine to me. Try to describe the things that I wrong , and I might be able to help you. | |
Re: You should except any number of variables as input in your method, like this: [CODE]public static double sum(double... numbers) { double add_num; for (double d: numbers) add_num += d; return add_num; }[/CODE] [CODE]public static double average(double... numbers) { double avg_num; avg_num = sum(numbers)/ numbers.length; return avg_num; } }[/CODE] Also … | |
Re: Hi It looks like you have missed a few points. First of all, look at the facts. There are two inputs: the starting amount and the timespan. Ask those two numbers from the user. Also, every five days there is a growing, not every day. Add that to your function. … | |
Re: You can use those classes when you want to capture mouse clicks, mouse scrolls, drags, enterings, leaves, keyboard klicks, keyboard typing etc. Most of these classes are used with GUIs, to let the user have more interaction with the program. As far as I know, mostly games will use these … |
The End.