7,116 Posted Topics
Re: Anytime I see variables names xxx1, xxx2, xxx3 etc I wonder whether xxx should be an array. | |
Re: getSelection() method for the ButtonGroup that they are both in. | |
Re: The keyword you are looking for is "package" - a grouping of Java classes. Have one project with a number of packages. You'll find the syntax and documentation in the usual places. | |
Re: Your line nos seem 1 out from the error messages, but studno1 = new JLabel(text[9]); is the line in question text = new String [9]; is the size of "text" so the valid array indexes for text are 0..8 | |
Re: This is all about the default constructors that Java provides when you don't provide one. Student has a defined constructor with ~6 params, so that's that. End of story. Graduate has no constructor defined, so Java provides a default no-args constructor for you. If a constructor does not begin with … | |
Re: Duplicate thread [url]http://www.daniweb.com/forums/thread330156.html[/url] | |
Re: In OO design classes represent things, and methods represent actions. (OK, this is the very simplified version!). So a class "sell" or "buy" is probably a bad idea, although Deans "buyScreen" and "sellScreen" are OK because they represent bits of GUI. However, this is all a bit cart-before-the-horse. Look at … | |
Re: alexchen 1. We don't just give people the code for their homework - that teaches them nothing, and 2. I guess you hadn't realised that this is a Java forum? | |
Re: You aren't getting any output becuase you haven't asked for any! You call new Student and calculateFee but neither of these produces any output (unless there is an error). You have a displaylnfo method - it would be a good idea to call that! | |
Re: Jon said something v important - either you do not want mantissa/exponent or your example is completely wrong. You need to check the specs for this project before going any further | |
Re: You can test to see if the Customer object is actually a Member, and then cast it to the right class [CODE]public void printTransaction(Customer customer) { if (! customer instanceof Member) return; Member m = (Member) customer; if(m.memberID exists) { // give discount; } }[/CODE] | |
Re: Line 30 you create a new array variable rather than using the existing "values". The new variable goes out of scope at the end of that method, leaving the original still null | |
Re: [QUOTE]Are Exam and its implementation the same thing??[/QUOTE] No, but in this case the method is defined as returning an Exam. Because Exam is an interface you cannot instantiate one directly. If ExamImpl implements Exam then this is a class that you can instantiate, and any instance of it will … | |
Re: There's no code there to add any controls to a JPanel. | |
Re: I guess the "parallel arrays" 1 & 2 contain (1) each value that occurs in the source data and (2) the number of times that values appears. Then you can search (2) for its max and get the corresponding value from (1) | |
Re: This looks OK to me. Only thing I can think of is that it may be using the java.util.Timer not the javax.swing.Timer (although with your include statements that shouldn't happen?). If you're still stuck it may be worth just trying making that explicit by changing line 12 to [CODE]private javax.swing.Timer … | |
Re: Sorry jemz, I have absolutely no idea what you mean, and I doubt that anyone else does either. Can you re-phrase this in a way we can understand? | |
Re: I can see why width or height <0 would be an error, but what's wrong with negative x or y? Haven't you even moved a window so its top left corner is just off the screen? You use IllegalArgumentException as your exception. This is a kind of RuntimeException which means … | |
Re: Get the array of Strings that you get from the split(" "). Create an array of integers of the same size. For each String in the array you can use a method in the Integer class (seek and ye shall find) to parse the string into an integer, which you … | |
Re: All the source code for the Java API can be downloaded (free & legal) from Oracle's web site. This includes java.lang.Class | |
Re: I don't have the references in front of me right now, but there is a solution that involves passing a "dummy" arg to the constructor whose type has to be <T>, then you can use the class of that param at runtime to instantiate your own vars with the same … | |
Re: You can debug this yourself by adding some print statements just before your if tests. Print the raw data that is going to be used in the test, and the results of any methods used in the test. This will immediately show you why your if tests are not giving … | |
Re: Looks like maybe problems with the Title class - which isn't in your post. ps Please post code in code tags with line numbers and correct indentation | |
Re: Java/Swing/MySQL is perfectly good and normal way to implement this kind of app [B][I]if[/I][/B] you need custom GUI screens. If it's just data entry/update/reports etc then Java may be overkill, and a simple database front-end scripting-type tool may give you a working solution for a fraction of the effort. | |
Re: There's no such thing as "no security vulnerability at all", so you have to ask "what do I want to protect against?" (eg unauthorised access, denial of service), and "how far do I need to go?" (eg good enough top prevent casual access, secure against the DHS's best efforts). If … | |
Re: Option 2 would be the standard "good O.O." way of doing it. Zetlin is not quite right - you define those methods in the parent class and the subclass will inherit them, and can call them directly. You do NOT need an instance of the parent class to do this. | |
Re: The CryptArith() method in IntFutoSol returns a null, so attempting to use that result for .a("0") results in an NPE Since I can't see from your uncommented code what you are trying to so, I can't tell you how to fix it. | |
Re: You have most of it there. Parse the input to a Date, get "now" as a Date, then get the time in millisecs from those. Subtract the two millisecond values and divide by 60,000 to get minutes. | |
Re: [url]http://download.oracle.com/javase/tutorial/java/javaOO/methods.html[/url] [url]http://download.oracle.com/javase/tutorial/java/javaOO/arguments.html[/url] [url]http://download.oracle.com/javase/tutorial/java/javaOO/returnvalue.html[/url] | |
Re: If I understand you right, then what you are doing is OK. Once someone has checked out that's it, they can't change the list of items later except by a possible "update existing order" function, and then only if the order hasn't been dispatched (at least, that's how e-shopping sites … | |
Re: It would be helpful if you identified the exact line on which the NPE was thrown. | |
Re: You write a series of Num objects to the file. They happen to be from an array, but that's irrelevant. The file contains just a series of Nums, one after the other. This is absolutely not the same as writing a array object to the file, so there's no way … | |
Re: This is a standard requirement, with a standard solution. Briefly: Create a class to hold your data, with 5 instance variables corresponding to the 5 fields. When the user presses "submit" create a new instance of the class, using the values from the fields. Define an ArrayList tto hold those … | |
Re: In your loop keep a counter, then make a file name something like this: String fileName = "familyname" + counter + ".parts.txt2; | |
Re: Using the class Class you can 1. Get an instance of Class from a String containing the name of the desired class and 2. Create an instance of the class defined by that instance of Class. Details of these 2 methods are in the API doc for Class. | |
Re: No. You may be failing to distinguish between a class and an instance of that class. You need Panel.class ( not java) at the client end so that the JRE understands what a "Panel" is. You can then use ObjectStreams to send/receive individual [B][I]instances [/I][/B]of Panel. | |
Re: Your paint method gets called when the applet is first displayed, and again every time things in the applet change (that was over-simplified, but will do for now). But every time it's called you do the whole prompt-for-input-and-display-output thing, which causes paint to be called again etc ad infinitum. You … | |
Re: Use the SimpleDateFormat class - create an instance using a pattern that describes your date's format, then use the parse method to convert your String to a java Date object. Once you have a Date object you can use another SimpleDateFormat to convert that to pretty much any format you … | |
Re: MainList is a non-static, ie instance, variable. Java creates one of these variables for every instance of MainScreen that you create. To access any one of these instance variables you need to use the the instance it belongs to. eg MainScreen myScreen = new MainScreen(); myScreen.Mainlist... | |
Re: As usual, you should override paintComponent, not paint [url]http://download.oracle.com/javase/tutorial/uiswing/painting/closer.html[/url] | |
Re: The following code assumes an "images" folder in the jar, or an "images" folder in the folder hierarchy where the class files are stored - it works in both situations so you can test in normal folders, then build the jar without code changes. [CODE]URL imgURL = getClass().getResource("/images/" + "newImage.JPG"); … | |
Re: I don't know the answer, but I know where you can find it... the entire source code of the API classes is freely downloadable from [url]http://download.java.net/jdk6/source/[/url] so you can look at the code and see exactly how it is written. | |
Re: You can change the foreground and background colours of Swing controls, and add icons to JLabels and JButtons etc, so you can do quite a lot of "customizing" without needing any additional software. | |
Re: You can leave the text field as it is and fix the commas after you read the text into your program, ie String textWithoutCommas = loanText.getText().replace(",", ""); | |
Re: What exactly is the error you are presented with? | |
Re: [QUOTE]This is the method that is called first, and when it ends the program ends as well.[/QUOTE] ... unless the program has more than 1 thread (eg every Swing GUI program) | |
Re: How do you know it's not returning? Because this is part of a window closing event how would you expect a return to manifest itself? Anyway, put a print statement just before the return to see if its being executed. | |
Re: You should use the swing timer for ordinary tasks that relate to swing GUIs. util.timer is for more general/complex timing tasks. | |
Re: What thread is this running on? If it's the swing EDT then you won't see any screen updates while your method is running/sleeping. |
The End.