7,116 Posted Topics
Re: The person who created the jar had the choice of what files (in addition to the class files) he included. Mostly people don't include the source, but some do. A jar file is really just a .zip file, so use any zip program to see what's in it. Although you … | |
Re: You call dispose() without an object, so that's equivalent to this.dispose(); You didn't show enough code for us to see what kind of Object "this" is, but maybe it's something that doesn't have a dispose() method? | |
Re: First sort out the references to the ArrayList containing Strings - it doesn't - it contains Students. Then, this is the plan: Read each line from the file. Split each line into its individual fields. Check which fields are N/A so you know what kind of Person this is. Create … | |
Re: That's a really detailed spec. Just start at the beginning and do exactly what it says. | |
Re: Line 101 you compare the names with == That tests for being the same object. To test if two different string objects contain the same text, use string1.equals(string2) | |
Re: Here's what I think your code should be doing: You have an array shapes[], and an int shapeCount that holds the number of shapes you currently have stored in shapes[]. OK. To ADD a shape in the mouse drag handler, you create a shape of the appropriate kind, and add … | |
Re: For keyTyped events use getKeyChar(), not getKeyCode() (For KEY_TYPED events, the keyCode is VK_UNDEFINED.) | |
Re: The Character class has methods for testing isLetter etc. You'll find the doc in the usual place. | |
Re: "The Java EE platform is built on top of the Java SE platform. The Java EE platform provides an API and runtime environment for developing and running large-scale, multi-tiered, scalable, reliable, and secure network applications." EE is used for developing large corporate-type apps in environments with big web servers and … | |
Re: Here's a strategy that may work for you - it's kinda like a recursive strategy, except that the levels are pre-defined. Pseudo code fragments follow: [CODE]new Document(Scanner input) { create empty ArrayList of Pages while (not input.EOF) add new Page(input) to ArrayList } new Page(Scanner input) { create empty ArrayList … | |
Re: [QUOTE]class GradeCalculator3 is public, should be declared in a file named GradeCalculator3.java[/QUOTE] What exactly about that do you not understand? | |
Re: Have a look at Apache "Tika" [url]http://tika.apache.org/[/url] It may be a bit over the top for what you need now, but it's probably the comprehensive file metadata utility you will find in Java. | |
Re: Come on guys! This is a really good question! I certainly want to know the answer. | |
Re: It is valid code. Class B will inherit v and String sayHello(), but nothing in the code makes use of that. | |
Re: You need a JTable. Check out the API, and Google for examples | |
Re: Just for interest, why do you want to do that? The implementation automatically uses a separator that is appropriate for the system upon which it's running. [QUOTE]The conversion of a pathname string to or from an abstract pathname is inherently system-dependent. When an abstract pathname is converted into a pathname … | |
Re: Hi NewOrder. You seem very close to losing the last person who is really trying to help - being rude to Norm is very short-sighted. Consider a few points from your last post: [QUOTE]i need someone to look at the syntax. cause it is causing the problem.[/QUOTE] No it isn't. … | |
Re: Given a Person object you can get its values by using its accessor methods getName() and getTime() - although the second still needs to be written. You will also probably find the for/each loop format easier to work with: eg [CODE]int time = 0; for (Person p : q) { … | |
Re: You have defined LessNoise inside the class Noise, so you need to refer to it via the Noise class. I guess this is an error in your bracketing, if so, just move the definition of LessNoise outside the Noise class and that should be OK. Indenting your code properly will … | |
Re: I guess you missed this at the top of the main forum page? [QUOTE]don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.[/QUOTE] | |
Re: Have a look at JFrame's setIconImage(...) method | |
Re: Package names are interpreted starting from all the places in the classpath. Eg classpath begins with . (current dir), package is com.xxx.yyy - java looks for a dir com/xxx/yyy in the current dir. If it doesn't find that it does the same thing starting at the next location in the … | |
Re: Start with some kind of frame (eg JFrame), add a MouseListener, try something simple (eg draw a small rectangle wherever the mouse was clicked - you will need to override paintComponent(...) ) and work up from there. As you go you will (a) learn a lot and (b) discover exactly … | |
Re: Lines 14 and 16 guarantee that the deltas will both be >= 0, so if(deltaX<0 && deltaY<0) will always be false | |
Re: Obviously your Google is broken (because nobody would post a question like this without first doing a little research of their own), so I searched for you and found this Wikipedia article as the first hit. [url]http://en.wikipedia.org/wiki/Plain_Old_Java_Object[/url] | |
Re: I used to use that approach, but JDK 1.6u10 (or thereabouts) has REAL transparent windows. It's buries in awtutilities for now, will be fully exposed in Java 1.7 Here's a demo I wrote: [CODE]import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Shape; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import … | |
Re: Unless there are privacy issues, maybe its a good idea to keep all the data instead of a summary, ie for each vote cast add a record to the list showing who voted/when voted/what voted for. That way each record is unique and never updated. Then derive the summary statistics … | |
Re: [CODE]for (a = 0; a <9; a++) { for (b = 0; b < 9; b++){[/CODE] Am I the only one who plays chess on an 8x8 board? | |
Re: Where is userdata[][] defined and initialised? | |
Re: You could solve this in a generic sort of way by also having a "mask" image - same size as the card images, with each pixel either black or white depending on whether or not you want to compare the corresponding pixels in the two card images. That way, if … | |
Re: [URL="http://sourceforge.net/projects/jwinapi/"]This[/URL] should do it. includes a sample prog that does exactly that. | |
Re: SimpleDateFormat. (It's in the API reference) Create a format to match your data, then use the parse(...)method to convert to a Date | |
Re: The code you show does not produce the output you show. Show us matching code and output. Post code, properly indented, in code tags. | |
Re: You may find that the size isn't set until the button is added to a container (JFrame or whatever) and that container is layed out (eg via pack()). The size definitely should work any time the button is visible on the screen. weiphos2012 - we try to be helpful and … | |
Re: You can call methods from inside other methods. | |
Re: Yes, open an output file and it overwrites the previous. Try opening the fileoutput stream in append mode, eg new FileOutputStream(fileName, true) | |
Re: If you post with code=java tags we may be able to see which line is line 180 where the problem happens (or maybe you can just tell us which line it is). Anyway, on the line you have either an uninitialised variable or a variable that has been set to … | |
Re: Yes, it's a cast/box too many in one step. [CODE]Float a = 3f; Float a = (float) 3; Float a = new Float(3);[/CODE] all work ps Khalid Mogul may be a great guy, but I would always prefer to find an authoritative source in the official Sum/Oracle documentation | |
Re: I can't see where you add those fields to anything. | |
Re: This code (assuming the class end brace was there somewhere later, and ignoring the non-issue of putting braces round a single-statement if) runs perfectly for me. Maybe the problem's somewhere else in the rest of the code or the system config, not in this code. Do other programs run ok? | |
Re: [QUOTE]i interlocked my whole pieces[][] array into conditions and methods, now i cant get them out and manipulate them[/QUOTE] Yes! Seeing that is the first step to fixing it. Time to step back and do a little design before doing any more coding. Get that array out, clean up its … | |
Re: Interesting question! My take is: new B[]; populates the array with two <references to type B>, so the second statement fails because a new A is not a B. ie: A is a reference to an array that can hold references to type A, but a[0] and A[1] (perfectly validly) … | |
Re: If you get all your results into some object (eg an ArrayList<Result>) then it's very easy to write/read the whole object to/from a file in a single staement using ObjectOutputStream/ObjectInputStream. That's probably the easiest way if you don't need to do record-based I/O | |
Re: I've followed this with some bemusement. You say "This means I need to impose some artificial constraints on the range of values we allow.". So what exactly is wrong with this: [CODE]do { sdX = (int)Math.round(r.nextGaussian() * xCenter + xCenter); } while (sdX < 0 || sdX >=w);[/CODE] | |
Re: Since Java 1.6.(something) there has been an implementation of transparent windows, which lets you display window content (eg text or shapes such as elipses) without the window itself being visible. It's going to be a full feature in Java 1.7, but right now you have to know where to look … | |
Re: Casting to a subclass of the objects actual type doesn't work. The subclass may contain variables and constructor code that the superclass does not have, so simply pretending its a subclass instance isn't going to work. You can create a kind of copy constructor like this: [CODE] public DateTime(Date d) … | |
Re: OO - yes; pure OO - no. Java is mostly OO, but incorporates non-OO "primitive" types such as int, boolean etc which are not Objects. For "pure" OO you need to go to something like Smalltalk, where everything is an object. | |
Re: You need to loop through the array of valid names testing each one against the entered name. If you find a match you can stop searching. If you reach the end of the loop and you haven't found a match then the name is invalid. Compare Strings by using the … | |
Re: Look closely at the difference between line 48 (wrong) and line 41 (better). The problem's near the beginning of the line. |
The End.