• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Building GUI with combo box

    When it said "Recompile with -Xlint:unchecked for details." that wasn't just to fill in a bit of spare time" Do what it says and you will get a proper error …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in String.equals() problem

    No need to delete - this solution may be useful to someone else. I've marked it "solved" J
  • Member Avatar for JamesCherrill
    JamesCherrill

    Marked Solved Status for String.equals() problem

    I'm currently creating a Java program in swing for my final year project simliar to something you'd find on codeacademy etc. i'm trying to compare the user input for example …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help: Project has a 10 minute big-O

    There's no problem holding it all in RAM. I found a large Scrabble dictionary with about 180k words in it, but that's only a few MegaBytes stored in an ArrayList<String> …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How can I gnerate random PPS Numbers in Java?

    What's a "PPS number"? The java.util.Random class has methods for generating random ints, arrays of random bytes etcetc
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Html Tag occurence counter

    That's a good start!
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Html Tag occurence counter

    One place to start is to split the lines using `greater than` OR `less than` as the delimiter, and look at what that gives you... or you could use `indexOf` …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Began Watching Html Tag occurence counter

    I am supposed to complete an java assignment which satisfies the following constraints 1)read an .html file which is given as input(This is not an weburl) just an file stored …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Html Tag occurence counter

    You should start by doing some research of your own, and trying things to see what works best. I know from your recent posts that you are very capable of …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Html Tag occurence counter

    Opening tags have stuff between `less than` and `greater than` symbols. Closing tags ditto, but the first thing after the opening `less than` is a `forward slash`. That should be …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Build a calculator-like layout

    The behaviour of the components when the window is resized is controlled by the layout manager. Most try to resize some or all of the components to fit the window …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help: Project has a 10 minute big-O

    Nothing there jumps out at me, but since you are usig Netbeans, why not run the profiler and see where your CPU time being consumed? It's the clock face with …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Getting file/directory path from user

    That is a valid solution, but a bit tacky - convert the file to a String path just to convert it back to a file... Much cleaner to just use …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Getting file/directory path from user

    That's bizarre - can't find the file when it just gave you that file from its directory listing but I may know why ;) Is this still the code? for …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Getting file/directory path from user

    print the File's absolute path to see how Java has completed the path, eg String path = scan.nextLine();//Files present in this path will be analysed File directory = new File(path); …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Getting file/directory path from user

    @stultuske: yes, he is reading all the .txt files in a directory and anyalysing their contents. This is a follow-up to this thread http://www.daniweb.com/software-development/java/threads/470704/java-code-to-make-an-word-frequency-counter Dinesh got the application working beautifully …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Getting file/directory path from user

    http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in help with deprecated Date, getYear(), getMonth(), getDate()

    The Date class was there in the very first Javas, but it was a poor piece of design - it doesn't handle time zones etc, wich makes it essentially useless …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help: Project has a 10 minute big-O

    > There are 5040 combinations, and perhaps 20 words in the row of the dictionary. Should it really be takin 10 minutes? Or you think there is maybe another problem …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Build a calculator-like layout

    It should respect the minimum size you specified, but you may have less luck trying to set a max size. One thing can do is add a listener for the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    Excellent! You've done a lot of work there, and showed that you can learn fast. You're going to ace this course. One tiny hint: if you're using Java 7 (like …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    That's quite a neat NPE generator if you start with an empty map. Check out this from Java 8: wordMap.put(word, wordMap.getOrDefault(word, 0)++) and pre-incrementing may be closer to what you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    Yes, a for loop is a good solution, or you could use List's subList method...
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in [URGENT]Integer array of pixels to Image

    In case this helps: I have a running application that copies Images over an internet socket by sending the ARGB int array data (compressed - but that's not relevant here). …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in [URGENT]Integer array of pixels to Image

    Any special reason to use BYE_BINARY rather than the obvious int ARGB?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    First: you did a good job on that - excellent progress. Just one problem with the sort: The Map.Entry class does not implement Comparator, so it has no default or …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    That code creates a new LinkedHashMap. LinkedHashMap is interesting because it remembers the order that its elements were added in. The method starts by getting a List of all the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in help me with this code!

    Welcome to DaniWeb. "get an error here" tells us nothing. If you have a compiler or runtime error message please post the complete message plus the actual code it refers …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    This is a really interesting problem, but because it's your homework I can't just give you the answer. But here are some things to remember: HashMaps don't have any ordering, …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    Yes, but how does that work in general? What genberal rukle do you apply? Do you ignore "er", "est", etc at the end of words? What about "deer" or "west"? …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    Thta's becuase you are checking if stopList contains the whole line from the txt file. You should be checking individual words.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    You have made this too hard by building a List of arrays. It will be much simpler if you just have a List<String> containing one word per entry. So at …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    Java 8 isn't out yet, so you can safely ignore it for now. I just posted that for anyone who was preparing to support Java 8 when it is released. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in HELP! switches and arrays

    You didn't post the requirements definition, so we have to guess exactly what you were asked to do, but ... at a guess ... Either: Your expenses need to have …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in image

    The question is pretty vague, but seems to be in two parts: How to display random image? Have an array containing all the file names and pick a value from …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in An annoying bug I can't find

    Although all that bit-twiddling can work, it's pretty tacky and error-prone. If I were doing this I would use getRGB and immediatley create a new Color instance from it. Then …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in An annoying bug I can't find

    Line 12 looks wrong - you need to set the RGB components, not just stuff a single byte into the ARGB int (the byte value will be the blue, but …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Build a calculator-like layout

    Excellent! One small point - always set the layout manager before adding anything to a container as the parameters on the add method are interpreted diferently by different layout managers …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Experimenting with layout managers

    Is that some confusion over the class name and the variable name? You declare a class FlowLayoutManagerTest but then in the main method it looks like FlowLayoutManager is a class …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Experimenting with layout managers

    You can work with `setMinimumSize` to have a minimum height and width, (and `pack()`, of course), but that gives you no control over the width or where it will flow …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Build a calculator-like layout

    Each container (JFrame, JPanel etc) has its own layout manager, so eg you could have a flowlayout for the frame, add a panel to that, and have a grid layout …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in layout manager, which one?

    There is the option of setting the layout manager to null and positioning/sizing everything in pixels using `setLocation`, `setSize`, or`setBounds`. In doing so you sacrifice any hope of portability between …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in An annoying bug I can't find

    Rather than getting the Image's buffer, and having to deal with all he types (as Paul mentions) you could use the PixelGrabber class to get an array of SRGB ints …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in An annoying bug I can't find

    Maybe its a problem with the byte arithmetic? The RGB byte values are unsigned (0 to +255), but Java bytes are signed (-128 to +127). You may need to do …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JavaFX scene builder 2: controller class

    Sorry, it looks like you may be out of luck. I don't think there are many JavaFX users active in this forum (yet). Still, don't give up too soon - …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help with LayoutManager

    This was already covered in your previous thread. You use a Layout Manager. See http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html and http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Add objects to the neighbors list

    You should have created a "get" method in your machine class(es) to allow other classes to access the x,y coords. (If you have designed your classes to be immutable, then …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Setting position of JLabel

    You set a LayoutManager for each JFrame's content pane or JPanel, it then handles the exact positioning of its contents, based on your specifications. Please see the tutorial I linked …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Build a calculator-like layout

    Yes, and I would place the buttons as a GridLayout inside a JPanel, so the JFrame has a text field and a JPanel, one above the other. A loop to …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Code to make an Word-Frequency-Counter

    A bit of a digression, but I've been practicing with the new features in Java 8 (due March), and I have to share this with anyone who's interested... The following …

The End.