7,116 Posted Topics

Member Avatar for SoulofchaOs

Because x is an array you need to supply an index to tell Java which element of the array you are talking about, eg x[b].getName()

Member Avatar for mKorbel
0
251
Member Avatar for somaye.s

DaniWeb Member Rules (which you agreed to when you signed up) 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 radhakrishna.p
0
112
Member Avatar for LegendX

> its giving some weird error Java error mesages may look weird but they usually tell exactly what the problem is and exactly where it's happening. Please post the complete exact text of your errors and someone will help.

Member Avatar for stultuske
0
109
Member Avatar for rose_anne

To make it more like a c header file full of `define`s, you can declare `pubic static final` members, as bguild explained, then at then start of any .java file you can `import static mypackage.MyClass.*;` Now you can simply use the public static member names in that file without needing …

Member Avatar for rose_anne
0
232
Member Avatar for kamil555

Generate two random numbers 1-6, add them together, test the result for ==7 or whatever else you need.

Member Avatar for JamesCherrill
0
533
Member Avatar for dannyboy.rizaldo

That is part of a loop that will reverse the digits in a number. It makes no sense without the loop. To see how it works, pick a number and go through that code by hand working out the results for each line.

Member Avatar for JamesCherrill
0
28
Member Avatar for 03hasnam

The view knows nothing about SQL, and so has no idea what to do with an SQL exception. On the other hand, the model knows nothing about how to talkto the user. So normally you would do something like: 1. In the model, catch the exception and write as much …

Member Avatar for JamesCherrill
0
291
Member Avatar for farah90

This is the Java forum, but that's not Java. Try one of the web development or database forums.

Member Avatar for JamesCherrill
-1
121
Member Avatar for Jimbo_Dew

You need a .class file or .jar file to run javaw, a .txt won't run. But in prinicple there's no problem running javaw from within Java. ps Runtime.exec was superceeded by the ProcessBuilder class from Java 1.5 You'll find loads of examples on the web.

Member Avatar for JamesCherrill
0
247
Member Avatar for Violet_82

You can usually hold money as an integer number of cents - very few applications ever neen to handle a fraction of cent. `int` will usually do, or `long` if you need amounts over 20 million dollars. If you write a simple method to take a value in cents and …

Member Avatar for Violet_82
0
316
Member Avatar for Yidnekachew.

Your request is very general, and sounds like it will need more time that anyone here has got. Strt by reading the [starting Java thread](http://www.daniweb.com/software-development/java/threads/99132/starting-java-java-tutorials-resources-faq), the have alook through the [Java projects for learners thread](http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners). Pick a project that interests you and try to design/code/test a solution. If/when you get …

Member Avatar for JamesCherrill
0
254
Member Avatar for boiishuvo
Member Avatar for JamesCherrill
0
189
Member Avatar for 03hasnam

That code is very difficult to understand, especially because you have ignored Java naming conventions and made your classes look like variables. And essential parts are missing. From what you have posted: There's a main method that isn't valid Java, but appears to try to define a run() method that …

Member Avatar for JamesCherrill
0
138
Member Avatar for prashant1111

Rajesh's post is about as wrong as it's possible to be. ActionListeners are called on the Swing Event Dispatch Thread. Most Swing methods are not thread safe and MUST be called from the EDT and no other thread. http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html Rajesh would have you leave the EDT in order to update …

Member Avatar for JamesCherrill
0
318
Member Avatar for lailadah

lailadah got "unable to access jarfile start.jar" when trying to instal Apache Solr server, but after many more tries got "invalid or corrupt jarfile C:[complete path to the file]". He's been unable to find any relevent answers on the web [or maybe lack of English skills prevented him from seeing …

Member Avatar for lailadah
0
880
Member Avatar for LegendX

Why don't you just try that and see for yourself? (It's nearly right, and when you try it you will see what's wrong and how to fix it)

Member Avatar for JamesCherrill
0
193
Member Avatar for Blink383

First step is simply to do exactly what it told you to do: `Recompile with -Xlint:unchecked for details.` That will tell you what the unsafe or uchecked problem is, and exactly where it is. Then you can either update the code or add an annotation to allow the operation.

Member Avatar for Blink383
0
287
Member Avatar for Hameeda0410

Why don't you ask the person who wrote that code? (See also [OP's original incomplete thread ](http://www.daniweb.com/software-development/java/threads/444967/road-simulator) )

Member Avatar for JamesCherrill
0
928
Member Avatar for neondroid

Hello neondroid You have not explained exactly what help you need. Nobody is going to read all that incorrectly-formatted code, then try to guess what your questions are! so please 1. Explain exactly in detail what you need to know. If you have an error then explain exactly what the …

Member Avatar for stultuske
0
273
Member Avatar for JamesCherrill

Just a quick heads-up, especially for anyone using Java in their web browser. There's a "widely exploited" vulnerability in Java that could allow bypassing normal security when a Java applet is run silently upon visiting a web site. (ie It's a bad one). Users are being widely advised to disable …

Member Avatar for harinath_2007
3
177
Member Avatar for Hameeda0410

Yes, lots of ideas, but your requirement is still far to vague for anyone to give a proper reply. What kind of simulation do you need for the cars? In how much detail (see previous posts)? (In 1971/2 I worked on an IBM project to simulate the traffic flow in …

Member Avatar for Hameeda0410
0
2K
Member Avatar for csk19

Part1: see bguild's answer. Part2: If you start by finding palindromes then you are left with the problem of finding out if each palindrome is the product of of two numbers 100-999 (not so easy). If you start by multiplying every possible combination of two numbers 100-999. that's only 500,000 …

Member Avatar for Taywin
0
608
Member Avatar for pro_learner

if(names.equals(n)) names is an Enumeration n is args[0] which is a String. An Enumeration and a String can never be equal. ps: Hashtable is designed for this kind of thing, so it has other methods that you will find very useful... spend 10 minutes reviewing all its methods before choosing …

Member Avatar for dreamslct
0
226
Member Avatar for dreamslct

Many places where Java displays text support a limited subset of HTML tags (eg JLabel). You could try some simple HTML and see if that works, eg "<HTML><H1>Hello</H1><BR>Everyone"

Member Avatar for JamesCherrill
0
363
Member Avatar for techxaidz

The person who wrote this problem description obviously doesn't understand object oriented design, so that makes it harder for you. Judging from the variables, the class they call Library clearly does not represent a library, it represents one LibraryHolding - which is an abstract class (instance variables ID, Date of …

Member Avatar for stultuske
0
529
Member Avatar for goutham.patnam

Member rules link is at bottom right corner of (every?) screen. I think the one you are looking for is "Do provide evidence of having done some work yourself if posting questions from school or work assignments" J

Member Avatar for Taywin
0
153
Member Avatar for raj09cs42

@raj09cs42 Taywin is being too nice to you! Posts that start "I need the code so I don't have to do my own homework..." usually get a much stronger response. There are lots of people here who will freely give their time to help you become the best Java programmer …

Member Avatar for JamesCherrill
0
126
Member Avatar for renmarkcerdan

DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there.

Member Avatar for azareth
-2
201
Member Avatar for amrita111

This is a typical problem with Scanner. Most of the methods use the delimiter (default white space) to separate tokens, and keep the following delimiter. Except for readLine that discards the following new line character(s). So, for example if you use a nextInt followed by a nextLine with a file …

Member Avatar for JamesCherrill
0
133
Member Avatar for Ilda

Have you read the Oracle tutorial on JTables? http://docs.oracle.com/javase/tutorial/uiswing/components/table.html

Member Avatar for Ilda
0
849
Member Avatar for harinath_2007

How about ProcessBuilder to execute the necessary commands directly from your Java program?

Member Avatar for herby_tech
0
128
Member Avatar for jessada.dissopa

If the command line interface has all the needed functionality, then you can use the Java *ProcessBuilder* class to drive octave's command line interface "behind the scenes" and retrieve all its output for display in your GUI. You'll find tutorials and samples on the web. ps: don't be distracted by …

Member Avatar for stultuske
1
248
Member Avatar for amaicahglyne.decastro

It sounds like you don't have much programming experience? If that's the case then to make a real-life application like this from scratch is far too difficult a project for a beginner. Why not look at one of the free inveytpory applications that you can simply download and start using? …

Member Avatar for JamesCherrill
0
96
Member Avatar for cor.vandijk.779

Remember that columns may be re-ordered relative to the underlying data model. Similarly rows can be sorted and/or filtered before display, in which case to get a row number that refers to the actual row in the data model you need the *convertRowIndexToModel* method. Those extra levels of indirection and …

Member Avatar for mKorbel
0
610
Member Avatar for JamesCherrill

Hello all. I'm currrently working on a GUI that needs to support dragging some application-specific objects from a selection area onto a work area (JPanel). It's currently working in a "click where to place the object, then click the Add button" mode, but that's not good enough. The obvious approach …

Member Avatar for JamesCherrill
2
1K
Member Avatar for mumaga

There are solutions using PipedOutputStream/PipedInputStream. Basically you re-direct System.out and System.err to a piped stream, then in a separate thread read from the pipe and put the text into your JTextArea. Google will find you a few examples; most have extra stuff you may not need (eg handing System.in as …

Member Avatar for mumaga
0
192
Member Avatar for mumaga

Your question is far too vague. setVisible(true) is the way to make an invisible component visible, but what has that got to do with singletons? If you ask a much more specific question, with enough background for us to understand what yur problem really is, then I'm sure someone will …

Member Avatar for mumaga
0
124
Member Avatar for dannyboy.rizaldo

Learn most of the language itself? months Learn a good subset of the Java SE API? a couple of years Learn to design & implement really good code? many years

Member Avatar for tux4life
0
138
Member Avatar for nigelturk

> You can use Bitwise unary NOT operator Check the Java Language Spec... there no such thing as a "Bitwise unary NOT operator". There is bitwise complement operator, just like the previous poster already said. ps You can also exclusive OR with a value of all 1 bits.

Member Avatar for Taywin
0
4K
Member Avatar for Violet_82

There is an overlap in function between constructors and setters, and no rigid rules about which to use. But some typical guidlines include: * If a variable must be set for an instance to be valid (eg Person must have a name and social security number) then set them in …

Member Avatar for Violet_82
0
235
Member Avatar for CoilFyzx

Serialization is a good answer. Open an ObjectOutputStream to a file with any name and extension you want. Java IO won't care about the extension.

Member Avatar for JamesCherrill
1
375
Member Avatar for Armanious

I think we are being too hard on OP here. He clearly has put a lot of thought into this problem, ans is now asking for more ideas. I would be more worried about whether this is intended to circumvent someone's attempt at DRM, and therefore violates DaniWeb rules.

Member Avatar for Armanious
0
216
Member Avatar for Pobunjenik

Line 54 you include the current cell in your counts, and also the cells diagonally above/left of the current cell. You don't seem to test the cells right/below the current one ps `if (someBoolean == true)` is a redundant way to say `if (someBoolean)`

Member Avatar for Pobunjenik
0
343
Member Avatar for jeffbeck8

^ excellent advice from Tux. Plus: sort out your indentation - it's very hard to see where blocks begin and end and, even worse, its too easy to think that the indentation accurately reflects the block structure of the code when in reality it doesn't. Finally, use lots of temporary …

Member Avatar for jeffbeck8
0
196
Member Avatar for harinath_2007

Is [this](http://stackoverflow.com/questions/4573812/how-to-convert-apk-files-to-java/5027405#5027405) any use to you?

Member Avatar for harinath_2007
0
123
Member Avatar for Pobunjenik

You're mixing nextInt and nextLine, which is a bad combination. nextInt takes the integer value but leaves the end-of-line delimiter (\n). Then nextLine takes everything up to the end of line, is a string of zero length. You need to take or skip the end of line after a nextInt …

Member Avatar for JamesCherrill
0
433
Member Avatar for Violet_82

`Player player;` creates a reference variable that can refer to a Player object, and is initially null. `new Player(p1, p2); ` creates a Player object the two things are independent of each other. `player = new Player(p1, p2);` creates a Player object and sets player to refer to it, then... …

Member Avatar for Violet_82
0
191
Member Avatar for IcyFire

Re implementing bguild's excellent suggestion: Simply create a little class Line, with vars for oldX, oldY etc. Give it a constructor that takes all the values it needs. Declare it as "implements Serializable" so it can be sent over an object stream. "history" can then be an ArrayList of LineData, …

Member Avatar for IcyFire
0
305
Member Avatar for 03hasnam

The NullPointerException nessage tells you the exact line where it happened. It's a lot easier if you share that with us! You can also help by printing the values of all the variables and method calls used on that exact line so we all know which one was null.

Member Avatar for 03hasnam
0
509
Member Avatar for Osaid9

Use the SimpleDateFormat class to convert your Date object into a String that's formatted exactly how you want to see it, and use that String in the text field.

Member Avatar for JamesCherrill
0
171

The End.