7,116 Posted Topics
Re: Why not just create an array of GregorianCalendar instances, exactly like an array of Strings? [CODE]GregorianCalendar[] myCal = new GregorianCalendar[99]; myCal[0] = Calendar.getInstance(); // etc[/CODE] To output a GregorianCalendar instance in any specific text format you can imagine, use SimpleDateFormat, eg like this: [CODE] SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Calendar … | |
Re: It's going to be difficult for anyone to answer a question that's quite as wide open as this one. You could look at a 3-layer architecture (GUI/object model/data persistence) - in which case start with the object model and define the classes and their public methods (these just need to … | |
Re: Hi Majestics. Judging by the lack of replies, not many people here know the answer. Could you please take a couple of minutes to tell us all how you solved this? Thanks | |
Re: Maybe the problem is at a higher level - the top-level container. Do you add wholeItems to that (not itemsPanel!), do you pack() it afterwards? ![]() | |
Re: You can create a new Image object in the worker thread, get its Graphics, and draw your page to it. Then in the paintComponent swing thread you just need to draw that Image to the Swing Graphics. Google "Java off-screen rendering" for examples and discussions | |
Re: [QUOTE=NormR1;1602404]What doc are you getting that from?[/QUOTE] The source code for the API is downloadable from [url]http://download.java.net/jdk6/source/[/url] | |
Re: [CODE]Student.printDetails();[/CODE] printDetails is an instance method that prints the details of a single Student. It only makes sense when you call it for a single Student. You are trying to call it using the class Student, so Java doesn't know which Student you want to print the details of. [QUOTE]I … | |
Re: Hi there. Seriously, if you don't have any interest in Java then look for jobs that don't need it. It's no fun working in a job where you use stuff you don't enjoy. C/C++ skills are still in demand if you look towards software companies more than end user organisations. | |
Re: The current version of Java is Java 6, confusingly version numbered as 1.6. There's no reason to work with any earlier version unless you are specifically required to do so. (Java 7 / version 1.7 is due out later this year, but doesn't add much over 1.6.) Anything you find … | |
Re: [QUOTE]what is arg1.x , arg1.y ??[/QUOTE] arg1 is a Point. Look at the API doc for Point - you will see that it has two public variables x and y representing the x and y coordinates of the Point. By changing them you prove that the calling program's variable can … | |
Re: [QUOTE]My supervisor told me it would not reach 100 transaction per day.[/QUOTE] I wish I had a dollar for every time a user told me "x will never happen" and then it did, after I shipped the code. Let's hope, for your code's sake, that your supervisor's business doesn't take … | |
Re: [QUOTE]StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead. [/QUOTE] (API doc for StringTokeniser) You should do a lot better by … | |
Re: [QUOTE=pro_learner;1602014](Cat kitty) is a constructor.....[/QUOTE] I believe you meant to say is a [I]parameter[/I]. | |
Re: What's stopping you from creating an activity class that extends android.app.Activity or one of its subclasses? [url]http://developer.android.com/reference/android/app/Activity.html[/url] | |
Re: Hint: It's recursive. ps Treat RoseIndia (note correct spelling) with some caution, although there's a lot of useful code there, some of its stuff is out of date and some is just poor quality. | |
Re: Use java.util.GregorianCalendar instead of Date. This class does days, weeks, months etc properly, and is the reason why the old methods in the Date class were deprecated. ps: When you look at the javadoc for GregorianCalendar you'll find all the interesting methods are inherited from the abstract class Calendar, so … | |
Re: The API doc for Printable includes this: [QUOTE]For correct printing behaviour, the following points should be observed: The printing system may request a page index more than once... ... the Printable should expect multiple calls for a page index and that page indexes may be skipped, when page ranges are … | |
Re: If your indentation is right the continue on line 59 is the last statement in the while loop 47-60. If that's the case then it has no effect. What did you expect it to do? | |
Re: onButtonCalculate method has no code in it. actionPerformed method in btnResetListener has no code in it. You define action listeners, but you do not add them to the buttons. (and maybe more like these?) In brief, it doesn't work because you haven't finished coding it! | |
Re: You will create 1000 objects, but the only references to them are in the 1000 local variables myObject. Those variables each go out of scope as soon as the method finishes, leaving the object having no references. That makes it eligible for garbage collection, and the garbage collector will destroy … | |
![]() | Re: So, given a category you want to take each of the words in that category and see if they appear in a given text? If so, NormR1's idea is a good way to go. |
Re: I doubt that anyone will try to understand those hundreds of lines of incorrectly indented uncommented code, so you'll have to debug this yourself. Just use lots of print statements to confirm the values of all the variables in and around where things are going wrong. And don't forget to … | |
Re: Line 12. Array sizes and indexes must be int or convertable to int (byte, char). They can't be long. [QUOTE]The type of each dimension expression within a DimExpr must be a type that is convertible (§5.1.8) to an integral type, or a compile-time error occurs. Each expression undergoes unary numeric … | |
Re: It's no good trying to draw things to the Graphics like that - Swing is in charge of drawing and will ignore/over-paint your drawing. The correct way is to override the paintComponent(Graphics g) method to include your own drawing code. Swing will call this whenever it is necessary - eg … | |
Re: There's nothing wrong with that as an OO design. Well done. The main thing you could improve are the player1/player2/player3 variables. What happens if you want four players? It would be a lot better to have an array of Players (and an array of boolean results) - this will eliminate … | |
Re: What code are you using to load the images? What [I]exactly [/I]does your image file path look like? | |
Re: [QUOTE=jackmaverick1;1598472]The only thing I would suggest is to use a switch statement. They are much easier to use.[/QUOTE] Yes, dump the nested ifs and go with an enum for Weather values, and a switch. Much clearer and easier to understand and modify. | |
Re: I agree with the previous posters. Don't learn the API, learn to use the API JavaDoc and Google to find what you need when you need it. As you build up experience you'll get to know the most common APIs, and you'll be able to copy/paste from things you have … | |
![]() | Re: Why not use writeObject/readObject via an ObjectOutputSream/ObjectInputStream to send/receive your image in a single call? ![]() |
Re: Is this connected with the META-INF in every executable jar file? | |
Re: [QUOTE=wizzwig;1593024]... and end up with an executable.[/QUOTE] [QUOTE=wizzwig;1593024]... With bytecode output that can be executed by the java command? yes thats right [/QUOTE] You realise that these two can't both be right? | |
Re: Open a ServerSocket in one process and listen for connection, use a Socket in the other process to connect to it. Open matching input/output streams at both ends, send data across the streams. It's exactly the same as connecting client/server on two different computers. There are lots of examples on … | |
Re: Notepad + command window until you master the basics. JCreator Lite for help without taking over control. Eclipse or NetBeans for professional developers. | |
Re: If this is the app we have been discussing elsewhere then you have quite a high transaction volume - in which case maybe you should be using/reusing a PreparedStatement rather than creating and parsing a new Statement for each transaction. [url]http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html[/url] | |
Re: public static void sortNumbers( int oddNumbers[], int evenNumbers[] ) sortNumbers( randomNumbers ); So here we have a method declaration that requires two int arrays as parameters And we have a method call that passes only one int array as parameter. That's not legal Java. | |
Re: This sounds to me like you want to disable all the cells in cols B and C until the user selects a cell in col A. At that point you want to enable just those cells in col B that are valid for the chosen value in Col A (ditto … | |
Re: There are ints and there are Integers (there is no Java data type called integer). One is a primitive value, the other is an Object. int variables cannot be null, but Integer variables can be. What you get when the user presses Enter depends on what method you are using. … | |
Re: For OO design there were many attempts at a standard, but eventually they all converged into one called "Unified Modelling Language" or UML. That's the only game in town now. Despite its name it's all about diagrams, not text. [url]http://en.wikipedia.org/wiki/Unified_Modeling_Language[/url] Google for more info | |
Re: If you have question create new thread don't try to hijack one from 2007. Read the notice at the top of the Java forum main page "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." So … | |
Re: You have all kinds of { and } that are wrong, and some that are missing. The best way to see them is to go through your code indenting it properly so you can match up { with }. Posting your code with valid code tags will also help (select … | |
Re: Here is a good introduction to enums [url]http://download.oracle.com/javase/tutorial/java/javaOO/enum.html[/url] | |
Re: You can use the new (since Java SE 5) Proxy class to define a proxy to use when making a connection to a URL. So you could try using each of your proxies to access (say) google.com [url]http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html[/url] (topic 3 "proxy class) about 1/2 way down) Once you have a … | |
Re: @IIM Please be aware that we do not do people's homework for them. By supplying the OP with a "corrected and optimised" solution you are simply inviting him to copy/paste the whole thing and learn nothing (except maybe that cheating is easier than learning). On the other hand, this is … | |
Re: Let me check: you have multiple products each with multiple attributes. You want to display one line per product, with the attributes in aligned columns. Is that right? If so, use a JTable. | |
Re: If you have 1.6 then you should have everything you need, regardless of OS platform. Have a look at [url]http://www.javaworld.com/javaworld/jw-06-1999/jw-06-javamail.html[/url] then look at the javamail documentation on Oracle's Java web site. | |
Re: Transparent windows are an AWTUtilities/Java7 thing. I don't believe this is possible without them. Why are you avoiding them? | |
Re: [QUOTE]and I think you can't make an object of type abstract [/QUOTE] Correct. You cannot create an instance of an abstract class. You could add: A class that extends an abstract class but does not provide an implementation for all the abstract methods must also be declared abstract. | |
Re: [QUOTE]at CandleLineApplet.itemStateChanged(CandleLineApplet.java:67)[/QUOTE] Line 67 is part of [I]public double getOrderAmount()[/I] in your code, so the code you posted doesn't match the error message. This is not helpful! Null pointer means uninitialised variable OR a method returned null and you tried to use the returned value. Check the actual line in … | |
Re: [QUOTE=winecoding;1587982]Can I assume that .equals() should be an robust approach to avoid these uncertainties? Thanks.[/QUOTE] Have a look at the documentation for Integer. It says [QUOTE]public boolean equals(Object obj) Compares this object to the specified object. The result is true if and only if the argument is not null and … |
The End.