1,963 Posted Topics
Re: 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 | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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= … | |
Re: 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 … | |
Re: 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"; … | |
Re: 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 = … | |
Re: 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 … | |
Re: [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 … | |
Re: How does it behave? Has JOptionPane.showMessageDialog an "OK" button? Waht did you expect to receive. Perhaps you should use the syncronized keyword. | |
Re: 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 | |
Re: Netbeans IDE can do it. Although for most cases I prefer to hardcode it becuase that gives me more flexibility | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: [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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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. … | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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, … | |
Re: 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 … | |
Re: What is your code? Do you use: resultSet.getString(); or resultSet.getDouble(); ? Perhaps you can do this: double d = Double.parseDouble( resultSet.getString(3) ); | |
Re: 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 … | |
Re: 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 … | |
Re: You could use the time in millis and take the last digit: System.currentMillis(); if I remember correct the method. | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: Are you importing any of the packages that these things are? | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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. | |
Re: 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...(...) . | |
Re: 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 … | |
Re: 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 | |
Re: Instead of Arete use this.x=x; Arete.someVariable is used when the variable is static |
The End.