7,116 Posted Topics
Re: First point: never say "gives me an exception". Alwyas say exactly what the exception is and which line its on. Second: on line 43 you check if ts is null, but that's too late. If it's null then you wil get a null pointer exception on line 40 | |
Re: I don't believe you can. You can only add Swing/AWT components to a JPanel. | |
Re: Did you try frame.getRootPane().setDefaultButton(goButton); ? | |
Re: Run what program? Where's your main method? To use those methods you need to call them and print the result, eg System.out.println(StringUtils.padRight("Hello", 12)); | |
Re: That's all wrong! `import` just affects the way that names are resolved at compile time. It has absolutely zero effect on what classes get jarred, or on the run time. importing everything is a lot easier than importing just the classes you need, especially if you are not using an … | |
Re: Doogledude has got it - ball A collides with ball B, and ball B colides with ball A. | |
Re: Literal \ characters in Java Strings need to be "escaped" - ie replaced with a double \ You did that in the findInLine, but not in your useDelimiter | |
Re: It's your put method. You check to see if that key is already there, and return true, but if it's not there you increment the size but you forgot to add the new key/value Pair to the map. | |
Re: It's pixels If you are using a layout manager like you should, then setSize is pretty much useless. With a null layout manager it sets the component size in pixels, and you look really silly when someone runs it on a retina display. | |
Re: Tables are split into two main parts - the visible GUI stuff, and the data for the table. This allows you to chose how to store the data any way you like, without affecting the way the GUI display works (and vice-versa). The part that holds the data is called … | |
Re: Your question is very vague and general - it sounds like you have missed some essential part of your course regarding GUI basics. There are many excellent Swing GUI tutorials on the web, just Google for them. Or start with this tutorial... http://docs.oracle.com/javase/tutorial/uiswing/components/table.html | |
Re: Start by loooking at which controls line up with which others - aligned controls are usually best on the same panel, unaligned ones may be easier in separate panels.Eg in the center there are CBs and JBs in a clear grid, but the "Print quality" line below doesn't line up … | |
Re: > For something as basic as this, where it will only be called once every run, you don't need to have methods for it. Only if it could be called multiple times. I disagree absolutely. Splitting long methods into sub-methods can be a massive boost to readability and clarity. By … | |
Re: If you are using Serialization (ie write/readObject) then bean standards are irrelevant, but you must declare every class involved as "implements Serializable" as a way of asserting that your classes don't contain anything the can't be serialized - eg references to live operating system handles. If you are using javabeans … | |
Re: You can do calculations when initialising variables, but only using values that are known at the time, eg int a = 3; int b = a+1; | |
Re: This is confusing. That code is perfectly valid Java; everything that needs to be declared is declared. Do you mean declaration like ricewtnd said, eg something like // I declare that this is all my own work and I didn't cheat... | |
Re: The package A has to be in a place that's in your classpath. If you have C:\Z\A\B\A\Print.class then A.Print is in C:\Z\A\B, so that's what has to be in the classpath. Ps: Having two directories called A, one inside the other is perfectly legal, but pretty much guaranteed to cause … | |
Re: When parsing the infix you can parse for parens, operators and numbers like you do now, but also parse for alphabetic tokens ie variable names (looks like you can assume single letter names?). Treat them just like numbers when converting to postfix. In the evaluator, when you get an variable … ![]() | |
Re: Why is there a colon in the middle of theclasspath - is that legal? | |
Re: vecA is a Vector of A objects, so there's no way it can contain a String. contains(...) just searches the Vector's elements for an equals() match, it does not search inside any "inner" Vectors that are in the "outer" Vector. For that you would need to do some kind of … | |
Re: This is just http://www.daniweb.com/software-development/java/threads/472200/java-retrieve-images again. I think we're wasting our time. | |
Re: The3 Java Language Spec documents all this stuff definitively. For throw it says > 14.18 The throw Statement > ... > A throw statement causes an exception (§11) to be thrown > ... > *ThrowStatement: throw Expression ;* > The Expression in a throw statement must denote either 1) a … | |
Re: No problem, they are initialised in both constructors. (edit) ... but anyway the language guarantees that instance variables are initialised (to 0, 0.0, false, or null as appropriate) anyway. See Java Language Spec: > 4.12.5 Initial Values of Variables > ... > • Each class variable, instance variable, or array … | |
Re: Try compiling using javac at the command prompt - that will give you proper error messages | |
Re: It's admirable that you have taken the time to create this tutorial to try to help others. But it's really not something I could recommend for a number of reasons... Most seriously, the method used is completely wrong for reading text files. Converting byte to int to char by casting … | |
Re: > But how does Java interpret the equation? Does it do proper BEDMAS Yes Java Language Spec: > 15.7.3 Evaluation Respects Parentheses and Precedence > The Java programming language respects the order of evaluation indicated > explicitly by parentheses and implicitly by operator precedence. | |
Re: The code that puts the image into a label (lines 20-24) can go inside the while loop so you create one label for each image in the result set. If you set a GridLayout layoput manager for your window then the labels that you add will be placed ina grid … | |
Re: > Each item needs to either be selectable, or non selectable That's the next thing in your requirements, so do that next. What kind of variable would you use for selectable / not selectable? How many of those do you need? What would be a good way to store them … | |
Re: On line 15 you test for a sign of "+" and if you find it, you add the next number using += on line 17. Testing for "-" and subtracting is exactly the same, except that it has "-" instead of "+" and -= instead of += | |
Re: > I research, learn, try, and ask for help. That's what helped me increase my ability to code in Java. Yes, absolutely right. But how does this fit with your posting a complete undocumented uncommented solution that the OP can just copy/paste without any understanding? I hope in your future … | |
Re: Chetan: Welcome to DaniWeb Our Site Rules (which you agreed to when you signed up) include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question | |
Re: (Ignore previous version of this post - it doesn't work) Sites may or may not respond to pings, so the only reliable way is to check a public service that definitely works. Eg try to make an connection to google.com on port 80 (google's search web site). eg InetAddress a … | |
Re: Is this sample code for our enlightenment, or is there a question you wanted to ask about it? | |
Re: That Student class is a very standard kind of code, you'll find millions like it in real life. Tools like NetBeans give you ways to write it faster, but the final code is the same. The only tiny question is whether you need all the set nethods - eg do … | |
Re: > The serializable class LogoPanel does not declare a static final serialVersionUID field of type long (etc) This is basically a stupid warning message that you can completely ignore. If it bothers you, just add this line inside each class it complains about: `static final long serialVersionUID =0;` > Cannot … | |
Re: The "How to use JTables" Oracle tutorial shows how yto set a different renderer for any cell of the table (briefly: subclass JTable and override public `getCellRenderer(int row, int column)`. http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#renderer Now each cell has its own renderer and each renderer can have its own underlying data. Updating the data … | |
Re: I don't know why this is in the Java section, but... TextPad 5 is commercial software so either: a) You have purchased a licence, in which case you should upgrade to the current version (7.1), then, if the problem is still there, get on to their tech support to fix … | |
Re: I'm no expert on this, but because nobody else seems to be around right now, I'll have a try... It coulld be that a) the 8 bit AL32UTF8 data isn't being converted to Unicode properly or b) the internal representation of the data is OK, but the character set you … | |
Re: You have a break; as the last statement in your loop, so it will always exit the loop at the end of its first pass. Maybe you intended that to be inside the else block? Also: the if test on line 28 is redundant. | |
Re: What do you mean by "compare"? Are you looking for duplicates, trying to sort the rows, or what? | |
Re: IMHO those GUI libraries are way too advanced for this requirement. There's nothing there that requires anything more that just an ordinary Swing GUI. The Oracle tutorials are unbeatable for accuracy, currency, and completness, but you may want to Google for some simpler tutorials if the Oracke ones are too … | |
Re: Use java.beans.XMLEncoder and pass it the ArrayList. It will encode the entire ArrayList and it's constituent classes and their ArrayLists of other classes and primitives all the way down. Your custom classes just need to comply with JavaBeans standards (get/set/add methods, a no-args constructor). It encodes to a Stream so … | |
Re: Could it be that the action command is "Save" (defaults to the same as the button text), but you are testing for equals("save") ? | |
Re: You're missing a set of brackets round the whole condiiton, but otherwize that's good. ps It's usually quicker to try something simple like that yourself than to wait for someone to reply to you. | |
Re: > There are 5040 combinations, and perhaps 20 words in the row of the dictionary. Should it really be takin 10 minutes? Or you think there is maybe another problem in the design/implementation? Running 5K iterations against 20 data items should so so fast you can't measure it. I have … ![]() | |
Re: Your analysis of the problem seems reasonable. Why not just check the selection in JList ListSelectionListener and ignore the event if the selection is null? | |
Re: TreeMaps are always sorted by their keys. subMap returns a view of a contiguous range of keys of the TreeMap, including only those keys within the specified range. Because it's a view, updates to it just update the origional (backing) TreeMap. Similarly updates to the origional TreeMap arre immediate visible … | |
Re: My extra-sensory-perception allows me to study your code, even if you haven't posted it, but unfortunately it doesn't work if there is an "a" in the month, so you're just going to have to post the relevant code in the old-fashioned way. :) | |
Re: toolkit.getImage does not throw any exception if it fails (other than for a security manager problem), so maybe the Image is not valid - createCustomCursor doc says : "If the image to display is invalid, the cursor will be hidden (made completely transparent)". This also doesn't throw an exception, and … | |
Re: ArrayList implements List, so every ArrayList is also a List. Can you post the exact syntax you used for the error version? |
The End.