7,116 Posted Topics
Re: [QUOTE=Choucas35;1588213]Same problem that ? the closed thread : [B]Java 6 update 26 - incompatible![/B][/QUOTE] That post was about serialised ImageIcons. So if your file contains a serialised ImageIcon it's the same problem, if not it's a new one. J | |
Re: Class methods cannot be overridden in Java. Calls to class methods are resolved using the declared type of the variable (not the actual type of the Object it refers to) - Foo in this case. Instance methods are overridable and are resolved using the actual Object. [url]http://stackoverflow.com/questions/5059051/java-calling-a-super-method-from-a-static-method[/url] PS - if … | |
Re: I can't see the problem after a quick look. Put lots of print statements into your code so you can see the exact sequence of execution and variable updates that lead to the problem. | |
Just a heads-up guys. I had JRE update 26 pushed onto client machines yesterday and it broke an important client-server app. This point release changes the serialVersionUID for ImageIcon. The app in question sends images from the server to the cients via a simple writeObject/readObject, which fails at the client … | |
Re: Is the correct answer 142917828921? If so, you may want to compare this with the largest value an int (eg [I]int Total=0[/I]; ) can hold... | |
![]() | Re: You may still be creating problems by trying to read binary data as if it is character. That will read 1 byte per character from the input stream, but convert to Unicode 2-byte chars to store in a char array, with results that may be unexpected for random binary input. … ![]() |
Re: Like it says at the top of the main page..., [QUOTE]to keep DaniWeb a student-friendly place to learn, 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] And posting … | |
Re: That kinda works, text is a bit untidy, but that's all. What EXACTLY is the problem you are trying to fix? | |
Re: It works for me too, but if your classmate (ps that's the correct English spelling) who gave it to you also wrote it then (s)he can explain it. If not then here's a good opportunity for you to hone your Java/NetBeans skills. Use the NetBeans debugger to trace the logic … | |
Re: Your copy method looks OK to me too (ie should work). But note the following does not do what you seem to think it does: [QUOTE]If I just copy the entire array it works fine: [CODE] copyOfOriginal = original; return copyOfOriginal;[/CODE][/QUOTE] Array variables (original, copyOfOriginal) do not contain arrays, they … | |
Re: It's exactly what the message says. An inner class cannot use the variables declared in the enclosing method unless they are declared final. If you don't need to change the value of jt just add the "final" keyword to its declaration. (It's because variables declared in the method go out … | |
Re: Have you a method that creates/makes visible the Other window? If not, create one. Then call it from the ActionPerformed of the menu item. | |
Re: Post your own answers and somebody may help you with the ones you get wrong. | |
Re: Read the whole message. It will tell you where the problem is. | |
Re: Alternatively... create an array of 26 ints and use it to count the number of 'A', 'B' ... 'Z' directly. No need to sort then. | |
Re: [QUOTE]It gave an error called cannot convert void type into string.[/QUOTE] Have a closer look at that error message - it should give you the exact line number where it happens. Then look at that line and find out which variable is null. | |
Re: Line 36 i<length, not i<=length Arrays are zero based, so the last element is index (length-1) | |
Re: I think your solution works because getCodeBase returns the URL the applet was loaded from (ie the server), so your getImage downloads the image file from that location, thus not needing local file access or any special permissions. I believe this is the "correct" way to do it anyway, rather … | |
Re: It looks like you are updating the previous image by writing blank rectangles in various places, so you really don't want to call super.paintComponent (and absolutely not super.paintComponents) if you expect images to persist from one call to the next. | |
Re: To ask the user a question and wait for the answer you would not normally use a JFrame, the class JOptionPane is the normal way to do GUI dialog boxes to ask questions. Details are in the API doc in the usual places. You will find instructions for using JTable … | |
Re: Maybe something like... [CODE]SocketAddress addr = new InetSocketAddress("192.168.0.23", 10123); ... Socket socket10123 = new Socket(addr); ... public boolean ConnectToServer() { try { if (!Globals.socket10123.isConnected()) { Globals.socket10123.connect (addr); } return Globals.socket10123.isConnected(); } catch(Exception e) { e.printStackTrace(); return false; } }[/CODE] ... but you will still have to deal with the input/output … | |
Re: it draw one sphere but when i enter 2nd.. it gives me error It would help if you told usexactly what the error was. | |
![]() | Re: Have you seen these? [url]http://download.oracle.com/javase/tutorial/deployment/applet/security.html[/url] [url]http://download.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html[/url] JNLP lets you get around many of the unsigned jar problems by automatically seeking permission from the user ![]() |
Re: The code+messages you posted earlier point definitively to multiple versions of your files, regardless of what you may believe. Java requires that public classes are defined in a .java file with the same name as the class, but there is no such requirement for non-public classes as in your code. … | |
Re: if(s!="no") You can't compare the contents of two Strings with == or != That tests for them being exactly the same Object. To test for two Strings having the same sequence of characters in them use s.equals("no") or s.equalsIgnoreCase("no").. which may be better for testing user-typed input. | |
![]() | Re: ready() [QUOTE]Returns: True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block. [/QUOTE] As far as I can see that means that it will return false when you have read zero or more … ![]() |
Re: Stultuske has explained this to you twice. I'll give it one more try. line 7 A b=[B]new A()[/B]; // creates a new instance of A line 2 [B]A a=[/B]new A(); // instance variable a is initialised as part of creating the new instance line 2 A a=[B]new A()[/B]; // new … | |
Re: [QUOTE=asterix15;1579698]If i can use public and design a program carefully(although a bit inconvenient) then can i completely avoid using private?[/QUOTE] Apart from all the good reasons stultuske gave, you should also consider that no (real-life) program is ever finished. Requirements change, increase, evolve, operating environments change. Its no enough to … | |
Re: Do you really [I]have [/I]to do this? Pattern/shape recognition is possibly the hardest thing ever to program. If you must then you have a choice of three main strategies - look for lines/edges, count sides & corners etc OR take the shape as a solid "block", rotate/resize it to some … | |
Re: How many sets of coordinates? 1, 2, or 3 points there is always a circle that passes thru all of them (except limiting case of 3 points in a line where the "circle" is infinite radius). | |
Re: break inside a switch breaks out of the switch - ie stops any later cases being executed. So in this case is does NOT break out of the loop, just the switch. | |
Re: We don't actually do people's homework for them here. Have a try, make a start, when you get stuck come back with a specific question and someone will help. ![]() | |
Re: Absolutely do NOT start with any code that has [CODE]catch (IOException IOE) { }[/CODE] If it doesn't work because of an Exception you'll never be able to debug it. At the very least replace all those with [CODE]catch (IOException e) { e.printStackTrace(); }[/CODE] ![]() | |
Re: A class with exactly one instance is called a "singleton" class. It is a common pattern in Java applications. Here's a typical implementation: [url]http://www.javabeginner.com/learn-java/java-singleton-design-pattern[/url] I don't understand what you mean by "user stops the function of this package and when he starts it again then the initialization of A,B and … | |
Re: Here's a minimal block of code that shows different arraylists added to a master arraylist [CODE] ArrayList<ArrayList<String>> masterList = new ArrayList<ArrayList<String>>(); ArrayList<String> temp = new ArrayList<String>(); temp.add("A"); temp.add("B"); masterList.add(temp); temp = new ArrayList<String>(); temp.add("C"); temp.add("D"); masterList.add(temp); System.out.println(masterList); String s = masterList.get(0).get(0); s += " etc"; masterList.get(0).set(0, s); System.out.println(masterList);[/CODE] Now how … | |
Re: [url]http://www.coderanch.com/t/411356/Java-General-beginner/java/Public-IP-Address-time-limit[/url] | |
Re: [QUOTE=johnbucayan;1578183]you can use this code to make it more simple...[/QUOTE] ... unless You want Java code You want the brackets to match You expect to use a loop variable somewhere within its loop You want the test for "equal" Strings to work You know that Strings and arrays are different … | |
Re: Eclipse has its own environment, and you can't get at the ordinary console. You can get the same capabilities using a BufferedReader with System.in [CODE] import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; ... try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Type name: "); String name = reader.readLine(); System.out.println("Hello " + … | |
Re: Standard approach (very short version): Ball class implements a single Ball, including its position, velocity etc, and has a public method to draw the ball on a Graphics that is passed as a parameter. Main class has a window where things are displayed. Creates new Balls on request, and adds … | |
Re: It allows you to extend some other class, if that's important to you | |
Re: [QUOTE=jwenting;1576499] method local variables do go out of scope unless they're declared final, in which case they're preserved between method calls.[/QUOTE] Sorry, I don't think that's quite right. final variables do go out of scope, and a new final variable is definitely assigned for each invocation of the method. The … | |
Re: A.method() is a static reference - A is a class not an instance. method() is an instance method - hence the error. Contrast that with the following valid code [CODE]class B{ void myMethod(){ A a = new A(); a.method(); } }[/CODE] | |
Re: A class variable has one value which is associated with the class itself. An instance variable has zero or more values, one for each instance of the class that has been created. You can only use it by specifying which instance's value you are referring to, as in hello.call() or, … | |
![]() | Re: getLocalAddress "Gets the local address to which the socket is bound" (API doc). This is address of the machine where the server is running, so of course its always the same, regardless of where the client is. getRemoteSocketAddress() will give you the address where the client is, if that's what … ![]() |
Re: [QUOTE=amalwit;1576072]I think this is the answer[/QUOTE] Answer to what? Did you actually test whether this meets the requirement in the original post? Do you think this is clear and well-written code (and look at AhmedGhazey's solution before you answer that)? Do you think you are helping the OP by giving … | |
Re: All swing activity (including action listeners and screen updates) is queued in a single thread called the Event Dispatch Thread. Your action listener is executed on the EDT, and everything else is held up until your method returns. Your first statement IS executed, but the screen won't be repainted until … | |
Re: Yes there is. javax.swing.JToolTip [url]http://download.oracle.com/javase/tutorial/uiswing/components/tooltip.html[/url] | |
Re: (A guess) this may be a thread problem - text area not being updated until the loop is exited. Does you code above run as part of a GUI - eg in response to a button press or somesuch? | |
Re: Why not keep the port and its in/out streams open? Sounds like you are trying to re-open something, which may not be necessary? | |
Re: In English: if x is less than zero go right one step if x is greater than 500 go left one step [I]therefore[/I] if x is between 0 and 500 [B]do nothing[/B] ... but it should continue to move in whatever its current direction is. Think about keeping track of … |
The End.