• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Monopoly

    You have created Die as an inner class, but there's no reason to do that. I would move the declaration of Die to outside the JavaMonopoly class.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Setting position of JLabel

    You *can* set the layout manager for the container to `null`, then use `setBounds` to set the size and position of your label in pixels. However, if you do it's …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in layout manager, which one?

    Happy new year to you and yours as well. My own experience has been that setting preferred size seems to be ignored most of the time, but setting minimum sizes …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in layout manager, which one?

    I totally agree with everything you said in your last paragraph. `setSize` is call for when you're not using a layout manager. By default, most layout managers will make your …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in java Product trial Licensing

    One way is for the app to link to a server that you control somewhere to check the trial licence period.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in layout manager, which one?

    pack() fits everything together according to the layout manager(s) and any other constrains you have specified. Until you call it your laying out isn't finished. In particular the setSize for …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Display blob from database to jlable

    Did you get a solution to inputting from the blob? If so, how did that work? (ps It would be polite to let us know if you found a solution …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in layout manager, which one?

    You still need to specify appropriate layout managers for the JPanel and its child JPanels. For th JFrame a flow layout is OK - it will place the panels left …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in layout manager, which one?

    The simplest way is to use multiple JPanels to organise the groups of controls. eg Place 3 JPanels in your JFrame, flowing left to right. In the first one add …
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    You'll have to look at the source files to see how/why you are parsing that blank space - your split method parameter should deal with it automatically. > how can …
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    > But i am not sure what this {=1 why its getting printed Looks like your splitting may be returning exactly one empty string, ie "" (or maybe an unprintable …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in learn

    I will second that concern about using material based on Java 1.6 or earlier. Oracle officially stopped posting updates to 1.6 last year (see http://www.oracle.com/technetwork/java/eol-135779.html ), and 1.8 is due …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with CardLayout - getting nullpointerexception

    It's a classic double-declaration problem. YOu have created two different "contentPane" variables. 13 protected JPanel contentPane; this is the contentPane variable that you use in the actionPeformed and which is …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Mileage and Cost of Fuel

    There are lots of ways... One way is to create 3 arrays for name, lat and long, and populate them with the location data. Then when the user enters a …
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    Lines 38-42 increment the counts for an array of words, so if you execute that code inside the loop, after creating each words array (line 25), that should be OK. …
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    Your first loop (17 - 37) processes many files, but stores its results in a "words" array that gets replaced on each pass of the loop. SO after the loop …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NullPointerException

    The very first row of that array contains 23 elements, so with k going up to 40 that will give an index out of bounds exception. Remember that it's not …
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    "words" must still be null - look at the earlier code to see how - use print statements to see exactly what's happening. ps - I'm going out now, maybe …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NullPointerException

    After creating the array you need to populate it by assigning new JPanels to each of its elements. eg for (int 1 = 0; i<12; i++) jp[i] = new JPanel();
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Want to learn Java

    Hi Vicky, welcome to DaniWeb. Start here: http://www.daniweb.com/software-development/java/threads/99132/starting-java-java-tutorials-resources-faq
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    In your catch block execute an `e.printStackTrace();` That will tell you the exact line where the NPE happened, from which it's usually easy to see exactly what went wrong. Anyway... …
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    OK, so start with number 2 "Read a list of words from a file". You already have written code to read and store all the words from all the text …
  • Member Avatar for JamesCherrill
    JamesCherrill

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

    Did you really write that code? It displays a wide knowledge of Java syntax, including some of the latest language enhancements. Someone with that kind of programming skill would surely …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Adding menu to a window

    Post the exact complet etext of your eror messages. Don't expect us to guess what they are.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in learn

    http://www.daniweb.com/software-development/java/threads/99132/starting-java-java-tutorials-resources-faq
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Write my program for me

    DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NullPointerException

    Glad to help. Please mark this "solved" for our database - you can always start another thread if you have new question.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NullPointerException

    jp=new JPanel[12]; creates an array of 12 references to JPanels, but it doesn't create any JPanels, all the references are null, which is why you get the NPE on line …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help with rectangle

    I don't have time now to study your code - I gave up when I saw you trying to add things to a JLabel! But you can't just add overlapping …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Display blob from database to jlable

    ByteStreams looks like a Google Java class. I haven't tried this, but maybe you could try `ImageIO.read(blob2.getBinaryStream())` to get the image then pass that to an ImageIcon constructor.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in lifetime of primitives..??

    It depends... For primitives that are local variables declared inside methods or other blocks, and for method parameters, they are allocated on the stack and released as soon as they …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Object cloning without clone() method

    > Even with p1.equals(p2) false > may p2 be considered to be p1 clone ? The API for for Object::clone() gives some relevant info on this: Creates and returns a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Object cloning without clone() method

    That's true, but don't forget that this exercise has a requirements satetment that includes > PointOneClone method takes an argument of PointOne type > and copy every value from his …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Object cloning without clone() method

    Your PointOneClone(PointOne point) method seems weird - you pass it a parameter but you never use that parameter in the method. The usual convention for a "copy constructor" would be …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    Only in that it "just works" regardless of platform. Why re-invent the wheel?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in coupeling: passing on objects or arguments?

    Where you create them and where you store them are two different things. It may be best for the Game class to have responsibility for creating everything, including Items, but …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    That's the object-oriented way of thinking! Sudents study Subjects, not "subject names". Suppose you want to know how many credits a Student can earm from his current set of Subjects …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Run java file without JVM

    Short answer: there are some hacks out there that try to avoid you needing a JVM - usually by packaging a version of a JVM and all the Java API …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Write a general purpose currency convertor program

    You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    In that case I would ensure that Student and Subjst follow the rules for JavaBeans, and use XMLEncoder to write the ArrayLists of Students and Subjects to a file in …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in problems with jar file while creating a jar file in eclipse

    The system classpath variables contains a list of places where Java will look to find classes. The jar should be in a folder referred to in the classpath so Java …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    "What sort of info" was a summary of your question, followed immediatly by an attempt at an answer (classes & methods etc) - I wasn't re-asking it back to you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in problems with jar file while creating a jar file in eclipse

    To use that jar from an ordinary Java application (ie not in Eclipse) you should place a copy of it somewhere in the system classpath
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    What sort of info? I woul;d start by trying to name all the main classes that will represent the data and all the things you want to do with it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Remote Desktop Accessing

    How can you possibly access a remote machine without using its IP address? YOu could use something like JmDNS to locate the remote machine, but you still have to use …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    > it is processed to create data that does not belong in the database. So I have to save that data locally, In that case I'd go back to just …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    There is a problem that, from tine to time, Oracle change the serialisation format for one or more classes - in the Image case I mentioned before it was to …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    Serialization allowes you to write/read arbitrary objects to a binary file, in a Java-specific binary format that may be subject to change (not just an empty threat - I had …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Saving Program Data

    In defence of cool_zephy's suggestion... Storing a Serializable object - no matter how complex its internal structure and content - is a single call to writeObject. Restoring it ditto. Storing/restoring …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Swing Tree Model to display multiple nodes

    You can call JTree's expandPath(TreePath path) or `expandRow(int row)` or the corresponding `collapse` methods to control which nodes will have their child nodes diplayed.

The End.