7,116 Posted Topics

Member Avatar for SakuraAssassin

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 …

Member Avatar for stultuske
0
231
Member Avatar for arionyx

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.

Member Avatar for JamesCherrill
0
2K
Member Avatar for Ashenvale

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 …

Member Avatar for Ashenvale
0
118
Member Avatar for Valiantangel

Yes, that makes complete sense to me (except line 5 where the math looks suspect).

Member Avatar for stultuske
0
130
Member Avatar for soham.m17

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?

Member Avatar for stultuske
0
287
Member Avatar for broodwich

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 …

Member Avatar for broodwich
0
275
Member Avatar for theCompiler

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

Member Avatar for JamesCherrill
0
219
Member Avatar for coroll

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?

Member Avatar for coroll
0
373
Member Avatar for sofien.fkih
Re: try

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.

Member Avatar for JamesCherrill
0
82
Member Avatar for sofien.fkih

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 …

Member Avatar for JamesCherrill
0
353
Member Avatar for sofien.fkih

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

Member Avatar for JamesCherrill
0
397
Member Avatar for dppd

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.

Member Avatar for JamesCherrill
0
128
Member Avatar for shivcena24

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]

Member Avatar for Majestics
0
162
Member Avatar for daudiam
Member Avatar for odubanjo.ismail
0
184
Member Avatar for SakuraAssassin

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";`

Member Avatar for SakuraAssassin
0
127
Member Avatar for coroll

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 …

Member Avatar for JamesCherrill
0
124
Member Avatar for pradeepptp

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 …

Member Avatar for JamesCherrill
0
330
Member Avatar for BinodSuman
Member Avatar for london-G

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.

Member Avatar for london-G
0
109
Member Avatar for ubi_ct83

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

Member Avatar for JamesCherrill
0
177
Member Avatar for Florinmoc

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 …

Member Avatar for florin.mocanu.501
0
221
Member Avatar for ganges

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 …

Member Avatar for JamesCherrill
0
73
Member Avatar for DWIZARD1

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 …

Member Avatar for JamesCherrill
0
154
Member Avatar for XodoX

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 …

Member Avatar for JamesCherrill
0
111
Member Avatar for GlenRogers

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

Member Avatar for GlenRogers
0
117
Member Avatar for rajilakshmi

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

Member Avatar for JamesCherrill
0
2K
Member Avatar for GlenRogers

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

Member Avatar for GlenRogers
0
2K
Member Avatar for gacusana.aljan

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

Member Avatar for stultuske
0
107
Member Avatar for jdseader

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

Member Avatar for JamesCherrill
0
4K
Member Avatar for soapyillusion

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.

Member Avatar for soapyillusion
0
110
Member Avatar for Tajinderpal

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

Member Avatar for JamesCherrill
0
4K
Member Avatar for jab8288

Use a DocumentListener to edit any input to the text field - see the "UpperCaseField" example at the start of the API doc for JTextField.

Member Avatar for JamesCherrill
0
193
Member Avatar for atunio
Member Avatar for amid88

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

Member Avatar for JamesCherrill
0
912
Member Avatar for london-G

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.

Member Avatar for london-G
0
260
Member Avatar for Jack5848

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 …

Member Avatar for JamesCherrill
0
164
Member Avatar for scarletfire

`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])`

Member Avatar for JamesCherrill
0
426
Member Avatar for Viped

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.

Member Avatar for Viped
0
161
Member Avatar for bobytch

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 …

Member Avatar for bobytch
0
430
Member Avatar for lj81

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.

Member Avatar for Philippe.Lahaie
0
418
Member Avatar for wallet123

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.

Member Avatar for JamesCherrill
0
249
Member Avatar for harishjoy

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?

Member Avatar for JamesCherrill
0
337
Member Avatar for Na'Vi

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

Member Avatar for JamesCherrill
0
125
Member Avatar for DEAD TERMINATOR

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 …

Member Avatar for JamesCherrill
0
620
Member Avatar for annette_arpana3

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

Member Avatar for JamesCherrill
0
241
Member Avatar for hkboateng

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.

Member Avatar for hkboateng
0
581
Member Avatar for messynaddy

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.

Member Avatar for messynaddy
0
286
Member Avatar for karoke

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

Member Avatar for JamesCherrill
0
5K
Member Avatar for mrgadgets

You can market and sell programs that you write in Java without paying any fees to Oracle.

Member Avatar for stultuske
0
246
Member Avatar for Viped

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

Member Avatar for JamesCherrill
0
168

The End.