• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Null ip address and -1 for port on java udp socket

    The returned value is really a InetSocketAddress, so cast the returned value to that, then call its getPort() method
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Disable save button until something is changed in frame

    OK yes :)
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JAVA Illegal Start of Expression Error

    Hello MCGameSkillz 1. Do not hijack old threads to ask a new question - please start your own thread. 2. "It's something wrong with the ..." tells us nothing. If …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Disable save button until something is changed in frame

    Yes, I'm sure there are problems with sharing a listener when you want to do stuff like finding the text area or updating its state. What I am asking is: …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Disable save button until something is changed in frame

    mKorbel - do you have any links or refernces I can follow up re problems in sharing a DocumentListener? *For this specific case*, where the document is completely ignored in …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Merge Sort Applet

    I think you have confused us with people who will do your homeowrk for you for nothing? If you have *specific* questions or problems then post them here and someone …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Methods

    That's the "hello world" program that is the first program you learn in any language. There are many many suitable tutorials on the web.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Null ip address and -1 for port on java udp socket

    Try getRemoteSocketAddress() instead of getInetAddress()
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in eclipse

    That looks like a problem with your installed Java version vs the class files or jars you are using, not Eclipse. You could download the latest version of Java 7 …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Disable save button until something is changed in frame

    So I tried a small demo program. With a bit of tuning it looked like this: First the universal listener... class Saver implements DocumentListener, ActionListener { private int count = …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in eclipse

    Eclipse comes in many different (free) versions, supporting different subsets of usage. You need to download a version that suports as much as possible of your needs, then download the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in polynomials

    Do you mean that you want the user to be able to type in 2 polynomials that you can then multiply using your existing code?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Calculator HELP ME PLS :)

    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 Disable save button until something is changed in frame

    Sorry - my mistake, it should have been DocumentListener, not TextListener. (Old habits maybe?) Because the listener is just going to enable the save button, I can't see any reason …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in TSP: creating an initial population of tours

    Realistically, I doubt that anyone is going to spend any time trying to understand undocumented unindented code with meaningless variable names. Maybe you could make it a bit easier?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Disable save button until something is changed in frame

    You can add a TextListener to each text field (and ChangeListeners to radio buttons etc etc). You can use the same listener code for all of them - all it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how to find redundant rows in a matrix

    Create a Map with the row values as key and an Integer count as value. For each row, if that value is already in the map, increment its count. If …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Finding the Most Common Character in a String

    Hello DeepakNarang Here at DaniWeb we try to help people learn Java and develop their Java skills. We do NOT do people's homework for them. Your post explains and teaches …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in beginner code check

    When you print an object, the `print` or `println` method calls that object's `toString()` method to get a printable representation of that object. `toString()` is defined in the Object class, …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Trying to save to SQL database

    That Class.forName hasn't been needed since JDBC 4. From 4 onwards drivers have registered themselves in their jar file manifests. JDBC was released in 2007 with JRE/JDK 6 https://today.java.net/pub/a/today/2007/04/10/whats-new-in-jdbc-40.html
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how do I change the size of the button

    Using a null layout manager is a really bad idea unless you are coding for some very specific hardware configuration and the code will never run run on (eg) a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in save canvas to file

    Hi Lius. The purpose of your project is for you to learn and practice Java programming, not Googling. The only way to understand how to code this is to start …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in .net or java?

    C# and Java are almost identical languages - switching between them is easy. .net is comparable with the Java API in function and scope, but differs totally in the details. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help with Swing

    For simple images in Swing just read them into an ImageIcon and pass that to a JLabel. You now have a JLabel that's the same size as the image, containg …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in beginner code check

    Ideally you should enums for Suit and Rank - but maybe you have not covered enums yet in your course.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about Socket/ObjectOutputStream Error

    Those 4 bytes are the extra int -1. I think you need some way to limit yout read loop to just read the right number of bytes from the input …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in return string in int public function

    The "cleanest" way is to return -2 or -3 from checkGuess, then use a if test (or switch) to print the right message,eg guessResult = checkGuess(randomGuess); if (guessResult == -1) …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in return string in int public function

    What value should checkGuess return if the numbers are not equal? (Not -1, but what?). You left that bit out when posting the requirements. Anyway, in your code you create …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in problem

    There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about Socket/ObjectOutputStream Error

    OK, that makes sense. You're right. In that case... maybe some kind of buffer flushing issue? I see you flush() the stream, so it *should* be OK, but anyway... Just …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in beginning java - enum help

    How is the set method declared? should be something like void setTVMode(TvMode newMode) { mode = newMode; } ... in which case your `myTv.setTvMode(TvMode.HDMI);` should be OK If you still …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about Socket/ObjectOutputStream Error

    That's a bit confusing... The logic will be simpler and safer (and without repetitions) if you structure it as: count = is.read(... if count >= 0 bos.write(buffer, 0, count); else …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Logic behind read and write method in Inputstream and output stream

    `is.read(bytes)` reads some number of bytes into the array, then returns an int with the number of bytes actually read. That value is assigned to the variable `read`. Depending on …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in beginning java - enum help

    Line 11: You forgot to declare the type of the parameter. Line 13: That's not how to fix the <parameter with the same name as a variable> problem. Use `this` …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in eclipse taking too long to open

    Yes, looks like not enough memory. Try stopping and closing everything that's not essential for Eclipse and see if it's a bit faster. But really you need a bigger PC …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about Socket/ObjectOutputStream Error

    I just spotted this, maybe it's your bug? Line 24 - if sum == num your if test fails and you don't process the data - so that looks like …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how do I change the size of the button

    What size do you want it to be? Eg If you have multiple buttons do you want them all to be the same size? setPrefferedSize is a last resort really …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how do I change the position of a button

    ^ like he said. Post the code you use to create and set the initial position of the button, so someone can give you the appropriate answer.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about JTextarea/Sockets/Threads

    OK, so actually it's nothing to do with setText vs update, it's to do with moving the Swing calls into a different thread? Doing the text area update on the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about Socket/ObjectOutputStream Error

    write(int) is misleading - it takes an int but just writes the last 8 bits of that as a single byte. So your length gets truncated to 8 bits. Still …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to esmeraldaB in Stacks Beginner Program Output is strange

    Nice output. not bad for a bebinner to do.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Edited Stacks Beginner Program Output is strange

    Hello, I have to write a program which reads in a text file and sees the parsing symbols brackets, parentheses, and braces, and use stack implementation to have a balance …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Edited Stacks Beginner Program Output is strange

    Hello, I have to write a program which reads in a text file and sees the parsing symbols brackets, parentheses, and braces, and use stack implementation to have a balance …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to dlarytm in Can anyone provide me the code to find the majority color in an image

    search on google about histograms. it is not difficult to write code in java
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about JTextarea/Sockets/Threads

    Just to clarify what you said: if you `append` the text to the textarea it works ok, but change that one method to `setText` then it doesn't?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Question about Socket/ObjectOutputStream Error

    I'm very suspicious about mixing printwriter and direct calls on an OutputStream. Try getting rid of the printwriter stuff and simply `write` the int file length as an int.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Stacks Beginner Program Output is strange

    Line 67: Isn't this case where the brackets DO match? (wrong message text) Anyway, your bug is because the `else` on line 72 doesn't match the `if` you think it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Simple for loop question

    It's certainly legal Java to append strings like that, but horribly inefficient - every + or += creates a new String object. When you want to build up a String …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in multiplicate two polynomials

    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 …

The End.