7,116 Posted Topics

Member Avatar for aanders5

Anytime I see variables names xxx1, xxx2, xxx3 etc I wonder whether xxx should be an array.

Member Avatar for aanders5
0
217
Member Avatar for iammet
Member Avatar for ajst
0
355
Member Avatar for DARK_BYTE

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.

Member Avatar for JamesCherrill
0
380
Member Avatar for rowen17

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

Member Avatar for rowen17
0
179
Member Avatar for jrookie

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 …

Member Avatar for JamesCherrill
0
115
Member Avatar for warook
Member Avatar for peter_budo
0
112
Member Avatar for warook

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 …

Member Avatar for JamesCherrill
0
319
Member Avatar for Sunshineserene

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?

Member Avatar for Sunshineserene
0
315
Member Avatar for H0AX4

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!

Member Avatar for JamesCherrill
0
151
Member Avatar for chippanfat

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

Member Avatar for jon.kiparsky
0
196
Member Avatar for nitins60

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]

Member Avatar for ~s.o.s~
0
160
Member Avatar for Theformand

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

Member Avatar for Theformand
0
162
Member Avatar for shiftee

[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 …

Member Avatar for JamesCherrill
0
286
Member Avatar for ajst
Member Avatar for rcogq7

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)

Member Avatar for JamesCherrill
0
100
Member Avatar for blknmld69

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 …

Member Avatar for JamesCherrill
0
652
Member Avatar for jemz

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?

Member Avatar for jemz
0
75
Member Avatar for Tankadin

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 …

Member Avatar for quuba
0
430
Member Avatar for Theformand

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 …

Member Avatar for JamesCherrill
0
165
Member Avatar for Kuroshi

All the source code for the Java API can be downloaded (free & legal) from Oracle's web site. This includes java.lang.Class

Member Avatar for peter_budo
0
133
Member Avatar for JDCyrus

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 …

Member Avatar for JDCyrus
0
183
Member Avatar for AhmedGhazey

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 …

Member Avatar for pbl
0
141
Member Avatar for deniseblue

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

Member Avatar for deniseblue
0
102
Member Avatar for alvalany

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.

Member Avatar for JamesCherrill
0
99
Member Avatar for crisabraham

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 …

Member Avatar for JamesCherrill
0
125
Member Avatar for kyojin

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.

Member Avatar for Ezzaral
0
183
Member Avatar for XxPKMNxX

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.

Member Avatar for JamesCherrill
0
235
Member Avatar for Kiseki

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.

Member Avatar for Kiseki
0
268
Member Avatar for Dean_Grobler
Member Avatar for spades0001

[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]

Member Avatar for laupkram
0
113
Member Avatar for blknmld69

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 …

Member Avatar for Gerbiler
0
2K
Member Avatar for grady-lad

It would be helpful if you identified the exact line on which the NPE was thrown.

Member Avatar for JamesCherrill
0
99
Member Avatar for sleepybug

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 …

Member Avatar for JamesCherrill
0
163
Member Avatar for anupam.j2ee

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 …

Member Avatar for JamesCherrill
0
74
Member Avatar for palavi

In your loop keep a counter, then make a file name something like this: String fileName = "familyname" + counter + ".parts.txt2;

Member Avatar for Linez
0
1K
Member Avatar for Abdel_eid

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.

Member Avatar for JamesCherrill
0
129
Member Avatar for sciprog1

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.

Member Avatar for sciprog1
0
282
Member Avatar for Yutxz

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 …

Member Avatar for JamesCherrill
0
108
Member Avatar for Member 784374

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 …

Member Avatar for JamesCherrill
0
94
Member Avatar for Dean_Grobler

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...

Member Avatar for JamesCherrill
0
128
Member Avatar for jbalaji87

As usual, you should override paintComponent, not paint [url]http://download.oracle.com/javase/tutorial/uiswing/painting/closer.html[/url]

Member Avatar for jbalaji87
0
103
Member Avatar for keanoppy

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"); …

Member Avatar for JamesCherrill
0
177
Member Avatar for daudiam

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.

Member Avatar for daudiam
0
634
Member Avatar for spades0001

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.

Member Avatar for JamesCherrill
0
90
Member Avatar for musikluver4

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(",", "");

Member Avatar for JamesCherrill
0
175
Member Avatar for StaticX
Member Avatar for deniseblue

[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)

Member Avatar for apines
0
231
Member Avatar for fahadyousaf

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.

Member Avatar for JamesCherrill
0
129
Member Avatar for Buffalo101

You should use the swing timer for ordinary tasks that relate to swing GUIs. util.timer is for more general/complex timing tasks.

Member Avatar for Buffalo101
0
1K
Member Avatar for ivanhuk

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.

Member Avatar for JamesCherrill
0
166

The End.