• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Socket Programming

    It looks like `AirplaneDetails` is an inner class of `airtrafficcontrol` (?), so you will need the whole `airtrafficcontrol` class on both machines.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thoughts on MIGLayout

    Never used it myself. GridBagLayout does everything I need, and I have a strong dislike of using third-party anythings unless I have to.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Histogram help.

    FYI: That little pattern on lines13-17 is so common that Java 8 Map has a new `getOrDefault` method to make it simpler. values.put(i, values.getOrDefault(i, 0) +1);
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to invisal in Recursive binary?

    (I was meant to post this as comment, but because it is too long so I will make a reply) To be precise, tail recursion optimization is the process of …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Recursive binary?

    > the recursive one run in O(log(n)) and use O(log(n)) memory because you keep push high and low into the stack. Not necessarily. This is a case of *tail recursion*, …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Recursive binary?

    A binary search partitions top/bottom halfs, then does the same for the appropriate half and continues until it's found the result. That is a recursive algorithm. It would be natural …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Socket Programming

    You need that class (exactly the same version) on both machines.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Socket Programming

    Seems like the server is running on a machine that does not have that class in its classpath
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Finding the product without the (*) multiplication sign

    Yeah, well done invisal. I carefully gave the OP just enough hint so he could benfit from working it out himself, then you went ahead and posted the whole thing, …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Finding the product without the (*) multiplication sign

    2 times 3 is 2+2+2 5 times 4 is 5+5+5+5 see a pattern? see how that can be implemented with a loop?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in array is not a function

    Line 9 ( ) is not the same as [ ]
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Reflection API

    Oracle's tutorial covers this exactly. https://docs.oracle.com/javase/tutorial/reflect/member/methodInvocation.html
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Reflection API

    Now you have the Method object you can call it by using Method's `invoke`
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in plugin for web development

    Have you bothered to Google, or did you think it was OK to just come here and demand that someone does it for you?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Tree of File Directory

    It's a standard feature of the Java API, See https://docs.oracle.com/javase/tutorial/essential/io/walk.html
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in explain this random number for me

    Copuld be a while or a do/while. Sometimes that's just a question of preference. Try coding both and see which gives the simplest code in your specific application.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Printing out objects

    Yup That toString() is in the Client class, but its an instance of one of the other classes that's being printed. You need an appropriate toString() method in each and …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Printing out objects

    That method lookd good Where did you put it? Where is the code that tries to print and gives the wrong output?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Printing out objects

    It will work if you override toString correctly. Check that tyour method signature is correct, ie @Override public String toString() { return <some String expression>; }
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Value from getter returns null

    `RegistrationDetails registrationDetails = new RegistrationDetails();` that version is almost certainly a mistake. The name is presumably mandatory. What use is a registration without a name? So in your Client class …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Value from getter returns null

    ` RegistrationDetails registrationDetails = new RegistrationDetails(name);` creates a new instance, and initialises the `name` field, but ` RegistrationDetails registrationDetails = new RegistrationDetails();` creates a new instance and leaves the name …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in upload .java files to posts

    I don't know. PM Dani, she wrote it.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in upload .java files to posts

    You can just paste the code in Code tags as part of your post. Experience shows that most people won't bother/dare to open a file attachment anyway.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Pig Game: Dice Rolld

    Have a look at Java's `exclusive OR `operator - it's just what you need.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    Insets work well, but the whole set minimum/maximum/preferred size, along with setSize itself is a nightmare. Different layout managers respect or ignore any or all of those depending on the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in pls i need help in creating a traffic control system

    OK Get a grip. Ask one sensible question, and show some effort if you want help.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    Key released - the value in your theChar is useless if you get a sequence like the one in my last post. The code at the end of your post …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    That code won't handle modifier keys (shift etc) correctly, and there's no quick fix for that. The only sensible way to get the correct character displayed is to use the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    I think you mean `setFocusable`, not `isFocusable` Your proposed solution is almost OK except you missed the whole point about key pressed vs key typed for the char that you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Coding HELP. Object-Oriented

    OK Bobby. You posted an entire project requirement doc (I hope you own the copyright to that!). Why? What response do you expect?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    I think I may have said right a the beginning - Swing keyboard handing is surprisingly hard, mostly because you need to know where the keyboard focus will be, (because …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java: Basics

    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 Keyboard GUI

    The pressed and released events give you a VK wich is a reference to a physical key on the keyboard. You can use those (via getKeyCode, not extended key code) …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Adding Multiple BufferedImages to one BufferedImage (Optimization)

    IF you really do have a lot of drawing that is repeated without being changed and if that is consuming a significant amout of resources, then yes, there MAY be …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in assign method to variable

    First, some notes on your question: You can't assign a method to an ordinary variable; you assign the result of calling that ethod. You can't call variables, just methods. The …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    pack() before making visible to avoid a flickery repaint. You are confusing parent and child layouts. Every container has a layout that controls how its contents are layed out, but …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    Your keys panel has a border layout, so you are adding all the rows in the same place, but you want the rows inside it stacked vertically. I can't see …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in random question

    Line 77 you generate one random number "number" Then you ask the user about two completely different numbers "num1" and "num2" that you have not generated.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in random question

    You would be very disappointed :)
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in random question

    So all you need is to generate random ints in the range 2-12? Create a Random and call its nextInt method as often as needed. nextInt(n) generates a number between …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in switch case

    He's right. Think about it. What is the result of` 5/100 `in integer arithmetic?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Suggestion in Multi Line Text Box

    Which language?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in random question

    Not crazy, but I have no idea what you are talking about
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in need help with java program for a course

    If you tage your topic "Java" then it will be seen by many more Java experts who can help you.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in random question

    ?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    No need to search the map - that's what maps do - lookup values by their keys. You can just get the button directly from the map given the key …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    You can't use the VK constants from another class without either fully qualifying them: `java.awt.event.KeyEvent.VK_1` or (better) by importing all the static public names from that class `import static java.awt.event.KeyEvent.*;` …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to attach output from the jbutton to jtext field?

    Depends on what you drag and where you drop it! While you are learning I strongly advise you NOT to use D&D to create your programs. You will never learn …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Keyboard GUI

    Yes, the VK_ constants are the ones that refer to buttons on a keyboard. They're the ones you need. `mp.put(new Integer(xxx), row1.add(new JButton("~")));` You don't need the `new Integer` because …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Places to learn gui java

    Books are out of date by the time they are printed. You should be learning with current Java ie Java 8, not some old version. The best source of tutorial …

The End.