318 Posted Topics
Re: But you have answered your own question in your thread title. [B]It does not exist. It is not a standard java package. Whoever is teaching you java must have told you this.[/B] One simple way to accept input from a user is the Scanner class. Which is an actual java … | |
Re: For a method to return a type other than void, you need specify the type you wish to return in the construction of the method. [CODE]public void frostCake[/CODE] This method declaration tells you 3 things. 1.the modifier (public) 2.[B]the return type[/B]...in this case the return type is void 3. The … | |
Re: Ok, it seems the nextLine() method doesn't retrieve the "nextLine()" Because, if you just call nextLine() once, it prints the array fine. I made this simple code to test, and it works fine for me. [CODE] public static void getFile(Scanner f) { String[] sArray = new String[12]; //listFlights=new Flight[count/3]; //num=listFlights.length; … | |
Re: For your first question, instead of repeating code, you could remove the code after the first 2 cases and only have it executed on the 3rd etc.. i.e. [CODE]public void showFeelings(int howManyGoals) { switch (howManyGoals) { case 0: case 1: case 2: System.out.println("Oh dear, not very good"); break; case 3: … | |
Re: You haven't posted your panel classes/main class code. | |
| |
Hi, I've been thinking about this for a while. What is the best way to design a program? What I don't understand is how people think of which classes etc. they will use and what they are called. For example, in a program which simulates the card game BlackJack. How/why … | |
Re: [QUOTE=sariberri;1438567]Pleaseee help me guys. I can't figure out why the elements in my array are null. I'm reading in from a file and take each line and saving it as a variable in the object and then adding the object to the array. This is what I have so far...when … | |
Re: [CODE]Nest nest = new Nest(); myOtherClass = new MyOtherClass(nest);[/CODE] This creates an instance(object) of your Nest class. | |
Re: I don't understand your question, What are you trying to do? | |
Re: [QUOTE=davetheant;1436458] and yes, I'm sure. It compiles and runs up until i use a method from that library.[/QUOTE] If it compiles and runs before you try to use methods from the library, chances are it can't find the library. So are you 100% sure you have the library in the … | |
Re: I am completely confused about what this thread is, and what everybody has posted. It seems to be a jumble of different unrelated threads all thrown into one. | |
Re: You seem to mix up the <..> signs. For example, in your enterNumbers() method, your for loop never runs([B]simple debugging using System prints told me this[/B]). You have the wrong sign in the loop's definition, it should run until it is [B]less than[/B] the length of the array, not greater … | |
Re: Java Methods: [url]http://download.oracle.com/javase/tutorial/java/javaOO/methods.html[/url] Java IO: [url]http://download.oracle.com/javase/tutorial/essential/io/file.html[/url] All you need to know about "functions" and file IO in java | |
Re: If your print out reads: 5+3 =8 Then you must not be printing everything in the same statement. If this was your intention, then using System.out.print instead of System.out.println on your first print will allow your second print to be on the same line. If it wasn't your intention, then … | |
How can I do this? I'm not even sure what the problem is so I can't really search google. Why is this not possible?: [CODE] #include <iostream> #include <cmath> using namespace std; void vGameLoop(); void vDoMenu(); void vDealMenu(); void vDoDeal(); int main(){ vGameLoop(); return 0; } class CCards{ const int … | |
Re: Or you could pass custArray into the backupfiledefaultfilename() as a parameter. | |
Ok, The only reason I'm asking this is because I want to be absolutely clear on it. In C++, if I write [CODE]int* ipSomePointer;[/CODE] [B]Is this the same thing as:[/B] [CODE]int *ipSomePointer;[/CODE] [B]or[/B] [CODE]int& iSomeRef = ...;[/CODE] [CODE]int &iSomeRef = ...;[/CODE] It does give the same result as each other … | |
Ok, I am sort of new to C++, and I just came across something that I don't fully understand. [CODE]int main(){ int iX=5; { int iY=30; std::cout<<iY<<std::endl; } std::cout<<iX<<std::endl; return 0; }[/CODE] What does it mean when I make a code block with no if,else etc..? Does it just make … | |
Re: Your loop runs from i=1;i<21 ...So if you revert the value of i to something below 21, then it will then start from that number. I don't see the confusion :D | |
Re: To return the length of an array, use array.length Not array.length() | |
Re: If you are researching scope of variables etc. It would also suit you well to understand static methods and variables. [url]http://download.oracle.com/javase/tutorial/java/javaOO/classvars.html[/url] | |
Re: Sadly, this is what happens to people who are too lazy too learn. If the original code actually worked, and the person you [B]stole[/B] this off copied his entire project...Judging by your lack of effort and understanding, I conclude your problem is most probably a very basic one....*HINT* You cannot … | |
Re: [QUOTE=jon.kiparsky;1420356]If you're just starting out, you should certainly not be using an IDE, any more than you should use a calculator in a math class. The conveniences provided by an IDE might be useful for someone who knows what they're doing, but they will prevent you form learning things you … | |
Re: Sorry, I completely missed the error you posted. | |
Re: crossposted here: [url]http://www.java-forums.org/advanced-java/36607-perform-hamming-window-fft-java.html[/url] You should link to all your crossposts, that way, if you find the answer in one of them, it may allow somebody searching for the same answer to find it easier. | |
Re: Instead of using a while loop, change it to an if statement. Then call your Play() method in the actionPerformed method. Therefore, you take input, check it, enter the play method, then if nothing gets done, it returns to the actionPerformed and does it again. What this is doing is, … | |
Re: Help - Yes. Write it for you - No. Post your attempts. | |
Re: You could use simple error checking using try and catch like this: [CODE]import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner myScanner = new Scanner(System.in); double num1, num2, answer, loop_calc=1; String num1s="",num2s=""; boolean isNum = false; //boolean for while loop String operator, rego; System.out.println("Welcome to the … | |
Re: A major difference is, an Array has a fixed size, whereas an ArrayList can grow dynamically. Arrays can hold primitive types like int, whereas ArrayLists [B]cannot[/B] they can only hold [B]objects[/B] Also, Arrays are not part of a class, therefore they have no methods that you can use to change … | |
Re: OP is from 2007 guys, Unless he is terribly slow, I would assume he has gone past this problem. | |
Re: How on earth is that any easier? Because you type a few less characters?? | |
Re: You posted the error wrong, you just posted your main class again. Besides that, It looks like your problem lies with your actionPerformed method. You don't have one. You call a method [CODE]public void ActionListener(ActionEvent e){ String name=answer.getText(); String greet="Hello,"+name; greeting.setText(greet); }[/CODE] it should be [CODE]public void actionPerformed(ActionEvent e){ String … | |
Re: Well, if it was a problem that is not obvious, why not post the solution here for others to see? grrrrrr | |
Re: If you want a space between the 2 different outputs at the end, just add an empty string. [CODE]System.out.println(name +" "+ cname);[/CODE] | |
Re: Seems your problem lies in your logic for testing palindromes. [CODE] if(!Character.isLetter(ch) && !Character.isLetter(ch1) && ch != ch1) { found = false; }[/CODE] So, this means, your method will only return false if all these expressions are true. So, if I enter "hole": the first two checks will return false(they … | |
Hi, I've started to learn about threads in java. I'm trying to make this simple animation of a rectangle. Where am I going wrong? I was under the impression that if a class implements Runnable, when it is executed, it looks for the start method, which in turn starts the … | |
Re: Hey, this is a small class I wrote that has a method for resizing an image [CODE] import javax.swing.ImageIcon; import java.awt.Image; import java.awt.Graphics2D; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.awt.AlphaComposite; import javax.swing.JPanel; import javax.swing.JFrame; public class ImageResize extends JPanel{ private Image img; private int width,height; public ImageResize(){ ImageIcon ii = new … | |
Hey, I was wondering if somebody could test this out for me? I need to know if it acts the same on other pcs as it does on mine. The game seems to randomly speed up/slow down. Can you test if it does the same? [url]http://www.filefront.com/17673747/BoundingBox.jar[/url] It's a simple space … | |
Re: By draw itself do you mean using a method inside its own class to draw on the JPanel in another class? | |
First of all, Is it actually possible for a keyboard to be able to accept input from multiple separate keys at the same time? For instance, If I was to make a simple game like pong, and set an up and down key for each player, could both players press … | |
Hey, I've never really used packages before so I was wondering if what I am doing is possible. i have a package called spacewars with all my classes. I then created another package from that called spacewars.resources. I am not sure what the best way to access those resources is. … | |
Re: Well, all you need to do is paint on the panel. So in the class that extends JPanel create the paintmethod [CODE]public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g;[/CODE] then simply draw onto the panel [CODE] g2d.drawImage(bgImage,0,0,null); g2d.drawImage(character,0,0,null);[/CODE] this will draw the background image first, then draw … | |
Re: [QUOTE=Slyvr]Not originally, but I just added it. That's not related to the issue though. The problem is doing calculations to the wallet amount in the right panel and then setting that amount onto the text field in the left panel.[/QUOTE] Of course it is related to your issue. If your … | |
Re: [QUOTE=mangopearapples;1418794]Huh? That code is a loop isn't it? [CODE]while(right){x++;} while(!right){x--;} while(down){y++;} while(!down){y--;}[/CODE][/QUOTE] or use if statements. if(right) x++; //etc... | |
Hi, I'm a bit stumped. I'm trying to find out a way to make a bullet fly from a spaceship. So far, I managed to make it work but it attaches onto the coord's of my ship image(I used the position of this to map the starting position of my … | |
Re: [QUOTE=gladius33;1418939]thaaanqq u[/QUOTE] Please god don't let him come back and say that code doesn't work! Ha! | |
Hi, I am pretty sure there is a more effective way of achieving this. Would love for some input from you guys. Basically, I have a class called GamePanel and it contains this: [CODE] SpaceShip spaceship = new SpaceShip("Galatar"); public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.drawImage(bgI,0,0,null); … | |
Re: [QUOTE=endro;1418792]Would you suggest I rename it? I had some variables in there already though...[/QUOTE] it looks like you just mispelled the Payroll class. Payroll.setHours(i,hours);//..change everywhere you have payroll.method() I'm also not sure if you have these classes in the same file or separate files, so you will need to create … |
The End.