7,116 Posted Topics
Re: Best practice is to have a "controller" class that has the public main method, and manages all the others. It can open the first window, run the SQL query class, and open the results window, passing the necessary data. The other classes need to accept an instance of the controller … | |
Re: First question is why? This class is for the exclusive use of ProcessBuilder.start() to create new processes. It's a private part of the internal technical implementation of Processes. It's definitely not a thing you should be messing about with at your level of Java expertise. | |
Re: percentEs = (totalVoteEs / totalVotes); totalVoteEs and totalVotes are both ints, so this division is done using integer arithmetic. Fractions are truncated to zero, so the result is zero. You can use a simple fudge like ` (1.0 * totalVoteEs / totalVotes)` to force the calculation into floating point, or … | |
Re: Yes, that makes complete sense to me (except line 5 where the math looks suspect). | |
Re: Interesting! Is it a requirement that it uses boolean logic like this? Could you, for example, use a recursive algorithm that would be relatively easier to code? | |
Re: You seem to be drawing strings to a Graphics called "brush" (an odd name for a Graphics, but nevermind), but I can't see where that variable is initialised. You also have a "paint" method in your ActionListener that doesn't seems to be called from anywhere. Overall it looks like you … | |
Re: A Java char is, by definition, a numeric value that represents a character. So you can freely mix character representations such as 'a' or 'Z' and numeric expressions, eg int i = 'C'; // i = 67 int j = 'C' - 'A'; // j = 2 | |
Re: Did your regex work with the array of test data (now commented out)? Have you printed the actual data in the String array after reading your file to see if the file input is doing what you expect? | |
Re: This is your third consecutive post about the scope of variables. Start by reading the link I already gave you. Don't expect any more answers until you have made more of an effort. | |
Re: Forgive me if I am wrong, but judging by this post, and your other post http://www.daniweb.com/software-development/java/threads/428659/getting-values-from-on-public-void-to-another-class I find it hard to believe that you "made" all that code yourself. You are jumping into quite complex areas (email, database) when there are catastrophic gaps in your knowledge of Java fundamentals (eg … | |
Re: There is no code that you can put instead of line 7 that will read the value of the variable on line 4. http://docs.oracle.com/javase/tutorial/java/javaOO/variables.html | |
Re: DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Please post what you have done so far, and we'll help you on from there. | |
Re: All yu need is ` if (strr[3] == null)` ... but if strr has not been initialised or is less than 4 elements in size you will need to deal with those possibilities before trying to use strr[3] | |
Re: Sun's documentation states "The default class path is the current directory". | |
Re: readLine drops the line termination character from the input stream, so all you have to do is put it back again, eg `savetext += text + "\n";` | |
Re: NPE means one of the variables on that line is null (unitialised) when you try to use it. let and aLetter could legally be null in that statement, so the culprit must be currentLink. Put print statements into your code to track the value(s) of currentLink so you can see … | |
Re: Despite previous post, arrays can also contain objects (depending on how they are declared) Object[] x = new Object[];. arrays are a fixed-size list of members). They not have methods etc. All you can do is refer tp individual elements. ArrayList is a Class. Instances of ArrayList can contain all … | |
Re: ... yes, but what is your question? | |
Re: If you Google *Java send email* you will find lots of examples of how to send emails from your Java program. This has nothing to do with whether or not you use Netbeans. | |
Re: DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules | |
Re: I agree with deceptikon, except that I can confirm from personal experiance that there is a definite age bias towards hiring juniors who will work 20 hour days for coke & pizzas, especially in exciting startup or high-prestige IT companies. However larger more established companies, where the managers are a … | |
Re: In a fraction of the time it took to create that post you could have Googled *set enviroinment variable setting and path settings for jdbc and servlets* and got lots of info and advice. If you're still stuck after doing that basic research, then come back here with a more … | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some … | |
Re: You have most of what you need, so it's mainly a question of organising it. Here, in pseudo-code is the kind of thing that will work... int[] testData = {78, 99, ... each value will be one search get the start time for (int key : testData) { search for … | |
Re: I'm with stultuske on this one. Use the knowledge you already have to construct the whole page as if it was a JFrame, then use the print api to print that instead of displaying it on the screen. ps sorry @softswing, but I would advise some caution about roseindia - … | |
Re: > when your form contains checkboxes, you can't see whether those are "filled in" since not filled in is one of it's values what's wrong with isSelected() for check boxes? (or did I misunderstand your post?) | |
Re: JTextFields support a basic subset of HTML tags, so you can achieve a lot of formatting by setting the text of the JTextField to some valid HTML (start with <HTML> ) | |
Re: DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question | |
Re: You don't suppy a lot of info, but I'm 99% sure you should have a Player class with one instance for each player. Obe class per player misses the whole point of classes. | |
Re: If you get the source code of the web page you could try any of the available Java HTML renderers to render the whole page into your own Image object. You can Google for "Java HTML renderer" and you'll see quite a few. Flying Saucer looks promising... http://flyingsaucerproject.github.com/flyingsaucer/r8/guide/users-guide-R8.html#xil_29 | |
Re: Use a DocumentListener to edit any input to the text field - see the "UpperCaseField" example at the start of the API doc for JTextField. | |
Re: You missed out the line where you declare and initialse myInput | |
Re: You need a *custom cell renderer* if you want complete control over the appearance of individual rows/cols/cells in your table. Start learning here: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editrender | |
Re: Line 23 you create a new data array every time you go through the loop, thus loosing the data from every earlier pass. You probably want to just create one data array, before you enter the loop. | |
Re: That piece of code looks through the string *str* and replaces everything that's not a letter with "" (nothing) - thus deleting everything that's not a letter. You need to do the same thing to *your* string after you get it from the user but before you start to analyse … | |
Re: `if(first == false)` is a long way of saying ` if(! first)` and `if(p[i] == true)` is a very silly way to say ` if (p[i])` | |
Re: What output do you get from lines 12 and 13? Also, print the length() of those two strings in case you have anything like trailing blanks or newline characters in there. | |
Re: This sounds like a problem with the specification, not with your Java! In reality there can always be two or more equal "highest" grades (eg supose Mr Genius scores 100% on every subject). You have a choice of just printing one of them or printing them all. In real life … | |
Re: David's post has incorrect syntax for a switch - it's missing the "case" keyword. Check the official doc for the correct version. ps: A switch using a String is only available from Java 1.7 onwards. | |
Re: Looks like isa1 has a wrong value. Use print statements throughout your code to print the key variables so you can see where it's going wrong. | |
Re: Ata guess you have an exception thrown before line 28, so insert (the variable, not the method) is still null when the finally blcok is executes after the catch? | |
Re: > can't pass the String object as a parameter to create a string with that Suggest you read the API doc for String. Passing a String as a parameter to a String copnstructor is perfectly OK. > public String(String original) > > Initializes a newly created String object so that … | |
Re: I didn't try to understand all your code, but maybe your problem starts from the fact that you are mixing [row][col] coordinates and x,y coordinates? Note that x corresponds to col and y corresponds to row, so the order of the coordinates is opposite between those two representations. Sooner or … | |
Re: `if(!(((ch<=90)&&(ch>=65))||((ch<=122)&&(ch>=97))||(ch==8)||(ch==127)))` Please don't do this in Java, it's not C. Firstly, you don't need to use opaque numeric values when what you mean is a character. Much better to code `ch>='a' && ch<='z'` etc More seriously, the designers of Java went to great lengths to make Java international, and you … | |
Re: You didn't explain exactly what your problem is... Please explain *exactly* how you are testing your code, *exactly* what output you expect, and *exactly* how the acual output is different from what you expect. | |
Re: That doesn't look like the standard Java LinkedList. Is that a class you wrote/were given? If so, we'll need the code for that too. | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules | |
Re: You can market and sell programs that you write in Java without paying any fees to Oracle. | |
Re: `Main.setPage(2)` Main is the name of a class, so whatever follows Main. is in a "static context". setPage is an instance mtheod, not static, so it needs an intance when you call it. |
The End.