7,116 Posted Topics
Re: There's nothing Windows-specific in there, so it should just compile and run under Linux as-is. Have you tried it? | |
Re: Don't know why that didn't work, but why not just use [icode]getSubimage(int x, int y, int w, int h)[/icode] to create your array of sub-images directly? | |
Re: [url]http://www.java-tips.org/java-se-tips/java.io/how-to-use-random-access-file.html[/url] | |
Re: Your Customer constructor requires a Name and an Address, but you have just provided the raw information (last ... zip). You have to create a Name and Address from the raw data and pass that to Customer [CODE=java]Name n = new Name(last, first); Address a = new Address(street, city, state, … | |
Re: ^ like Vernon says, or maybe you will see the title as a parameter to the frame's constructor. | |
Re: ArrayList, from the info you have given, is a very good choice. Wen you declare and create it, specify the type of object it's supposed to contain - this will allow the compiler to check your code better and will simplify subsequent processing of its contents. [icode]ArrayList<File> arrayList = new … | |
Re: Your TutorGroup class has a SortedMap that appears to contain student names as keys and Student objects as values. You can use this map to look up the Student object for any given name. The map is private, so you can't just access it from anywhere else (quite rightly!), so … | |
Re: If you use a port in the non-restricted range you would be unlucky to hit one that was in use. Maybe all you need to do if you [B]do [/B]get a BindException is to just try the next one (etc) until its OK. | |
Re: Since nobody else has the answer I had a quick Google, and found this: " How do I use JSAPI in an applet? It is possible to use JSAPI in an applet. In order to do this, users will need the Java Plug-in (see [url]http://java.sun.com/products/plugin)[/url]. The reason for this is … | |
Re: Are you certain that the Pic01.JPG file really is there, and its name is correctly capitalised? (just checking). May be worth just seeing if the new ImageIcon isn't null. | |
Re: The normal strategy for this is to add public methods to your Gui class that Gui2 can call to achieve whatever it is you want achieved. You may well already have a public constructor for Gui, so that may cover the "display" part. | |
| |
Re: You should probably be using a pair of wait/notify to signal between the two console outputs. That's a standard Java way to ensure that the two writes alternate properly. Here's a reasonable intro to the subject: [url]http://www.java-samples.com/showtutorial.php?tutorialid=306[/url] | |
Re: Two is not static, so it needs an instance of One to be created in. ie [icode]One.Two p=new One() . new Two();[/icode] Alternatively, declare Two as static | |
Re: A field may be an instance variable or a static variable. | |
Re: InputStream, as the Java API doc makes very clear, is an abstract class; it's definition is incomplete and you cannot instantiate it with new. It's purpose in life is to define a standard set of operations that any byte-oriented input stream should implement. As also explained in the API doc, … | |
Re: You don't seem to call setMonths() anywhere, so that's why it's not doing anything. Perhaps you should call it at the end of your constructor? I don't know the math for std dev, but your method: a) sets it to sqrt(n), when n=0. Seems pointless b) then sets n to … | |
Re: If your code is an ActionL:istener, you're probably listening for the wrong event to see if the selection has changed. You probably need an ItemListener. | |
Re: I don't understand the question... but is this what you were looking for? [code=java]for (int i = 0; i<var1; i++) { for (int j = 0; j<var1; j++) { System.out.print(var1); } System.out.print("\n"); }[/code] giving: 333 333 333 or, for var1 = 2, 22 22 | |
Re: If the list has already been created, all you need in the new method is [CODE]public List<Customer2> getCustomers() { return list; }[/CODE] and the easiest and safest way to loop thru a list is [CODE]for (Customer2 cust : getCustomers()) { System.out.prinltln(cust.getName()); // or whatever }[/CODE] | |
Re: Have you got an actionlistener added to the menus? | |
Re: If the last block you read is <1024 bytes, you still write 1024 bytes to the output stream. | |
Re: Doesn't readData have default (package) scope, and is therefore accessible from the main class? If it wasn't, you would get a compile error. Maybe the output file needs to be closed before the contents are read? | |
Re: THis capability was added to Java in the latest version (1.6, aka Java 6). [url]http://blogs.sun.com/CoreJavaTechTips/entry/getting_to_know_system_tray[/url] | |
Re: Normally you would have a separate thread waiting on a read from the input stream. When the server sends something, the read completes. The read is in a loop, so after receiving an object it just goes back to waiting for the next one. However, if you want to poll … | |
Re: Adobe have a free JavaBean to display pdf in a Swing app. See: [url]http://www.informit.com/guides/content.aspx?g=java&seqNum=377[/url] | |
Re: I think you will find this [B]very[/B] interesting [url]http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JEditorPane.html[/url] just scroll down to section 2. | |
Re: I'd go for a simple solution - create int variables in the Thread class to hold the number of threads currently using the track in each direction. Increment the appropriate variable in useTrack and decrement it in exitTrack. Now you have the info necessary to perform the tests specified in … | |
Re: Either way, you could (should?) make the storage mechanism "pluggable" by defining an abstract class that handles all the store/retrieve operations and then implement flat file and/or SQL versions as required. | |
Re: is this what you want to achieve? [CODE=java]String change1 = ""; while (!change1.equalsIgnoreCase("y") && !change1.equalsIgnoreCase("n") change1 = JOptionPane.showInputDialog("Change Silo 1 dimensions? (y/n)"); }[/CODE] | |
Re: The Java API reference for Graphics includes [icode]drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) [/icode] did you have a look at his? | |
Re: Maybe you have an out-of-date .class file for Temperature, or that file isn't in the classpath when you execute your other class? | |
Re: Start with something like: [CODE=java]public void actionPerformed (ActionEvent event){ int[] selectedRows= table.getSelectedRows() for (int i : selectedRows) System.out.println(i); }[/CODE] | |
Re: fSize isn't defined (as far as I can see). The problem's probably in the way the loops are constructed, but because you posted your code without [code=java] tags and proper indentation it's too hard to see. | |
Re: Java Threads are fundamental to the whole Java API. They really do work, properly. What's the problem with your code? You say "don't work properly" but that tells us nothing - what exactly your program do/not do that you didn't expect? | |
Re: Bean is short for JavaBean. The Wikipedia entry is a good place to start. Its a java class that conforms to some simple conventions (especially: uses standard get/set methods for its variables, and can be serialised) that enable it to be used in a plug-n-play kind of way to build … | |
Re: If you know how to get data from a client to a server and you also know how to get data from a server to an(other) client, then you already know how to send data from one client to another via a server! | |
Re: You split the line into the String array rowFields, but then you do nothing with it. Perhaps you should loop thru the members of that array printing them, or storing them somewhere. | |
Re: [icode]Student students[] = new Student[MAX];[/icode] in the constructor incorrectly declares a new array called students[] whose scope is limited to the constructor and which is garbage collected when the constructor exits. This does not do what you intended, which is to initialise the students[] array that you declared in the … | |
Re: getInput() returns an instance of the Wire class, so that cannot be directly compared to a boolean value. You probably want to use the boolean value that the isValue() method returns for that instance of Wire. ie getInput().getValue() (as previously explained by Vernon). You don't need to compare a boolean … | |
Re: 1. 22/7 is a calculation using 2 integers, so it's performed in int arithmetic, giving the int result 3, which is then assigned to the long variable. Just making one of the values a floating poit number will force the calc into floating point, eg 22.0/7 2. When you calc … | |
Re: A fewof quick comments: I wouldn't worry about creating a new thread for each click - what's the problem? You shouldn't need to run the text update on the EDT, setText is one of the very few swing methods that is thread safe. Rather than sleeping your thread, just call … | |
Re: Depending on the value of i_0_ it constructs an array of RSStrings (no definition provided) and passes it to one on a number of similarly-named methods (no code or definitions provided), and returns whatever value that that method returns. Also, at the beginning it updates a couple of couple of … | |
Re: where do you try to print ip etc. Is it inside the loop? | |
Re: ... and a few more examples: Open a window with a given title, text, and buttons. Open a TCP/IP server on a given port. Open a file, given the file name. Start a randon number generator with a given seed. ... in each case the things that are "given" are … | |
Re: The stop(); method for Thead is deprecated because it has problems. Here's what the API doc has to say: . This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath … | |
Re: winningNum is an array. You need to put the first number into winningNum[0], the next into winningNum[1], etc | |
Re: One class can only have one constructor with any given list of parameters (although it can have any number of constructors that take different parameters). So it makes no sense to copy a constructor in the same class. If you create a subclass, the superclasses' constructors are NOT inherited, so … | |
OK, I'm obviously going bonkers here, but has something happened to the java code tags? Why doesn't this work in preview mode? [CODE=java] i++; [/CODE] |
The End.