1,963 Posted Topics

Member Avatar for anbuhikaru

Declare the variables in the class, instantiate them in the constructor. Read about JFrames. Also I put in the constructor the code that generates the gui. Then call the class from a main method

Member Avatar for jwenting
0
86
Member Avatar for mattcrow

One of our teacher who used to work at the Supply Management of a company (logistics) told us that everybody where making requests for supplies saying that it was extremely urgent, so he could not decide which request to handle first. Then he came up with the idea not to …

Member Avatar for javaAddict
0
145
Member Avatar for anbuhikaru

Read all the file in an array or a Vector and generate a random number from 0 to size-1. Then take from the array the element that is at the place of generated number.

Member Avatar for javaAddict
0
228
Member Avatar for NycNessyness

My swing is a little rusty but if you add an Object in a comboBox, the toString() method will be displayed. And when you try to get the selected item it will return the entire object. So have an object Person with attributes: name, percentage. The Person should have a …

Member Avatar for NycNessyness
0
119
Member Avatar for alannabrittany

[QUOTE=alannabrittany;607897]im not exactly sure where to start and i dont really understand it. i dont know if im right, but i tried to understand the question by following the sample inputs. For example, the first sample input, (1 5 9 + 8 – + ), you take leave the 1 …

Member Avatar for javaAddict
0
125
Member Avatar for s080072

And what if the user enters 24? Then he should check for 2,3,4,5,8,12. The algorithm for checking prime numbers is a little bit more complicated. It will require a for loop from 2 till the number divided by 2. Then in the for-loop you will have the if statement like …

Member Avatar for javaAddict
0
94
Member Avatar for Alistair1

[CODE] String a = ""; System.out.println ("Please enter the sentence to analyse"); a = userInput.nextLine(); if (a.length!=0) { if ( (a.charAt(a.length-1) == '.') || (a.charAt(a.length-1) == '!') || (a.charAt(a.length-1) == '?') || (a.charAt(a.length-1) == ' ') ) { a = a.substring(0,a.length-1); } } System.out.println (""); System.out.println ("Here are some statistics …

Member Avatar for Alistair1
0
109
Member Avatar for alpe gulay

Have you included this mysql-connector-java-5.0.7-bin.jar jar file? If not use the above first and if it doesn't work try the below I think that the problem is with value you use for: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); At first try to write: e.printStackTrace(); inside the catch(). You will get a better view of the …

Member Avatar for alpe gulay
0
143
Member Avatar for ebebcb

You should post the errors the compiler gives you, and at which line you get them. You call these methods like this: prime(isPrime); noPrime(isPrime); And you declare them like this: public static void prime(isPrime, int number) public static void noPrime(isPrime, int number) Plus, at the main method you don't declare …

Member Avatar for javaAddict
0
75
Member Avatar for geisteskrankhei

Since the user inputs the size you can create the array: int [][] array=new int[N][N]; Then use a for-loop to put numbers in the array. As I noticed at your example the random numbers are from 1 to 9. Is that a requirement? Meaning do the numbers have to be …

Member Avatar for Ezzaral
0
181
Member Avatar for fj822

Your class is an interface: public interface SipStack So you can [B]not[/B] write code only declarations of methods and variables. So this: myListeningPoint= sipStack.createListeningPoint(port, "udp"); shouldn't be there. And by the way: myListeningPoint is declared as a method: ListeningPoint myListeningPoint(); This would be wrong anywhere you write it : myListeningPoint= …

Member Avatar for fj822
0
146
Member Avatar for warjas816

Can't you read the errors and follow the instructions to fix them? When you get compile errors you get a description of the error, the line that it happened and how to fix it. Why doesn't anybody read compile errors these days and just post the code without even bothering …

Member Avatar for javaAddict
0
86
Member Avatar for tyczj

You are trying to turn a EmployeeAryApplicEx instance into a EmployeeMultiTypeSeqFileExer, which cannot be done. I presume that you wrote something like this: [CODE] EmployeeAryApplicEx empAryApplicEx=new EmployeeAryApplicEx(); EmployeeMultiTypeSeqFile empMultiTypeSeqFileExer=new EmployeeMultiTypeSeqFileExer(); empMultiTypeSeqFileExer = (EmployeeMultiTypeSeqFile)empAryApplicEx; [/CODE] What you did is like trying to cast a String into an Integer: [CODE] String s="3"; …

Member Avatar for tyczj
0
112
Member Avatar for wujianwei

What do you mean when you say button tip? If you want a message appearing when you put the mouse on the button then use this: JButton button = new JButton("Save"); button.setToolTipText("Click to Save the file"); If you want to have the button activated from the keyboard: JButton button = …

Member Avatar for javaAddict
0
98
Member Avatar for kimbostun

First of all equalDeals does what equals does. So delete equalDeals. Inside the MutiItemSale class you will define an array of Sale objects: Sale [] sales = new Sale[100]; //the 100 is for this example, you can use what you want. You can have a count int variable and when …

Member Avatar for javaAddict
0
105
Member Avatar for rh3883

[CODE] number = SavitchIn.readlineInt(); int sum=0; int count=0; int tempMax=number; int tempMin=number; while ( number != -1 ) { //have an int variable(count) that increases by 1 each time, counting how many numbers //were given //add each number to the sum variable in order to have the total sum //use …

Member Avatar for javaAddict
0
114
Member Avatar for alpe gulay

How does it behave? Has JOptionPane.showMessageDialog an "OK" button? Waht did you expect to receive. Perhaps you should use the syncronized keyword.

Member Avatar for javaAddict
0
89
Member Avatar for dayanandabv

At which line do you get the Exception? What does the console prints. Try adding try-catch with printstacktrace so you can provide us with more information

Member Avatar for dayanandabv
0
154
Member Avatar for alpe gulay

Netbeans IDE can do it. Although for most cases I prefer to hardcode it becuase that gives me more flexibility

Member Avatar for javaAddict
0
100
Member Avatar for puk

Your code is correct. This is how it is done. The problem is that you are trying to convert the String: "Enter Answer here!" into an int which cannot happen. As you can see at the message that you posted it: Exception in thread "main" java.lang.NumberFormatException: For input string: "[B]Enter …

Member Avatar for javaAddict
0
186
Member Avatar for jk_bscomp

And have a class that reads from the database and gets the data you want to display in a String, or an array, or in whatever you want. You call that class in your gui and display the results like peter_budo said. As you can a lot of things are …

Member Avatar for javaAddict
0
116
Member Avatar for degamer106

javadoc has some other parameters as arguments besides the filename.java. I don't remember them exactly but if you search the internet you might find ways to use them

Member Avatar for javaAddict
0
105
Member Avatar for gator6688

[CODE] for(int i=1; i<employees.length+1; i++){ output += employees[i-1].toString();<<<<<This Line [/CODE] One of the employees[i-1] is null, meaning that you don't instantiate all the elements of the array. That happens because inside the for-loop you have an option with the command: break; So if the user gives "Quit" you break from …

Member Avatar for javaAddict
0
130
Member Avatar for kira4

If you are a beginner in Java and you cannot understand this thing how can you expect write something as complex as an emaiSender combined with GUI. Even I don't dare to try this. What he told you is that inside the main there are commands that are executed one …

Member Avatar for VernonDozier
0
140
Member Avatar for terence193

I would suggest not to download the API. You don't need the entire API since you are new to java and it will confuse you. The API is not going to help you learn java. And you have written a few programs with the notepad try to download a java …

Member Avatar for javaAddict
0
130
Member Avatar for chweetnancy

[QUOTE]public static string showOutput(int a, int[]signal,int[]smooth)[/QUOTE] There is not such thing as a "string". The correct declaration is String with capital S. And most important, java is case sensitive. Meaning that if you want to call the above method you should call it like this: showOutput NOT like this: showoutput. …

Member Avatar for jwenting
0
107
Member Avatar for shouvik.d

Create a class that will represent the data from the database. Create a separate class with queries and methods that return the data from the DB. When you open the GUI call these methods and use the data to populate the combobox. Since you will have many Jpanels Child I …

Member Avatar for javaAddict
0
144
Member Avatar for thatnewbreed

[QUOTE]the catch block should should print out an error message (nonGUI) and return zero as the GPA , and the finally block should print out a message (nonGUI) indicating the method finished[/QUOTE] You will put the code that calculates the GPA inside the try. Inside the catch you will print …

Member Avatar for javaAddict
0
123
Member Avatar for Taz x

Useful example for objects in arrays: CdRecord [] records = null; : This is an array that takes CdRecord objects. THE ARRAY IS NULL CdRecord [] records = new CdRecord[2]; : This array IS NOT NULL. The records IS an array and it behaves EXACTLY like any other array. But …

Member Avatar for javaAddict
0
255
Member Avatar for KimJack

The stack.push is inside the for-loop. Meaning that insert the same token more than once. For example if token="123" then you will check if "1" is a digit and then you will push the token. then you will check if "2" is a digit and then you will push the …

Member Avatar for javaAddict
0
817
Member Avatar for sosuave

For the random generated numbers try : Math.random(); . It will return a random double between 0 and 1. You can then multiply with 100 and cast it to an int [QUOTE]I need to Populate the class taken whth an empty string[/QUOTE] Add getters and setters for the variables: name, …

Member Avatar for javaAddict
0
107
Member Avatar for jimJohnson

First of all, can someone explain to me what he said?: [QUOTE] Ezzarel you dont havta reply to this prolly think I am the biggest idiot living but I still am having problems with this program...I tried movin a bench of stuff around but just went back to this w\some …

Member Avatar for jimJohnson
0
185
Member Avatar for Kusno

What is your code? Do you use: resultSet.getString(); or resultSet.getDouble(); ? Perhaps you can do this: double d = Double.parseDouble( resultSet.getString(3) );

Member Avatar for Kusno
0
305
Member Avatar for dakrous

Store them where? Because you are already storing them in varables: [CODE] int frow = Integer.parseInt(st.nextToken()); int fcol = Integer.parseInt(st.nextToken()); [/CODE] Where you want them to be stored? You can put these variables wherever you want. Perhaps create a new class for each line and put those values in the …

Member Avatar for dakrous
0
125
Member Avatar for DickLaurent

Lines 74 to 84: [CODE] catch(FileNotFoundException fnfe) { System.out.println("File Results not found.");} catch(IOException ioe) { System.out.println("Unable to read from Results");} return area; } [/CODE] As you can see you are missing a bracket. And here is a tip for the future. Whenever you open a bracket immediately close it, and …

Member Avatar for DickLaurent
0
142
Member Avatar for chandanapapa

You could use the time in millis and take the last digit: System.currentMillis(); if I remember correct the method.

Member Avatar for jwenting
0
106
Member Avatar for KimJack

Why did you create a new thread and ask the same question? If you didn't understand my answer at the previous thread then ask for more details or ask a better question.

Member Avatar for Ezzaral
0
116
Member Avatar for 9107you

You don't need this: public static double At your system.out, instead of Bonnie, you will have a variable. And according to your assignment the user will give this value from the keyboard. And from what I see the song has many lines that repeat so you can store these lines …

Member Avatar for javaAddict
0
127
Member Avatar for Katherine692008

The data would probably be inside an array. Write a write-loop that reads the array and checks every element if it is 12. Then break from the loop because you only need the first. After you print the result then write another while-loop that reads the array backwards and does …

Member Avatar for Ezzaral
0
133
Member Avatar for cage

You are only reading the word to censor. You should read the word that will replace the first word you read, as well as the text in which you will search for the word to censor. I think that the : keyboard.nextDouble(); returns double You must declare a variable in …

Member Avatar for Ezzaral
0
816
Member Avatar for a_iyer20

I believe that the Collections class has a sort method: Here is what you must do: Your object that you put inside the ArrayList has to implement the Comparable interface. When you do that you will have to implement the compareTo method that compares this object with another object. This …

Member Avatar for a_iyer20
0
129
Member Avatar for denniskhor
Member Avatar for Katherine692008

Just count how many braces you have opened and how many you have closed. Make sure that when you open a brace you must close. So don't open a brace, start writing and then after lots of code try to remember where to close it. What you should do is …

Member Avatar for javaAddict
0
143
Member Avatar for Kusno

The java way to do it is to create a class with attributes: CountryName, CountryID Then create a method that runs the select-query, gets those values from the DB and puts them inside a Vector or ArrayList of that class and then of course return it. Since you have the …

Member Avatar for javaAddict
0
96
Member Avatar for welbyobeng

It would be if you use one for-loop instead of 3. You could have 3 boolean variables inside the for-loop taking values true or false depending on the current character. And at the end check if all of them are true

Member Avatar for javaAddict
0
106
Member Avatar for karlee

Where exactly do you get that NullPointerException because I don't think that people will find it easy reading your whole code. And it is probably because you are using an object that has not been instantiated. Use the "new" word.

Member Avatar for Ezzaral
0
172
Member Avatar for it2051229

Instead of a second frame use a dialog box. Read in this [URL="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JOptionPane.html"]JOptionPane[/URL] the static methods that begin with show...(...) .

Member Avatar for Ezzaral
0
301
Member Avatar for Dr Windows (XP)

You will never get inside the while loop because you set count=0 and you don't know what x or y will be. Since you are setting x to be you starting number try this: [CODE] int x; int y; int div=2; int count=0; System.out.println ("Enter the starting point N:"); x …

Member Avatar for Dr Windows (XP)
0
166
Member Avatar for Katherine692008

Personally I have no idea what are you talking about. If you want to change a String to int then use: String s="2"; int i=Integer.parseInt(s); The rest of your post don't make any sense

Member Avatar for Katherine692008
0
115
Member Avatar for Virginie

Instead of Arete use this.x=x; Arete.someVariable is used when the variable is static

Member Avatar for javaAddict
0
76

The End.