7,116 Posted Topics
Re: Hi AhmedGhazey. It's good that you are giving so much help in this forum, and your code sets a very good example for its structure and clarity. Just one thing to watch out for - we try to help people learn enough to solve their own problems, especially if it's … | |
Re: I think you will have to wrap the Vector (or extend the Vector class) in your own class that implements an addListener(...) method and overrides add() etc to broadcast the change event forwarding the change to the the Vector. This is basically what javax.swing.DefaultListModel does to support JList objects - … | |
Re: [QUOTE=AhmedGhazey;1575872]one important note this parameters mustn't accept any type of cast . i.e. if you have the following method definitions int x (int p); int x (double p); if you called x(5); which one will be called ?? you guess this will give you compilation error . [/QUOTE] [CODE]public class … | |
Re: Do you mean a-z, A-Z ? If so, just check char between 'a' and 'z' OR between 'A' and 'Z'. | |
Re: If you want to know whether it's button1, button2 etc, you can simply say if (e,getSource() == button1) ... | |
Re: [I]at olmosProyecto.GestionDeHorarios.cargarCurso(GestionDeHorarios.java:44)[/I] That line from the error message tells you which line of your source code (line 44 in GestionDeHorarios.java) threw the error, so you can see what token it was looking for on that line, which should help you identify the error. ps Not all lines in the data … | |
Re: [url]http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/[/url] | |
Re: Take a look at this: [url]http://download.oracle.com/javase/1,5.0/docs/guide/language/enums.html[/url] scroll down about half way and look at the Planet example - that shows how to use a constructor in an enum. | |
Re: I agree. More than once I've implemented a simple finite-state-style thing to pick a few relevant values from an XML file, rather than get into the complexity and overhead of SAX or DOM. This [url]http://www.javaworld.com/javaworld/javatips/jw-javatip128.html?page=1[/url] may be interesting to you (Just like buses. You wait an hour for one, the … | |
Re: Use a JTextPane instead of a JTextArea. Same functionality plus formatted text. API JavaDoc is in the usual places. | |
Re: Did you write this code? What do you understand to be the intention of line 155? | |
Re: [QUOTE=Armanious;1573675]Well, I solved it by using just System.arraycopy(), and I assume it's faster since it's performed by the VM (if not, please tell me so I can optimize it[/QUOTE] arrayCopy is a native method, so I think it's safe to assume its faster than anything anyone can do in Java … | |
Re: Does the Fruit class extend Food? | |
Re: @siviwe You do realise that this was marked as "solved" in 2008, don't you? It's 2011 in this part of the world... | |
Re: Without seeing your code how can we comment? | |
Re: Firstly, I agree with Jon (I think he's a bit too hard on field setters, but I support his reasoning behind that). Now think about maintenance/enhancement. Writing a program is easy. Updating someone else's program when requirements change is hard. Suppose you do your Vector2 class and develop loads of … | |
Re: I didn't study all the code, but I get a strong smell of a Swing EDT thread problem here - trying to execute user interactions while still inside a Swing event handler? Sorry, no time to go any further into this now, J | |
Re: if ("waveSlider1".equals(source)){ You are trying to compare a String object with a JSlider Object - always false. Assuming waveSlider1 is a variable containing the first JSlider you need to compare the variable, not a String containing the variable's name if (source == waveSlider1) { | |
Re: [CODE]public void graphicsComponent (Graphics g){[/CODE] looks odd to me, are you sure you don't mean [CODE]public void paintComponent (Graphics g){[/CODE] | |
Re: Indent your code properly, then look at when [I]System.out.println("Your total is:");[/I] will be executed. | |
Re: Briefly - make sure any non-standard dependencies (libraries) you may use have been placed somewhere (anywhere) in the classpath, then package the whole of your project's classes and resources into a jar (Eclipse: File -> Export -> Runnable jar file) which you can then run by [I]java -jar myJarFile.jar[/I], or … | |
Re: Stick it anywhere in the classpath for command-line use. In Eclipse go into Project -> Properties -> Java Build Path -> Libraries and add it there. | |
Re: Agree with Norm. Best practice is to write a small public method in the GUI class that just takes the String as parameter and does whatever it needs to display it. That way other classes can call the method without needing any knowledge of the internals of the GUI class. | |
Re: You can do this kind of thing using the indexOf and substring methods of the String class. So myUrlAsString.indexOf("secret_code=") gives the start point of that string, add 12 to get the index of the first char after it, which is where your target text is located. Use the same approach … | |
Re: AFAIK SIP is concerned with establishing and controlling a session, but not with the actual streams of voice and video that are sent in the session. That would normally be the responsibility of the Real-time Transport Protocol (RTP/RTCP). Maybe you are interested in researching innovative ways to achieve a breakthrough … | |
Re: Try printing the exception - it's message will help. ps: subSet gives a "live" view, not a copy | |
Re: null pointer exception means you have tried to use a variable that has not been initialised. Reading down the messages we see it happened in the add method for Container, and that was called from line 18 of jpad.java That line reads add(mainTextArea, BorderLayout.CENTER); and there's the problem. You have … | |
Re: Also If you take the time to read the API doc for JList you will find an explanation with examples of how to use a ListCellRenderer to format JList entries any way you want. | |
Re: What gets executed if hours worked are >0 but < 40? You keep nesting if within if within if until by the end (eg line 63) there's only a small chance of the code being executed. The presence of six consecutive } at the end, although perfectly legal, is also … | |
| |
Re: I'm not a Scanner expert, but I think... after you get the weight with a nextDouble() the following carriage-return is still there (it's not part of the double). Then you do a nextLine() which gives you all the chars up to the next CR - which is a zero-length String … | |
Re: You have a loop where you get each file name in turn, but you do nothing with them. You know how to append text to your result area, so... ps: When you post your code, post it properly indented in CODE tags. | |
Re: [QUOTE]You need external Api for this... [/QUOTE] No you don't. Its part of JDK 6. Here's a decent introduction from Oracle themselves: [url]http://download.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html[/url] A common approach is to make a MessageDigest of the password (eg using MD5) and store that in the database. When the user next enters his password … | |
Re: Reflection is useful when you have to make calls dynamically at runtime to classes/methods that are unavailable at compile time, and for implementing annotations etc, but they are not normally used for "ordinary" code. A major reason is that, unlike normal calls, they cannot be checked at compile time thus … | |
Re: 1. Exactly what is the real text of the error message, including line numbers? 2. Why do you have three JFrames (one created in main, one created in the constructor, and one instance of Absolute which is itself a JFrame)? | |
Re: This depends on what kind of fields your class has. Assuming they are just ordinary data types - ints, Strings etc - then you, it's not hard to have a method that concatenates all the values into a single String with easy field delimiters (eg tabs), and a corresponding constructor … | |
Re: That link tells you how to make a Window full-screen. If you know how to play a video in a Window then all you need to do is make the window full screen. | |
Re: This has been cross posted on at least 6 different sites, complete with the mis-spelling in the title. Nobody who codes [CODE]} catch(Exception ex) { }[/CODE] deserves an answer anyway. | |
Re: The Integers are different Objects, even if their values happen to be the same EXCEPT that Java pre-creates a single set of Integers for values -1287 to +127 (approx - or maybe its 0-255, but you get the idea) so Integers in this range will always be the same Object … | |
Re: Don't expect us to guess what error you have. Exactly what error are you unable to fix? Give full details. | |
Re: You can allow the user to type in an expression in JavaScript then use/call that as code dynamically at runtime using Java's recent support for scripting languages. | |
Re: It is very object oriented, but has some non-OO features for reasons of performance, notably the primitive data types (int, boolean, char, float etc) which are not Objects | |
Re: General strategy: Don't try to use paintComponent for viruses or ships, they do not extend anything with that method. Just have a public paintMe(Graphics g) method for each. Have the game panel with its overridden paintComponent method, and within that method call paintMe(g) for all the viruses and ships so … | |
Re: Actually there's quite a difference between [QUOTE]i want a free tool to draw structure chart [/QUOTE] and [QUOTE]i asked if any one know a good one suggest it thanks [/QUOTE] If you had tried the second version from the beginning you might have got a better response. | |
Re: The JavaDoc for NoSuchElementException is incredibly unhelpful [QUOTE]Thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration. [/QUOTE] Obviously wrong, since you have no enums. A look at the code for java.util.Scanner.throwFor tells us the real story: [CODE] // If we … | |
Re: Have a look at BitSet. It holds long strings of bits, fully packed at 64 bits per 8 bytes, and can be written/read to/from files as a single Object using Object input/output streams. | |
Re: th=spoofpkt/totalpkt; because th is an int, and assuming spoofpkt < totalpkt, th will always be zero (integer division is always rounded down to an integer value). You could make th a float to hold fractional values. | |
Re: 1. readObject can throw Exceptions (see the JavaDoc for details) so you have to use try/catch to handle them. 2. In Java 1.5 collections like Vector were enhanced to allow specification of what kind of Objects they contain (previously they just contained Objects, which had to be cast at runtime … | |
Re: Big Decimal still won't give an exact value for rational numbers such as 1/3, so your idea may still be useful if you store numbers as exact fractions. | |
Re: I'm pretty certain you have to read and re-write the data from the insertion point to EOF. How big is the file? There's no problem with (say) 100Mb reading the whole thing into memory, modfying it, the re-writing it. If your data is more structured than the example the there … |
The End.