7,116 Posted Topics
Re: If you have a specific question then start your own thread. | |
Re: I couldn't see where you call excute() for your SwingWorker, which may explain why it doesn't execute. In any case, all it seems to do is to start a swing Timer, so why bother? Just start the timer from your ordinary in-line code. If you get exceptions. post them so … | |
Re: If you want a specific L&F for your application then it's best to set it programatically - just think about what happens when you or someone else runs it on a different machine. | |
Re: You are reading images one ata time, but then trying to create a new array for each image. You can't assign an image to an array, just to one lement of the array, eg private ImageIcon[] icons = new ImageIcon[4]; icons[0] = getClass().getResource(name[0]); icons[1] = getClass().getResource(name[1]); // etc (or use … | |
Re: Looks like basics[i] is null for some value of i. Print i and basics[i] at that point in the code to see which element is not initialised, them backtrack in your code with prints to see why/where the initialisation is missing. | |
Re: Are you using a layout manager? Layout managers ensure that your forms can re-size as required, eg when moving from one OS to nother with completely different font sizes. They come in various flavours, from very simple to you-can-control-everything-in-great-detail. See http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html | |
Re: You use a loop just like in C, except that instead of just breaking out of the loop you use a tidy do/while loop, eg do { // stuff // get answer for y or n to continue } while (answer.equals("y")); | |
Re: The thread sleep method doesn't work well, if at all, in Swing. Your thread blocks Swing's own thread from executing, so the screen never gets updated. You have to use a swing Timer to update your animation every "n" miliisecs. Here's a trivial exaxmple that shows the correct technique: import … | |
Re: Come on gedas, you're better than that. Just Google ` java send http request` | |
Re: Good start, but inside the loop you have an array that you also need to loop through - ie you need 2 nested loops. | |
Re: Have you tried a GridLayout with a variable height and a width of 1? | |
Re: That's because whiteBoardapplet doesnt implement it. It's ABHandler that implements it. | |
Re: PriorityQueue uses a private array to hold the queue. It automatically re-sizes the array when needed. By specifying an initial capacity you set the initial size of that array. Its just an optimisation thing - if you know how big your queue will be then the array can be made … | |
Re: Line 91 you call getWidth() without an explicit object, so that's the same as this.getWidth(). "this" is the current instance of JavaApplication12, which extends JFrame and inherits getWidth() from it. So 132 seems like a perfectly reasonable value. You will see a different result if you call ant.setVisible(); rather than … | |
Re: DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" What have you done so far? | |
![]() | Re: That seems to suggest that players is declared as a String - you haven't posted it declaration. ![]() |
Re: There's no code there that can update the database, so how exactly are you trying to update the values? | |
Re: I just had a quick look, so maybe I missed something , but anyway... The original correctly uses a Timer to call its actionPerformed method at regular intervals. That's how the animation is updated and finally repaint() is called to tell Java that the screen needs to be updated. (Java … | |
Re: Your main method runs, it creates an instance of your class, and then it's finished. If you add some code to call the "f" method then you should see some output. ps having a variable called f and a method called f isn't an error, but it is potentially confusing. | |
Re: ^ basically right, except that nowhere does Java define any mapping between 0 and 1s vs the boolean values false/true. Bitwize operators work on each bit of an int value, the logical operators work on individual boolean true/false values, but there's no connection between these two versions. | |
Re: > I've changed: > discsArray = new ArrayList<CD>(); > peopleArray = new ArrayList<Person>(); > To > discsArray = new ArrayList[CD]; > peopleArray = new ArrayList[Person]; Those changes completely destroy the original meaning of the code, so although they may compile it's unlikely that it will now work as intended. What … | |
Re: Probably becuase v2 is zero on line 24. Perhaps you should be setting v2 somewhere? | |
Re: Reverse or Rotate? The requirement and title are contradictory. | |
Re: Realistically I don't think you can. If machines on the network chose not to talk to you then you can't find them. You can use the "ping" protocol to find machines that are happy to respond to a "ping", but that's about as far as it goes. | |
Re: 1. In a linked list the nodes are not numbered, so it makes no difference whether you chose the count from 1 or 0 as long as you count the correct number of total entries in a consistent way. 2. Each node in a linked list contains an Object, and … | |
Re: FYI my Win 7 JDK/JRE installation didn't set any program association for .class files, just .jar's | |
Re: Zaad's suggestion is a good way to go. You can improve it slightly to protect against people searching the web for well-known MD5 values by "salting" the password, ie adding some extra garbage characters (hard coded in your program) to the password before calculating the MD5 digest. | |
Re: You don't say how you re-wrote it, but for future reference, a Java char is a numeric value. If you get a single char (eg by converting a String to a char array) then you can just use that value in a numeric expression without any further conversion, eg String … | |
Re: > Can we create a text file of the size specified by the user? Yes. Just ask for the size and write that number of bytes to a new file. For large amounts of space it may be safer to create a new directory and fill that with 1GB files, … | |
Re: Do you mean each node can contain an int **and** a String, or that each node can contain an int **or** a String, or do you mean you want to have two types of lists, one containing only ints and the other containing only Strings? (Each of those has a … | |
Re: > An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1. http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html | |
Re: How exactly do you intend to use the boolean array? What is the logical proposition that will be true ort false for each element? Most people define a Card class, and have an array of Cards. | |
Re: @satyarao: I think after one year the OP has either solved this or given up, regardless of the value or otherwize of your suggestion. | |
Re: See line 30. After you press OK it is waiting for you to type in file name on System.in | |
| |
Re: Seriously - you have 9000+ line java file? That's insane. Break it up into individual files for each class. Usually "error: class, interface, or enum expected" means you've messed up one or more { } pairings, but with a file that size you'll have a job finding them. If all … | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Start your own thread. | |
Re: What exactly do you mean by the object's name? Objects in Java do nor have names. You can have an instance variable `String name;` in the Fruit class and set that. | |
Re: You create the window's contents in the `init` method, but nowhere do you call that method. This is not an applet. | |
Re: Line 239 after an error you re-call getCoordinates but you do NOT use the returned value at all. | |
Re: It's pointless trying to add more code until the code you already have compiles and, as far as is possible, executes correctly. Stage 1: fix those compile errors. | |
Re: That looks like your keys are Strings. In the Comparator you could parse them into integers and compare those values. | |
Re: That's println (short for print line). You have a capital I for India instead of a lower case l for Liverpool | |
Re: setRGB(x, y, 2000000) - why not? plus, see this: http://www.devdaily.com/blog/post/java/getting-rgb-values-for-each-pixel-in-image-using-java-bufferedi | |
Re: How about just not declaring it static? | |
Re: You have overidden JApplet's paint method, which is the method responsible for ensuring the contents are painted. That's why they don't get painted. Add a call to super.paint(g) as the first line of your paint mathod. This will ensure that everything in the applet gets painted before you draw your … | |
Re: In Java you do this by creating a utility class with all those functions defined as static (so they don't need an instance to be created). A good example is the Math class in the standard Java API http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html you can simply `import` this class at the start of your … | |
Re: I'm going to disagree with the previous advice (sorry guys). Initialising word to some arbitrary value will make the compile error go away, but it won't help your program to work properly. Looking at the code, it looks like you want word to contain the text that the user typed … | |
Re: You should be able to do it by checking System.in.available() inside the timer's loop each second to see if the user has typed anything. If he has then you can use a next... to see what that input was, and exit the timer loop as appropriate. Unlike next... available() does … | |
Re: If you have "n" tickets each with "m" numbers on it, you can represent that as a 2D array [n][m] ... The `Collections` class has methods you can use to `sort` a list of numbers into order... |
The End.