7,116 Posted Topics
Re: Do you have any choice about doing this? Conmparing different images is horribly difficult (and slow) in any language. Is there any other project you can do? | |
Re: Have a look at your jar using a standard zip file utility (whichever you prefer) and check the exact path and file names for the files you need. If you're using Windows, watch out for upper/lower case in the names - the Windows file system is not case sensitive, but … | |
Re: Re all thise String arrays: Apart from the load method, they are used as temporary variables, so scope is OK. BUT they all seem to be redundant, eg String [] selection = interestRates; annualInterest = selection[1].getDouble(); why not just annualInterest = interestRates[1].getDouble(); | |
![]() | Re: If you look back through this board you will find quite a number of people have been building Java apps to send receive and broadcast instant messages across TCP/IP or UDP sockets. (It looks like this must be a standard project on some programming courses.) Their posts contain lots of … ![]() |
Re: Apart from violating the "we don't do people's homework for them" rule, the above code does not work as required, so it's doubly unhelpful. Remember: char is a numeric type. | |
Re: You can display a graphic in a JLabel using the setImageIcon method - v easy and works v well. Research layout managers to see how they allow you to lay out the labels in a window. a grid layout may be good for you. | |
Re: You have a class called DVDCollection but each instance actually represents a single DVD. This sounds a suble difference but it's very inportant. When you say new DVDCollection =(...) you are NOT creating a new collection of DVDs, you are creating a single DVD. That's the right thing to do, … | |
Re: A class without a suitable public main(...) method can only be called from another class. If you want to run a class from the java or javaw command it must have the method. | |
Re: Looks like you create the window, increment the bar as fast as the CPU can go, then exit the app. You're lucky to see even a flash! And "there are errors" isn't enough info. Exactly what error message on exactly what line? | |
Re: Check the API for the JTextArea append method. It takes exactly one parameter, a String. You are calling it with multiple arguments, just like the errors say. If you want to append some complex formatted text you must build this up in a String first, then append that String. (ps … | |
Re: Previous answer is 90% right, but, as defined in the Java language definition, the JVM has no problem deciding which variable to use. Declaring x as a parameter "masks" or "hides" the declaration of the instance variable x, so an unqualified use of x in that method is a use … | |
Re: The JVM has nothing to do with compiling a Java class. The compiler takes your source code (xxx.java) and converts it into a coded form (xxx.class) that contains a detailed low-level step-by-step set of instructions corresponding to your program. The JVM then takes that .class file and executes the instructions … | |
Re: [url]http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/combobox.html#listeners[/url] | |
Re: Anything the user types is a String You can then try to convert the String to integer (etc) by using API methods such as public Integer(String s) throws NumberFormatException which will give the the Integer if possible, and throw a NumberFormatException if it cannot be parsed as an Integer. | |
Re: ... or simply use an array double[] car = new double[3] car[0] = ... car[1] = ... etc | |
Re: Have a look at the contains(...) method in the String class (ps: in case you are worried, CharSequence is just an Interface implemented by all Strings) | |
Re: When you extend a class or interface, any members that you re-define in the subclass/interface override the definition in the superclass/interface. So there is no ambiguity. If you have an instance of B then the definition in B applies (if it is not defined in B, then it inherits the … | |
Re: If I understand the question, then the answer is "yes", but why do you ask, and what do you want to infer from the answer? | |
Re: I seee nothing wrong in a static method provided that it gets all its data from the parameters (or embedded constants). There are many examples of this in the Java API - which I would use as the definitive guide to "normal" practice. Re line 76: use the printf method … | |
Re: Yes, its called Random. You will find it in the API JavaDoc | |
Re: Methods, both static and instance, are loaded into the VM when the class is loaded. Only one copy of each method is loaded and held in memory. | |
Re: for i = 0 to (length of string+!)/2 print string with first and last i characters replaced with blanks. repeat loop with starting and ending values of i swapped. | |
Re: ob is a reference to an object of class A. It can also hold a reference to an object of any sub-class of A, because any such object is, by definition, a kind of A. new X() creates an object of class X and returns a reference to that object. … | |
Re: How much spare time do you think we have? Make the effort to read some of the stuff that's already available to you on the web, then come back here if you have specific problems. | |
Re: You may find that this is a problem with keyboard focus - are you sure the focus is on your JLabel? Try clicking it once then pressing a key. | |
Re: Divide by zero means exactly what it says. You have c/d and also %f so it seems that either d or f must be zero. Print out all the variables immediately before the line where the problem occurs and see which one(s) are zero. When you know which is zero, … | |
Re: I would use a common method rather than duplicate 3/4 lines of code (assuming they are non-trivial). Main reason? Maintenance. What happens when you discover that that piece of code needs to be improved or fixed in some way? Now multiply this across a full-sized commercial project. | |
Re: It would be informative to do a quick scan of programming vacancies in the area that interests you and see what skills they are asking for. | |
Re: Do you mean that it should not have any visible windows? In that case, just don't create any. Any Java app will run in Windows and in Linux unless you go outside strict Java and access an OS-dependent library directly. | |
Re: "Global" data structures updated at random by multiple processes is generally a formula for disaster. Much better to create a proper class for data persistence with public methods that the GUI can call to submit data. Define the signatures of those public methods very carefully, then look at how best … | |
Re: Did you look at using a styled document in a text pane? [url]http://java.sun.com/javase/7/docs/api/javax/swing/text/DefaultStyledDocument.html[/url] | |
Re: Java does support mp3 [url]http://java.sun.com/javase/technologies/desktop/media/jmf/mp3/download.html[/url] For info on how to get the individual samples and do a FFT see [url]http://jvalentino2.tripod.com/dft/index.html[/url] unbump.. Am I really the only person on this forum who knows how to use Google? | |
Re: Short version: It's testing individual pieces of a (large) system one at a time to get them working as specified before putting them all together to test the complete system. Building and testing a complete sytem is a horribly inefficient way of finding a bug in one small component. | |
Re: Just a small hint here: think about a Card class with instance variables for suit and rank (which ideally would be enums). A deck is then a simple array or Collection of Cards. | |
Re: [QUOTE]its not working.[/QUOTE] Do [B][I]you [/I][/B]think this is enough info to allow someone to help you? | |
Re: Cut your program down to the smallest/simplest version that shows this problem and post your code here (don't forgte the CODE tags) - 1.6u20 definitely does display windows correctly with Win 7, so there's probably something wrong with your code. | |
![]() | Re: Your enums are members of the Player class with default access, so you can't refer to them from just anywhere. Making them public will help, as will using their fully-qualified names (like line 12). ps: The members of the enums are locations and items, so adding "ID" to their names … |
Re: On which line? Or shall I guess? ... I see a line number with two digits ... the first looks like a one, the second is .... wait for it ... a nine? | |
Re: What do the methods like x.Brand(); do? BMW@a62fc3 is what the public String toString() method produces when it's inherited from Object. Many Java API methods call toString() when they need a textual representation of an object (eg System.out.print(...)). It's normal practice to override toString() in any new class you define. … | |
Re: Yes, import does nothing that you can't do by always using the fully qualified names for all the classes you use. This saves a LOT of typing | |
Re: The Date and Calendar classes will do the parsing and give you access to the value as a nunber of milliseconds since <some date/time that I can't remember now> in a long integer, which is exactly what you need for calculating intervals etc. | |
Re: You need to look again at the algorithm for bubble sorting - it needs two nested loops and you've only got one. Also arr[x+1] is going to fall off the end of the array with your current loop. ps: "I know the brackets are off a bit" - that's inexcusable. … | |
Re: Read up on Swing Threads - your wait is causing the whole of Swing to wait - hence no screen updates | |
Re: Java has a Preferences class that's ideal for what you need. It's as easy as [CODE]Preferences prefs = Preferences.userRoot().node("myEditor"); prefs.putBoolean("lineWrap", true); ... if (prefs.getBoolean("lineWrap", false)) ...[/CODE] UI should be a dialog, and keeping it modal makes coding, and using, it easier. | |
Re: [QUOTE]Does the command line execution needs main() ? Is there a way to execute without the main() from the command prompt.[/QUOTE] Yes. No. | |
Re: If ExtendedMovie extends Movie then you can access the name via the inherited accessor methods of the Movie class | |
Re: You are using the length() method for a File object that is a directory. The [B]API reference[/B] says: [B]The return value is unspecified if this pathname denotes a directory. [/B] so that's why you get 0. You will have to sum the sizes of the individual files in the directory … | |
Re: You can use DeadSoul's code, but instead of the SQL query from line 8 onwards, remove the object from your array. I strongly recommend that you replace the array with an ArrayList which will greatly simplify your code for adding and removing records (use its add(...) and remove(...) methods) as … | |
Re: Nobody is going to try to check this code until you indent it properly - it's just too hard to match up the {}. And please tell us what the exact error message is, this isn't a quiz. And class Items should be called Item - each instance represents exactlyy … | |
Re: "We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well." |
The End.