202 Posted Topics
Re: You could use a [URL="http://docs.oracle.com/javase/1.4.2/docs/api/java/text/DecimalFormat.html"]DecimalFormat[/URL]. You'll want something like: [CODE] DecimalFormat df = new DecimalFormat("#.##"); double test = 242.23232; System.out.println(df.format(test));[/CODE] | |
Re: As long as the domain is relevant this sounds alright. The most important point is to ensure your domains won't confuse customers ("Why are exampleproduct.com and myproductexample the same???"). Search engines attempt to demote sites that are purely designed to funnel traffic to a page as spammers try to use … | |
Re: Although I'm not familiar with this library, but a quick Google search came up with this guide [URL="http://rxtx.qbang.org/wiki/index.php/Deploying_JAVA_with_RXTX"]here[/URL]. | |
Re: Classes are a way of representing objects in a program. The real world is made up of numerous things like tables, chairs, and couches. These objects have properties like height, width, and color. Classes allow you represent these objects by grouping variables together and developing methods to manipulate them in … | |
Re: You should start by checking if they have some sort of API. If so, what you're trying to do shouldn't be too hard. | |
Re: First: having your users input the server's IP address is probably the most proper way to do what you'd like. If you try to simply crawl a network for a server you may run into problems. You need to know your network's structure to determine whether or not this approach … | |
Re: LIFO is short for [B]l[/B]ast [B]i[/B]n, [B]f[/B]irst [B]o[/B]ut. That should help get you started. | |
Re: There is no platform independent way to do this. You could use [URL="http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html"]Runtime[/URL] to run an OS specific utility to gather this information. Getting OS information is very easy. I would suggest checking the different [URL="http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html"]system properties[/URL] you can access. | |
Re: Real numbers don't have to be integers. 1.232 and 4/3 are both potential real numbers, but you're storing integers. Otherwise this looks correct to me. | |
Re: Since you're using a string I would recommend consulting [URL="http://www.cplusplus.com/reference/string/string/"]this reference[/URL] to see the different methods available for working with it. You can access the first character in the string like you could an array. In your case this would be something like: [CODE]if(line[0] == 'A') { // Place the … | |
Re: You could create a station class that stored the line (or lines) which it services. Depending on how your lines are managed you could either store its name in a string or a reference to the appropriate line class instance. Your calculation function could then determine which station is closest … | |
Re: I would recommend checking out [URL="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Random.html#nextInt%28int%29"]this[/URL] method. | |
Re: You'll need the JDK which you can get from the [URL="http://www.java.com/en/"]official site[/URL]. Once you have that, installing Eclipse should be as easy as downloading the ZIP. If I remember correctly you can get it without an installer so it simply needs extracted and then you can run it. | |
Re: Perhaps you could copy the value you're going to move, then move the items that will be behind it over one index, then write the value back into the array? ![]() | |
Re: Does the write to the file succeed before you call the delete()? Perhaps the PrintWriter is still attached to inFile even after the close call? | |
Re: [URL="http://java.sun.com/j2ee/tutorial/1_3-fcs/index.html"]This[/URL] is a good place to familiarize yourself with J2EE. If you have time to work through the tutorial, I'd recommend it. How long do you have? | |
Re: You must first identify what functionality of the class you are trying to test. What you write depends on how you want to test the class. I'm not an expert on JUnit testing, but [URL="http://www.vogella.de/articles/JUnit/article.html"]this[/URL] article might help a lot. | |
Re: Perhaps the [CODE]label = SetImage("C:\\Users\\Documents"); App\\ImagesDoc_001.jpg");[/CODE] is causing problems for you? I would bet you probably want [CODE] label = SetImage("C:\\Users\\Documents\\App\\ImagesDoc_001.jpg");[/CODE] | |
![]() | Re: You simply need to check if the length of the string is greater than 0. The error you're getting is resulting from the charAt(0) call on a string that has no first element (probably the user simply pressed 'enter' without typing anything). Try adding this check: [CODE]public void screenRunner(){ boolean … ![]() |
Re: The [URL="http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JWindow.html"]JWindow[/URL] class creates a window with no title bar or the associated buttons. A [URL="http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html"]JFrame[/URL] looks more or less like a normal window that you would expect to see in any application. I personally like JFrames more. | |
Re: What part is giving you trouble? What does your factory do so far? | |
Re: One approach would be creating a class to handle networking and simply sharing that object between all your classes. That class would manage the sending and receiving of the messages. You would probably need to create a way for each object to ask the class if messages had arrived for … | |
Re: Where is the buttons array defined? You might make a getter method to access it from outside the class (as the references it stores should still be valid). | |
Re: One surefire (although drastic) solution is a wipe and reload of the operating system. If you've had significant problems with viruses/malware in the past or have installed and uninstalled large amounts of software this could help. Another approach would be [URL="http://kb.wisc.edu/page.php?id=1688"]disabling unnecessary programs[/URL] from your startup sequence. WARNING: only disable … | |
Re: Reading the file with a Scanner is a good start. Now consider the format of you data: you have character strings separated by spaces. This means you could use the .split() method on spaces (" ") to break up your unknown number of scores into a String[]. Remember that the … | |
Re: If you want to pass information from within the JSON object, you need to parse it out. A quick Google search returned two, but I've never used them and give no warranty that they're correct. They're [URL="http://json.org/java/"]here[/URL] and [URL="http://jackson.codehaus.org/"]here[/URL]. You might be able to store the whole object in the … | |
Re: Look into [URL="http://docs.oracle.com/javase/tutorial/networking/index.html"]Java Networking[/URL]. You most likely want to have a PHP script running on a server that reads from some source for current currency prices. This script would run when your application accesses it. The script could aggregate your data and send it back to the client. You then … ![]() | |
Re: One method would be to set up unique URLs and track which users register through that page. Then you would simply use basic tracking techniques to review how often they return to your site or if they convert to premium customers (depending on your model). You could also run giveaway … | |
Re: Why not lay out 9 buttons in a 3x3 grid? If you wanted to make it 3D (similar to a Rubik's cube), then you could lay out a number of these grids beside each other to represent the numerous sides. | |
Re: Remember that you can pass multiple files to javac to compile. Instead of doing them separately, try javacing them at the same time. | |
Re: I believe what you want to do is iterate through the 2D array with a pair of nested for loops. You could either generate the number as you traverse the array. I'm not sure what your array description (the {1,1,2,2,3,3,...}) means though. | |
Re: You probably want to look into [URL="http://en.wikipedia.org/wiki/Machine_learning"]machine learning[/URL]. What you want to do isn't easy without a strong background in statistics, so I would also recommend looking into that. Basically one way this algorithm could work is through building a complex Bayesian network that links changes in color and relation … | |
Re: The Java random number generator, like in all other languages, actually generates pseudorandom numbers. This means the numbers are not truly random, but appear to be so (and for a game are more than sufficiently random). The numbers are not truly random due to the nature of computers: they do … | |
Re: I believe the problem lies in the fact that you create a new instance of the Games class, but you never actually call .start() on it. It appears all the constructor does is set the visibility and size. You need to call .start() on the Games object you create (perhaps … | |
Re: Java frames have a [URL="http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Frame.html#isResizable%28%29"]isResizable()[/URL] method that allows you to disable the user's ability to resize the window. | |
Re: If you don't want to modify the original array, why not just copy that array into the result array for the function and perform the sort on it? If you're returning a different array, there's no reason not to simply use it for the computation. Also you may be interested … | |
| |
Re: I'm assuming you're doing this to learn Java, so this should get you started: [CODE]int counter = 0; // Declare your variables int value = 1; int max = 10; // You can define ("hard code") this, or read it in while(counter < max) { System.out.println(value + " "); // … | |
Re: How is your data stored in the text file? You most likely would need to read in a string and parse out an integer, double, etc. If you're storing more than one character per entry you'll need to do something similar. Also, how are you separating each item in the … | |
Re: You might try limiting the number of refreshes you do by using a timer. It won't make it look great, but it should eliminate the worst flickering. Perhaps 2 refreshes a second? | |
Re: Threads can be written in a number of ways, but if they complete their run() method, they will terminate (die). You can easily get around this by putting the code to execute in a while loop that simply executes a [CODE]break;[/CODE] if you want it to exit. What it sounds … | |
Re: Drawing text straight to the screen (without displaying any application) requires some knowledge of the OS you're using. Most will still require some form of window to be open for the application. You might consider looking into writing a widget? | |
Re: This sounds like something you could easily solve by putting a short password on your user account and locking the computer (by using the Start menu or Windows Key + L) when you're not around. | |
Re: You can easily add a check to your method for user-defined public holidays, but you must define the holidays yourself. I would suggest adding a simple definition file that is loaded into memory when your program starts in case this method is called often. | |
Re: Arrays are fixed size structures that are useful for quickly accessing data. You can think of them as a partitioned box where each partition is an index in the array; that is, each index can store one element of the type you declared the array for. An example would be: … | |
Re: Perhaps specifying a size for the GridBagLayout would help. Also, calling the pack() method before the setVisible(true) might also be useful? Its been awhile since I worked with Swing and I don't have the JRE set up right now on this computer to test, but I believe this is where … | |
Re: If the error message is from the operating system or the JRE, it is likely that the file itself has been corrupted somehow. If the message is coming from a program-generated window, then it is possible that the application itself either has corrupt files or has been programmed to fail … | |
Re: Every program is, by default, a thread. This thread can spawn other threads (such as classes that extend Thread or implement Runnable in Java). From what you said it sounds like you technically have two threads in your model already. The main program (or whatever produced the button) is a … | |
Re: Using the Scanner class would be the best. You can read each section of the file with it and specify the delimiter to use. Something like this: [CODE]Scanner fileReader = new Scanner("FILENAME.txt"); while(fileReader.hasNext()) { String item = fileReader.next(" "); // Print or store the string, read in the next line … | |
Re: I believe what you're looking for would be the [URL="http://www.asciitable.com/"]ASCII character codes[/URL]. |
The End.