3,927 Posted Topics
Re: Your question is not clear on what you want to do with the extra text field, but you are already manipulating two fields just fine. Why can you not just add the third and do whatever you want with it? What is giving you difficulties? | |
Re: If you passed the animation reference to the Timer as a final reference (which would have been required for an anonymous inner class for the ActionListener), then you can't re-instantiate that reference and have it still work in the Timer. Have you tried recreating the Timer? | |
Re: [QUOTE=lasher511;584992]Problem resolved. It seems my supervisor thought it would be funny if he put a keylogger on my computer and kept giving the passwords to this kid so that it would confuse me.[/QUOTE] I would be looking to get a new job if my supervisor "thought it would be funny … | |
Re: You could use a while loop, but with arrays a standard for() loop or a foreach loop is usually preferred. A do while loop is seldom used to loop an array because a do while always executes at least once before the test and you would have to make sure … | |
Re: See the api for [URL="http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html"]DecimalFormat[/URL]. Also, after 50 posts, you should be familiar with [noparse][code] [/code][/noparse] tags - use them. | |
Re: All of this portion could go into a method called setupGame()[code=java] JPanel p1 = new JPanel(new GridLayout(3, 3)); int randomNumber = (int)(Math.random()*9)+1; if(randomNumber == 1){ p1.add(myButton1); p1.add(myButton2); p1.add(myButton3); p1.add(myButton4); p1.add(myButton5); p1.add(myButton6); p1.add(myButton7); p1.add(myButton8); p1.add(myButton9); } if(randomNumber == 2){ p1.add(myButton2); p1.add(myButton1); p1.add(myButton3); p1.add(myButton4); p1.add(myButton5); p1.add(myButton6); p1.add(myButton7); p1.add(myButton8); p1.add(myButton9); } add(p1, BorderLayout.CENTER); … | |
Re: That depends entirely on the constructors you have written for DisplayDie and DisplayPanel. | |
Re: Because you are calling nextLine() on the scanner and that method returns a String, not a char[code]char chars = scan.nextLine();[/code]Capture a String instead and use String.charAt(0) to get the first char.[code=java]String input = scan.nextLine(); char choice = input.charAt(0); switch (choice) { ...[/code] | |
Re: The code has numerous issues with empty blocks, misplaced semi-colons, missing braces, etc. | |
Re: First you'll want to get a BufferedImage object for the input image. Example code for this here: [url]http://exampledepot.com/egs/java.awt.image/Image2Buf.html?l=rel[/url] BufferedImage will allow you to access the grid of pixels ([url]http://exampledepot.com/egs/java.awt.image/ImagePixel.html?l=rel[/url]). You may be able to apply a thresholding function to the pixels to create an array map of the identified paths, … | |
Re: Having the sleep() in main() after you have called the mortArray() method will not cause your output to pause. The loop will continue to run until complete and then return to execute the rest of your code in main() - which is your pause code. You need to place the … | |
Re: It doesn't need to be reloaded - it just needs to be reset. How to do that depends upon how you have structured the code that initializes it. | |
Re: [QUOTE=bumsfeld;582615]Just waiting till Google comes out with their neat no nonsense (NNN) OS.[/QUOTE] Named HAL... | |
Re: [code]Dim i as integer i=10[/code] | |
Re: The demo class needs to create "Ages" objects and use the methods you have defined. As written your demo just defines some variables and prints the "avgAge" - which is still 0 because you haven't done anything with it. | |
Re: This is your third thread on the [U]exact[/U] same issue and this has been answered in the other two already. | |
Re: Another loop inside that one on [code]while( tokens.hasMoreTokens() )[/code] is all you need. | |
![]() | Re: The error message should also include the name of the class that is not found. Check that method for classes you may have missed on the class path and if it is a third-party library check that those runtime dependencies are also in your classpath. ![]() |
Re: The stack trace clearly indicates that in your actionPerformed method on line 99 that you are attempting to call a method on an object that is null. Examine the call that is being made on line 99 and examine why it might be null. | |
Re: Your question is too vague. By "upload" do you mean with a JSP page or from a desktop Java application? (This is the Java forum by the way. There is a separate JSP forum here:[url]http://www.daniweb.com/forums/forum24.html[/url]) Without more information no one can really help you. | |
Re: [QUOTE=denniskhor;580808]wat is import?? how?? i jz beginner in java...[/QUOTE] Then obviously you didn't copy [U]all[/U] of the appropriate code from wherever you copied this routine. You need to specify "import <package>.<class>;" for each of those classes that you are using. Honestly, if you don't know what an import is then … | |
Re: You haven't ended the main() method block. Until you do that you can't start a new method. | |
Re: That line is actually the entirety of this statement[code]b[index[j]][k] = b[index[j]][k].subtract( a[index[j]][i].multiply (b[index[i]][k]));[/code] You are performing an operation on a value in b[][], but you haven't initialized all of the elements in b[][]. You have only initialized the diagonal of that matrix here[code]for (int i=0; i<n; ++i) b[i][i] = new … | |
Re: Use this constructor for your FileWriter to append to the file instead of overwriting it: [URL="http://java.sun.com/javase/6/docs/api/java/io/FileWriter.html#FileWriter(java.lang.String,%20boolean)"]FileWriter.FileWriter(java.lang.String,boolean)[/URL] You will also need to change [icode]\\ file to output or save to[/icode] to [icode]// file to output or save to[/icode] if you want that to compile - wrong slashes for an inline comment. | |
| |
Re: Which method are you wanting to pass an object to? "idMethod" is getting a no-arg method and "getMethod" is getting this method [icode]getInstance(String)[/icode] with this line [code]Method getMethod = Class.forName(ClassName).getMethod("getInstance", new Class[]{Class.forName("java.lang.String")});[/code]. If you need [icode]getInstance(Object)[/icode] the you need to use [code]Method getMethod = Class.forName(ClassName).getMethod("getInstance", new Class[]{java.lang.Object.class});[/code] Your question is … | |
Re: The row must be added to the TableModel, not the JTable as you are attempting. In particular, that method is provided by DefaultTableModel and is not in the general TableModel interface, so you will either need to keep a reference to the DefaultTableModel that you are creating[code=java]DefaultTableModel tableModel = new … | |
Re: There is no guaranteed return path because your return is within a conditional statement. This means that when your if() test is false the function has no return value - and the compiler won't allow that. You need a return outside of the if statement as well. | |
Re: [icode]DecimalFormat("#.##")[/icode] will show up to 2 decimal places if applicable. If you want to always show 2 digits after the decimal use [icode]DecimalFormat("#.00")[/icode] Edit: Just noticed, but you are not even using the DecimalFormat you created. You need to use that instance to format your numbers like so[code=java]System.out.println("The maxiumum score … | |
Re: A search across this site (that little box in the upper right corner) on "final year topic" yields 50 pages of results. That should get you started I would think. | |
Re: I doubt you want to disable the cells but rather make them uneditable. Example here: [url]http://exampledepot.com/egs/javax.swing.table/NoEdit.html[/url] For the row selection, see these: [url]http://exampledepot.com/egs/javax.swing.table/GetSel.html[/url] [url]http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#selection[/url] | |
Re: It would help a lot if you either used [noparse][code=java][/noparse], which would place line numbers in the listing or highlighted the line number in your code, since most can't just quickly pick out line 174. Here is that code with line numbers: [QUOTE=Dio1080;580346]I can't figure out why it is saying … | |
Re: Then you need to make sure that the BufferedWriter is being created correctly and the "myList" has been initialized by the point you are calling that loop. | |
Re: Because your toString() method is not returning a string, it's just printing stuff out to the console. It needs to build a string and return it. Also, after 18 posts, you should learn to use [noparse][code] [/code][/noparse] tags around code that you post. | |
Re: Take a look at this example on disallowing edits: [url]http://exampledepot.com/egs/javax.swing.table/NoEdit.html[/url] The signature of the method that they are overriding should give you a pretty good idea on how to disallow editing on any particular row or column. | |
Re: The stack trace is showing the error occurring in sigmoidActivationFunction [code]at newtonsMethod1.sigmoidActivationFunction(newtonsMethod1.java:118)[/code] and if you look at the constructor you are using for BigDecimal there the error should be pretty clear. I doubt what you wrote there can be formatted as a number. | |
Re: See the resources outlined in the [URL="http://www.daniweb.com/forums/thread99132.html"]Read Me post[/URL] at the top of this forum. There is a lot of info there to get you started. | |
Re: Of course, this is exactly what a Dialog is for... | |
Re: It's the same principle as with an array but you update the list pointers instead of shifting the array elements. If you need more specific answers, you need to ask more specific questions. No one here is going to write the sort for your homework assignment, so post the code … | |
Re: You need to have the read in a loop like so [code]while ((line = reader.readLine()) != null){ StringTokenizer tokenizer = new StringTokenizer(line," "); // do stuff }[/code]I have no idea where the "BbmReader" class comes from, so I can't speak to any specifics on that, but the general loop should … | |
Re: This tutorial has examples of working with the available layout managers: [url]http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html[/url] | |
Re: You actually need to add the data to the TableModel. You can either implement the TabelModel yourself against your existing data (whether that is in an array, list, or whatever) or create an instance of DefaultTableModel with your data. Read through these for more info and examples: [url]http://www2.sys-con.com/ITSG/VirtualCD_Spring05/Java/archives/0405/hatmaker/index.html[/url] [url]http://java.sun.com/docs/books/tutorial/uiswing/components/table.html[/url] | |
Re: [URL="http://java.sun.com/javase/6/docs/api/java/lang/String.html#substring(int,int)"]String.substring(int,%20int)[/URL] | |
Re: You can do it with a custom cell renderer like so:[code=java]class CustomIconRenderer extends DefaultTreeCellRenderer { ImageIcon defaultIcon; ImageIcon specialIcon; public CustomIconRenderer() { defaultIcon = new ImageIcon(CustomIconRenderer.class.getResource("/images/defaultIcon.gif")); specialIcon = new ImageIcon(CustomIconRenderer.class.getResource("/images/specialIcon.gif")); } public Component getTreeCellRendererComponent(JTree tree, Object value,boolean sel,boolean expanded,boolean leaf, int row,boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, … | |
Re: Each container can only have one layout manager, however you can easily create any layout you wish by nesting containers with the layout that you want for each one. This could include using a few JPanels inside a JFrame with each JPanel containing a few components. Breaking up the layout … | |
Re: Well, a couple of things. This query makes little sense [code]executeQuery("select * from result where result='"+ b1 + "'");[/code] The field name in the where clause is the same as the table name. Second, after you run the query and call .next(), you need to retrieve the field value like … | |
Re: And how do you figure it's a silly answer? You don't say what about the code you do not understand. Is he supposed to just know that you understand pointers? Do you? Do you expect someone to just explain every portion of "that top template part" to you in excruciating … | |
Re: Multiplying at those magnitudes are putting you beyond the precision of double. Use [URL="http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html"]BigDecimal [/URL] instead. [code=java]double a = 1.190597027811988E-273; double b = -2.513498651481222E-273; System.out.println("double: "+(a*b)); // double: -0.0 BigDecimal c = new BigDecimal(a); BigDecimal d = new BigDecimal(b); System.out.println("BigDecimal: "+new DecimalFormat("0.#######E0").format(c.multiply(d))); // BigDecimal: -2.992564E-546[/code] | |
Re: Just use a BufferedReader for the read. Example here: [url]http://www.exampledepot.com/egs/java.io/ReadLinesFromFile.html[/url] | |
Re: Why does MVDList extend Queue but work with an internal Queue reference "aQueue"? |
The End.