7,116 Posted Topics

Member Avatar for Hollyin

You rely on actionPerformed beuing called for tickettypeTxt and amountticketsTxt but do you add action listeners to those fields? And what if the user doesn't click them at the right time?

Member Avatar for JamesCherrill
0
266
Member Avatar for tricket_7

Arrays are fixed size, so all you can do is either replace the unwanted entry by some "empty" value (eg a null) or Create a new array one size smaller and copy all the elements except the deleted one into the new array. This is why people tend to use …

Member Avatar for JamesCherrill
0
397
Member Avatar for aslam.junaid786

You get a list iterator (line 16) then use that to iterate thru the list (lines 20/21). Then you go straight on to try to iterate some more (lines 27/28) *using the same iterator*. Butyou have already used that iterator so it has no entries left. You need to get …

Member Avatar for JamesCherrill
0
339
Member Avatar for loveparadise

All Java code is part of a class definition - you have forgotten/lost the `class` statement that should be around line 5. Similarly the code starting a t line 10 should be inside a method definion. Now look again at the error message that you got but decided not to …

Member Avatar for loveparadise
0
370
Member Avatar for Gebrish
Member Avatar for SummerSunshine

You can run (almost) any other program from Java via the ProcessBuilder class. Eg ProcessBuilder pb = new ProcessBuilder("notepad.exe", "sometestdata.txt"); try { pb.start(); } catch (IOException ex) { ex.printStackTrace(); } There are loads of other options - eg to send input via the programs stdin, and to capture its stdout …

Member Avatar for JamesCherrill
0
150
Member Avatar for Student22
Member Avatar for sk8ergirl

First problem is that you try to get(index) on line 2 *before* you validate that index on line 3. If the array size is 4 then valid indexes are 0-3. That's just a simple programming error. As for the second problem,I can't get past the first line - it's a …

Member Avatar for sk8ergirl
0
355
Member Avatar for SHARATH_1
Member Avatar for mKorbel
0
224
Member Avatar for Biff2013
Member Avatar for Benjamin_4

If you check the API doc for JTable you will find a choice of constructors that let you supply the data as a simple 2D array (see the doc for all the options) such as new JTable(Object[][] rowData, Object[] columnNames); It won't be hard to put your data into a …

Member Avatar for mKorbel
0
208
Member Avatar for JohnOSull4021

There's absolutely nothing in the design of this program that would make it "object oriented", other than those aspects mandated by Java itself. It's just a single instance of a single class - which could just as well have been all static members. This is taken to extreme - eg …

Member Avatar for JamesCherrill
0
163
Member Avatar for JohnOSull4021

Hi John Your question is far too general for anyone to answer properly - maybe you can explain more about what you already have and where you're getting stuck?

Member Avatar for JohnOSull4021
0
144
Member Avatar for ddnpresident

You have a 2d array (rows / positions). All its entries will initially be zero. When you place a musician you put their weight into the corresponding entry. So it's really easy to see if a position is empty (the entry is still zero) or occupied (the entry is a …

Member Avatar for kal_crazy
0
326
Member Avatar for SCass2010

Absolutely. You can create a `File` object that refers to the folder, then use its `listFiles` method to get an array of the Files in it (you can also supply a filter to select only .json files). Details, as always, in the File API doc. ps Java 7 has new …

Member Avatar for JamesCherrill
0
204
Member Avatar for sk8ergirl

Line 11. If you just removed the item at position pos, what are you getting here? Suppose pos was the last element, what will be in position pos after it is removed? Line 25. Create an array of the right size, loop through the list copying elements to the array.

Member Avatar for Seldar
0
152
Member Avatar for nirmeen.asad

Ideally you will do some design before diving into real code - maybe just a list of all the classes and public methods you will need to implement, maybe some pseudo-code to support that? There are people here who can also review that info before you write too much code, …

Member Avatar for nirmeen.asad
0
1K
Member Avatar for lobnaallam

if ( letter != 'i' || letter != 'o' ... There's a problem. If the letter is 'i' then letter != 'o' is true If the letter is 'o' then letter != 'i' is true If the letter is anything else then both are true. You OR them together, so …

Member Avatar for lobnaallam
0
1K
Member Avatar for nikolaos

Unless I missed something it looks like your init() methods creates the threads and makes them eligible for execution, but then on lines 12-16 you immediately print the contents of consumerData. At that point there is absolutely no guarantee that the other threads will have executed anything. Creating and starting …

Member Avatar for nikolaos
0
5K
Member Avatar for nirmeen.asad

Do you mean a JTable? You can't put a JTable or an image inside a JTextArea. You need to create some kind of container, eg JPanel, then put your text area, table, image etc iside that.

Member Avatar for nirmeen.asad
0
305
Member Avatar for Benjamin_4
Member Avatar for JamesCherrill
0
69
Member Avatar for ZombieKnight93

Expression is evaluated with / and * same priority, left to right, is as `((((4/3)*3.14)*r)*r)*r` The first part is `4/3`, which is two ints, so evaluated in int arithmetic, ie = 1 It doesn't switch to floating point until you get to the `*3.14` You can rearrange the formula so …

Member Avatar for JamesCherrill
0
133
Member Avatar for andrewriebel

Sound advice Seldar, but perhaps you could now explain for Andrew's benefit why he had that error and why that fixes it?

Member Avatar for andrewriebel
0
255
Member Avatar for loody
Re: help

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 doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence …

Member Avatar for loody
0
224
Member Avatar for sk8ergirl

In Java a class can diectly extend one superclass, and implement any number of interfaces. Java's "extend a superclass" is called "generalisation" in UML. The UML representation of a Generalization is a hollow triangle shape on the superclass end of a solid line or lines that connect it to one …

Member Avatar for sk8ergirl
0
163
Member Avatar for you207

One way is to have a boolean `matchFound = false` When you find match in the file you set that to true. Then at line 49 you can test the boolean to see if you need to add the user.

Member Avatar for you207
0
695
Member Avatar for srikanth2321

I would be surprised if its possible to update a jar that's in use. And if you could I'd be even more surprised if it didn't result in some kind of crash. Maybe, if you can explain what your end objective is, we can find another way to do it?

Member Avatar for JamesCherrill
0
173
Member Avatar for sk8ergirl

That usually means you are using an old version of the runtime with a class that was compiled for a later version. Simply download and install the latest Java Runtime (JRE) (execute only) or JDK (build/compile/debug/run - includes the JRE)

Member Avatar for JamesCherrill
0
450
Member Avatar for PaulDel

If you showed us the code and told us what the error messages were, then maybe we could help.

Member Avatar for PaulDel
0
151
Member Avatar for Twee Nguyen

ntthuy: Do not post the same question multiple times http://www.daniweb.com/community/rules Your question is so vague and general that nobody knows what kind of answer you need. Explain what you have done so far, and expolain exacrtly what help you need. Remeber also: *Do provide evidence of having done some work …

Member Avatar for Twee Nguyen
0
209
Member Avatar for anestistsoukalis

`49: return (this == other);` tests for them being exactly the same object. I guess you want to return true of they are different objects that happen to have all the same values? You can override `equals(...)` - that's how classes like String work. But you can't mix `equals` and …

Member Avatar for JamesCherrill
0
211
Member Avatar for Start4me

You can convert an int to String with the `String.valueOf(int i)` method, but you will often see people using string concatenation because Java will find a way to convert any non-string values to string in order to perform the concatenation. That's the method Seldar hid carefully in his undocumented code …

Member Avatar for Seldar
0
1K
Member Avatar for aVar++

Check out the % (remainder) operator - gives you the remainder after dividing, eg 27/6 = 4 27%6 = 3 ie 27 is 6*4 + 3 or secs = 140; secs/60 = 2 (minutes) secs%60 = 20 (seconds)

Member Avatar for aVar++
0
164
Member Avatar for manel1989

You can read whole lines one at a time from the console into a String, then use the String `split` method to split the line into an array of strings, each containing one value from the input string (the blanks are used to split the string, then discarded). You can …

Member Avatar for JamesCherrill
0
303
Member Avatar for skyyadav

The Arrays class has methods for sorting arrays. If you don't want to mess up your data you'll need to create a copy of the array, sort that, then convert it to a String

Member Avatar for JamesCherrill
0
92
Member Avatar for hamza.khan.5473894

Nobody here is going to give you the code for your exams, and shame on you for asking. Now, do you have a specific question about Java that we can help you with?

Member Avatar for Nguyễn Đình Đại
-1
182
Member Avatar for Denmbithi

Normally I agree with mKorbel, but in this particular case (one-time logon screen -> the rest of the application) I don't. I'd use a dialog for the logon, then dispose() it and hand over the application's main window.

Member Avatar for Seldar
0
242
Member Avatar for XTMercenary

YOu may find some useful ideas [here](http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners). If you haven't worked with databases in Java then this would be a very good skill to acquire. Java has loads of built-in support for SQL databases, and the JDK comes with a decent SQL database as standard (JavaDB). MS Access is a …

Member Avatar for JamesCherrill
0
146
Member Avatar for Pyler

Normally I would say " go ahead and test it, you'll soons ee if it's ok". But in this case you have a couple of catastrphic mistakes that will prevent any useful testing. You have 2 methods that look something like int doIt() { return doIt(); } These will call …

Member Avatar for JamesCherrill
0
229
Member Avatar for chdboy

Looks to me like that value is a valid integer, but its not a valid `int` because it's too big, >= 2^32. You could use a `long` instead of an `int`.

Member Avatar for chdboy
0
2K
Member Avatar for Om Prakash_1

It's platform-independent unless you deliberately include something that depends ona particular platform (eg accessing the Windows registry). Java is not quite "pure" OO, it has primitive variables (int, boolean etc) which are not objects.

Member Avatar for rubberman
0
210
Member Avatar for cakka

When you execute any program (eg from a batch file or script) the program returns an integer return code; by convention this is 0 for successful execution. The batch file or script can then test that value to select an appropriate next thing to do. System.exit(n) just makes the JRE …

Member Avatar for ~s.o.s~
0
168
Member Avatar for Pyler

> In the method above (plus(T something)) I get an error on push. Eclipse tells me to create a new method called push. That's clear enough. What's your question? > I want a new stack to be created whenever someone creates a stack list object Isn't that what line 9 …

Member Avatar for JamesCherrill
0
407
Member Avatar for andre.hamraee.75

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here. There are lots of people here who will freely give their time to help you become the best Java …

Member Avatar for JamesCherrill
0
361
Member Avatar for Lavanda

JOptionPane (which you have already used) also has a `showInputDialog` method that does exactly what you asked for.

Member Avatar for JamesCherrill
0
332
Member Avatar for COKEDUDE

Stack overflows are almost always caused by too many recursive calls. In this case your Node constructor includes a `new Node(work, grr)` which calls the constructor, which includes a `new Node(work, grr)` which calls the constructor, which includes a `new Node(work, grr)` which calls the constructor, which includes a `new …

Member Avatar for JamesCherrill
0
427
Member Avatar for Violet_82

You can look at its addXxxListener methods to see which events it will give callbacks for. Don't forget to check all the superclasses as well. eg JTextField has *addActionListener* then scroll down a screen or two to find *addCaretListener, addInputMethodListener* inherited from JTextComponent then *addAncestorListener, addVetoableChangeListener* from JComponent then *addContainerListener, …

Member Avatar for JamesCherrill
0
150
Member Avatar for nikolaos

The main advantage of Semaphore is that you can limit access to n threads, not just one thread, at a time. Personally I would use synchronised to limit to one thread at atime, mainly because its simpler and more obvious code.

Member Avatar for nikolaos
0
389
Member Avatar for sehrish_1

How big? How complex? Java SE only or Java EE? Database? etc... If you want suggestions you must provide a lot more info.

Member Avatar for JamesCherrill
0
122
Member Avatar for Zdneth_1

Can you please be more precise about the help you need? Eg Do you need to know how to get the data froma JTable? Do you need to know know how to execute an SQL insert statement? Etc?

Member Avatar for JamesCherrill
0
1K

The End.