7,116 Posted Topics
Re: 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 name you can search the name array, then use the index where you found it to get the lat and … | |
Re: 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 41. After creating the array you need to populate it by assigning new JPanels to each of its elements. | |
Re: Post the exact complet etext of your eror messages. Don't expect us to guess what they are. | |
Re: 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 things to an ordinary frame or panel and have any control over which gets painted on top of which. But … | |
Re: 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 go out of scope. For primitives that are declared as static members of a class, the lifetime is the same … | |
Re: 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 a constructor, not an ordinary method, taking another instance as its only parameter, and initialising its values from that other … | |
Re: 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 data with multiple occurences of complex data by mapping it into relational tables can be very complex and code intensive. … | |
Re: 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 classes into an executable with your classes. In general they don't work well, they prevent essential automatic security updates, and … | |
Re: 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 here. There are lots of people here who will freely give their time to help you become the best Java … | |
Re: 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 the IP address from JmDNS to access the machine itself. ps: DaniWeb Member Rules (which you agreed to when you … | |
Re: 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 | |
Re: If you want to analyze the first line after printing all the lines then you need to store that first line somewhere. In fact, why not store all the input? Use an array or ArrayList of Strings to store all the data as you read it in, so it will … | |
Re: You can read the image into an Image object, then use the PixelGrabber class to examine the individual pixels and get their colors, but after that it gets difficult - how exactly would you define "background color" and "foreground color" for some arbitrary image? | |
Re: 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. | |
![]() | Re: I guarantee that nobody human can possibly tell you what's wrong with your code if you don't show us that code! ![]() |
Re: You can append any String to a StringBuffer by using its append method, eg StringBuffer sb = new StringBuffer("pattern is "); String pattern = "/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/"; // will need to escape the \ chars as \\ sb.append(pattern); | |
![]() | Re: Where *exactly* did you see them? ![]() |
![]() | Re: If that solved yoyur question, please mark this "solved" for our knowledge base. Thanks |
Re: If that solved yoyur question, please mark this "solved" for our knowledge base. Thanks | |
Re: [QUOTE]- Add components to the ContentPane - not the root of JFrame[/QUOTE] Not sure if it was 1.5 or 1.6, but this annoyance has now been fixed and ... [QUOTE] As a conveniance add and its variants, remove and setLayout have been overridden to forward to the contentPane as necessary. … | |
Re: Did you try printing add5 and add6 to confirm that they contain the expected values? | |
Re: Hi dev90 Before you put too much effort into this thread, you should be aware that <M/> has double-posted, and there is already a pretty full discussion of exactly the same code here: http://www.daniweb.com/software-development/java/threads/469611/similar-error-as-before | |
Re: In Checkout you create a new Index then immediately get LCNum from it. At that point the user has had no chance to interact with that Index, so its value1 has never been set, so it's null, which is why you get that SQlerror (phew!). The fix for this lies … | |
Re: Sounds like you may have hard-coded a file or path in your app that isn't present/valid on the other machine? Or it may just be lunch4J mis-behaving. Do you really need to use it? Why not just distribute a jar? | |
Re: OK, so what's the question? Calculation of the minimum perhaps? [ICODE]if (min > grades[i])[/ICODE] how often is that true when min is 0? | |
Re: It seems dangerous to have both an action listener and a mouse listener for the same button(s). I don't think there is any guarantee about the order in which these two listeners will be called, especially if there's a lot going on. Maybe the bug is caused by the action … | |
Re: That's one way to do it. A more experienced programmer would probably separate the user interface from the calculation. The initialisations on line 7-9 are redundant because those values are never used. There's a much simpler formula for the area of a triangle defined by three Points a,b,c: 0.5*((a.x - … | |
Re: It seems that getLevel was not implemented in the early releases (just returns -1 error code) It was listed as a bug around version 1.4.1, but as far as I could see it was never fixed. Part of the justification is that they could not agree a definition of "level" … | |
Re: 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 Post what you have done so far and someone will help you from there. | |
Re: What did you try? All you have shown is `return 0;` You just need a loop that goes through the array checking each entry to see if it matches the patterns, and deleting it if it matches. You can't just "delete" an entry in an array like that - you … | |
Re: JLabels etc accept simple HTML code to control formatting, headings, font color etc, eg aLabel.setText("<HTML><H1> Hello</H1>" + "<FONT COLOR="RED"><CENTER>World" + "<FONT SIZE=-2 COLOR="GREEN"> and friends"); | |
Re: You also seem to be reversing the original number, whereas the "right" answer reverses the doubled value. | |
Re: The second code is valid only if its in a class that extends a swing component that accepts mouse listeners, eg `extends JPanel`. Because there is no explicit obect for the the call, it's the same as `this.addMouseListener` which is OK if `this` is an instance of a class that … | |
Re: Also note that Integer is a class, so you are creating 1000 new instances of that class. That's not the same as 1000 ints (primitives) that would be just 4 bytes each | |
Re: YOu didn't post the requirements, but this line: System.out.println("The number of integers is " + num); implies that num should be a count of how many integers were entered, but what you are printing is just the latest integer. You don't count them. | |
Re: Please explain what you are trying to do in more detail. | |
Re: That code (with a Scanner declaration for kbinput, aqnd placed inside a method) compiles without any errors or warning in NetBeans, and gives the right answers when executed. Maybe the problem is not in that code but caused by something in the rest of the class? | |
Re: Start by reading the tutorials: http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html | |
Re: To prompt the user and get input in a simple gui, use JOptionPane (Google it for details). Display stuff in your text area by calling its append(String str) method. But if you wanted to make your text area work just like the console window for input and output then (a) … | |
Re: albedini: please be polite. Old Apache is trying to help you. The very first sentence of his previous post explains why your print produces nothing with those call parameters. What is it about that explanation that you do not understand or think is irrelevant? | |
Re: I suppose you did remember to call setDefaultRenderer or setCellRenderer (for the relevant columns)? And did you setOpaque(true)? because the default renderer is a JLabel, which is opaque(false) by default, so it never shows its background colour. | |
Re: Initialise it to false, then set it to true in the code where you find or take an item? Or is the problem actaually more complicated than that? | |
Re: *A. Develop a working application that implements an interface.* So far you have no interface in your code. If only to meet the requirements of the exercise you could make Lootable an interface - it already sounds more like an interface (it's an adjective) not a class (its's not a … | |
Re: Your test data does not show you writing the ArrayList to the file. The exception is telling you that the data is the file looks like a single String. It may be a good idea to delete that file, and use your writeFile method to write an arraylist to tghe … | |
Re: Are you looking for a Java-specific solution or something more general, eg a regular expression. Are you just looking for the following rules: ( "0" OR "+33" OR "0033" ) followed by a non-zero digit, followed by exactly 8 digits, blanks to be ignored? ... if so it's the same … | |
Re: Here's the tutorial: https://netbeans.org/kb/articles/javase-deploy.html | |
Re: Well... First, you set newBoat to false on line 10 then try to see if it's false on line 11 - which ot always will be! Second, on line 11 you have coded an assignment rather than an equality operator | |
Re: stultuske: its totally obvious that this is a task that he has been set. Yes, it makes no real sense, but as a programming exercise he has no choice but to program it as specified. Necrozze: One way is to loop through the strings taking one character (ie digit) at … |
The End.