3,927 Posted Topics
Re: [quote=iCez;449055]Here it goes, we were told to make a Multiplication thingy that the user can [B]Input[/B] something like [I]5x5[/I] and then the [B]output[/B] will be the [I]answer[/I]. We were not taught on how to do it yet so I don't have any idea. I'm just hoping that someone can teach … | |
Re: If you are running in Windows, try prefacing the command with "cmd /c start "; | |
Re: You just need to use the mod operator on your percentComplete calculation.[code] int chaptersRead = 1500; int chaptersInBook = 1189; System.out.println("total percent read = "+(chaptersRead/(float)chaptersInBook*100f)); // with mod operation to reduce to percent complete for the current reading float percentOfBook = (chaptersRead/(float)chaptersInBook*100f) % 100f; System.out.println("percentOfBook = "+percentOfBook); // or a … | |
Re: There is no need for a mthod to retain it's own state separate from it's instance context. If you need to maintain state in an object, make it a class level variable. If you really feel that the method MUST retain it's own separate state then you probably have a … | |
Re: The incrementing methods don't necessarily need a return value. Just call the increment method and then show the new time toString(). Your set method may also need to throw an IllegalArgumentException when an our of bounds parameter is passed, like 61 minutes. Also, 60 minutes is actually 0 minutes and … | |
Re: Search what? Your file system? The internet? Your closet? Your question is too vague. | |
Re: [quote=kedarkhedkar;448463]I also have a query about ISBN. Some books have one ISBN, SOME have two. Is it appropriate to use ISBN AS a primary key for a book table ( as I have seen it in one book). What is ISBN. What can be the appropriate primary key for book … | |
Re: Perhaps it may be too late into your assignment to consider this, but do you really need to keep two separate lists that only vary by sort order. As you are finding with your current task, having multiple copies of the data means that all operations on that data must … | |
| |
Re: Try this instead[code=java] import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.lang.reflect.InvocationTargetException; import javax.swing.*; import java.util.*; public class Game extends Applet implements ActionListener{ String textB="textB",output="",input="type here"; JTextField inputBox; JTextArea mainBox; public void actionPerformed(ActionEvent e) { if (textB.equals(e.getActionCommand())) { Typewriter type = new Typewriter(inputBox.getText()); type.start(); inputBox.setText(null); } } class Typewriter extends Thread{ … | |
Re: You are correct that "this" refers to the current object instance. YWhen you add a listener the parameter is typed to an interface. You can supply an object which implements that interface. The interface merely guarantees that certain methods are available on that object. Here your gui class implements the … | |
Re: [quote=The Dude;446995]Why is everyone making a joke about this?? Sometimes using NATURAL ELEMENTS produces MUCH BETTER RESULTS than anything man made!![/quote] Hrmm, perhaps because the poster is a fruitcake? All three posts by this individual seem to indicated that perhaps he has soaked his own head in salt water for … | |
Re: What errors are you getting and what is your question? Please be specific and use code tags around code you post. | |
Re: No, operator overloading is not possible in Java. The only thing you can do is add methods for the operations you need. | |
Re: Well, if you have jdk 1.5_04 installed in that path, it should work just fine. I assume you have verified that location? | |
Re: [quote=tony07;446884]if any one on here has a job on rune scape i'll do it i'm all ways need to make money and if you want to right click on a mac right bloody click the itas he same as the windows soft waer i have had ma mini mac for … | |
Re: [quote=volscolts16;446888]In this experiment, people take turns playing and you can delete or add players, Seem to have a couple of issues left, not sure how to work out. One of the problems is the display, the other is a class interface. Need any help or suggestions I can get. Thank … | |
Re: [quote=restrooms;447300]Pls Help Me On Doing My Project. A Simple Game Using Java And I Need The Program. As Soon As Possible Thanks A Lot For Who Can Help Me.[/quote] Giving you the code for your project is not helping you at all. You won't learn a thing by turning in … | |
Re: You actually define the buttons twice, once in the initCD() method and then again in showGUI(), but you do not add any ActionListeners (or Actions, both are valid) to be executed when the buttons are pressed. [url=http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html]How To Use Actions[/url] | |
Re: Well, it's quite easy if you put those entries into a collection of objects as you mentioned in your last thread. You just scan the collection for the ones that fall between the upper bound and the lower bound. Did you have a more specific question? | |
Re: When a client connects, just add the client output stream to a collection (ArrayList should be just fine) which you can then loop through to broadcast the message along to all clients. | |
Re: If even one method is declared as abstract then the class must be abstract and cannot be directly instantiated. There may be a lot of other functionality in the class, but declaring a method abstract means "this behavior must be specified by a subclass". To instantiate, you must at the … | |
Re: Well, according to this [URL]http://hudzilla.org/phpwiki/index.php?title=Avoid_overusing_function_calls[/URL] it is, and zend.com has the following to say on it[quote]Function calls carry a high overhead. You can get a bump in performance if you eliminate a function. Compiled languages, such as C and Java, have the luxury of replacing function calls with inline code. … | |
Re: [quote=KimJack;445801]Hi All, I am trying to parse an xml file. Not using any of the regex or parsers, simply using only java code. Any suggestions? Thanks[/quote] Ok, so you won't use an XML parser for some reason that you won't explain. Your last post asked how to do it with … ![]() | |
Re: If you are comfortable with Java, PHP is really pretty easy to learn. You'll still have to get used to things like state management and passing variables through GET, POST, and SESSION, but you face those in JSP as well as PHP. Both are just fine for what you want, … | |
Re: You need to set up a Swing [URL="http://java.sun.com/javase/6/docs/api/javax/swing/Timer.html"]Timer[/URL] to handle the countdown on the button. See the following on timers:[URL="http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html"]How to Use Timers[/URL]. The behavior you are getting right now is because you are sleeping in the thread that is creating the UI. Create the UI first and after it … | |
Re: Just read the API for [URL="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html"]ArrayList[/URL]. The methods are quite clear. If you don't understand Collections at all, there is a lot of info here: [URL="http://java.sun.com/javase/6/docs/technotes/guides/collections/index.html"] Java Collections Framework[/URL] | |
Re: It really depends on how that piece of info relates to Customer. Is it specific to each customer and applicable to all customers? Then add it. Is it only applicable to a certain kind of customer and has no meaning in the context of most customers? Then extend Customer. Is … | |
Re: This is the Java programming language forum - there is a separate forum for Javascript and you would probably get quicker help over there. | |
Re: No, read the announcement at the top of the forum - [URL="http://www.daniweb.com/forums/announcement9-2.html"][U]we do not do homework for you.[/U][/URL] Post code that you are having difficulty with and specific questions about it. The forum is to help those who are making an honest attempt at solving their issue. It's not for … | |
Re: You could use regex to extract all of those things, but really an XML parser would be a lot easier and more appropriate to the task. An XML DOM parser is what I would recommend you use. See the XML tutorial here:[URL]http://java.sun.com/xml/tutorial_intro.html[/URL] and specifically this section [URL="http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/dom/index.html"][B]XML and the Document … | |
Re: Try IzPack, it's a free Java installer that will let you create distributions like that. [url]http://izpack.org/[/url] | |
Re: This method actually won't compile either [code] public static int i(int i) { if (i == 0) { return i; } }[/code]because there is no guaranteed return. If the i==0 check is false, there is no return. You need to return something if your check fails[code] public static int i(int … | |
Re: [quote=shank;444934]Friend.... according to me .NET is 80 per cent and SAP 20 per cent... If want... consider my opinion[/quote] And do you actually have any basis for that outside your imagination? | |
Re: Yes, the draw() method encapsulates [U]how[/U] to draw the chart and the Graphics2D parameter is [U]what[/U] to draw the chart on. In that way, your method can draw onto anything that can supply a graphics context to it and is not limited to a graphics context from one particular source. | |
Re: Also, when looping a collection for deletion it's easier to loop from end to beginning, i.e. from size()-1 to 0. Element shifts from deletion won't affect your indexing if you do that. | |
Re: Your displayComputerInfo() method is calling methods on Computer as if they are static, because you typed Computer instead of computer - different case. Gotta watch case-sensitivty in Java :) | |
Re: [quote=hbk619;444419]I like pty's idea, over the summer I thought I'd look into java/c++ so I DL some ebooks on Java. Problem is can't really concentrate on a computer screen, and reading stuff like that from a book is hella confusing (me audio/visual learner it would seem).[/quote] Honestly, if that is … | |
Re: Well, your explanation is a little difficult to follow, but it sounds like int division by 1189 is all you are needing[code] // assuming that show is an int or long b = show/1189; [/code]Does that yield the result you are trying to achieve? | |
Re: You just need to save the class in a file called PayrollApp.java. It works just fine. I'm assuming your file name does not match the class name. | |
Re: [quote=jwenting;442438]I've not yet heard any reason why "java is different" from anything else, or why that would matter. Hardly surprising, as most arguments come from people who have no clue yet have strong opinions based on personal preference or irrate hatred of Microsoft (caused in itself by jealousy above all … | |
Re: Well, is the "other classname" an interface? The declaration expects you to have an interface name there, which your class implements. When you say "call " an external class, what exactly are you trying to do? | |
Re: [quote=ceyesuma;442261]Does anyone have time to look over a 3 class program? I get a NULL POINTER ERROR. What is the best way to debug a variable that produces this error? Thanks[/quote] Yes, as mentioned, the stack trace should tell you which method the error occurred in and the line number. … | |
Re: Post the errors that you are receiving and what problem you are having with it. You can't expect others to read the entire code line by line and debug it for you. | |
Re: Well, you don't define a class at all - just a main() method. Methods can't exist on their own, they must be in a class. You also don't define the readInterger (sic, misspelled Integer) method either, so you can't call it until you define it. | |
Re: You have no guaranteed return statement in doMath(). If op falls through all of the cases in your switch, the method would not return a value. Add a default return value after the switch and it will be fine[code] static int doMath(char op,int numa, int numb){ switch (op) { case … | |
Re: You really don't need to cancel execution of the method, just don't perform any other actions after the display of the message. It looks like your current method will do that just fine as it is. Just remove the System.exit() call. | |
Re: And because that is how they designed the language specification. "Why" doesn't really matter at this point does it? | |
Re: [INLINECODE]show = String.valueOf(calc);[/INLINECODE] | |
Re: Declare the scanner at the class level and do not re-open it in the listener. Let it use the one you have already opened. |
The End.