7,116 Posted Topics

Member Avatar for aelajj

Without creating new array the best you can do is to compress out the zeros, then fill the unused elements at the end of the array with zeros. Ie 9 7 23 4 0 0 0 0 There is no way to change the size of a Java array after …

Member Avatar for JamesCherrill
0
1K
Member Avatar for jackbauer24

[QUOTE]another way to specify the current L&F is to use the swing.properties file to set the swing.defaultlaf property. This file, which you may need to create, is located in the lib directory of Sun's Java release (other vendors of Java may use a different location). For example, if you're using …

Member Avatar for durim.kryeziu.927
0
1K
Member Avatar for JohnSoftware

mKorbel - I presume your comment to stultuske is based on the fact that JTextArea handles \n chars properly? It's not helpful or polite just to say someone is wrong - please always explain why they are wrong, and at least point them in the direction of a right answer.

Member Avatar for mKorbel
0
749
Member Avatar for chdboy

You don't give a lot of context for this question, but it looks like you should be using a switch based on the selected index, and in that calling separate methods for each of the possible cases.

Member Avatar for JamesCherrill
0
289
Member Avatar for ZombieKnight93

Drawing shapes in Java has to be done in a very specific way - here's a tutorial that will show you exactly what to do: http://docs.oracle.com/javase/tutorial/uiswing/painting/ You can handle the coordinates in exactly the same way you did the radius.

Member Avatar for JamesCherrill
0
1K
Member Avatar for manel1989

The exception message identifies the exact line where the NPE happened, but we don't have the original file to interpret the line number. What is the code on line 978?

Member Avatar for JamesCherrill
0
394
Member Avatar for Violet_82

There is somewhere on Oracles site a table that shows which components generate which events, but I can't remember where exactly. Otherwise, look at the addXXXListener methods for your component (don't forget to look for inherited methods as well)

Member Avatar for Violet_82
0
162
Member Avatar for sterno68

double tuitiontotal = tuition; Why this initial value? Don't you add all the desired values into tuitiontotal in the following loops?

Member Avatar for JamesCherrill
0
562
Member Avatar for 117

Without seeing your code it's impossible to say what's wrong with it!

Member Avatar for JamesCherrill
0
284
Member Avatar for asif49

It's not the enums, they're just like any other object for this purpose. Java has primitives and references. Primitives are int, boolean, char, float etc - all have lower case names. References are used to refer to objects and arrays. When you call a method Java passes a copy of …

Member Avatar for JamesCherrill
0
152
Member Avatar for anestistsoukalis

The key to creating frames in specified formats is to chose the right layout manager. This tutorial is a good start. http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

Member Avatar for JamesCherrill
0
268
Member Avatar for Hanyouslayer

It's in this thread if you look for it. But you would be far better advised to write your own rather than copy something that can be traced on the internet

Member Avatar for JamesCherrill
0
1K
Member Avatar for Layki

Hi Please don't hijack other people's threads. Start you own new thread and someone will help

Member Avatar for JamesCherrill
0
344
Member Avatar for ghfeyn

Hi Kenton. Welcome to Daniweb. Start a new thread for your question and someone will help.

Member Avatar for JamesCherrill
0
6K
Member Avatar for ObSys

Yes, as soon as it hits the return statemnent it returns, so you only ever get the first Card. Your requirenent seems bizarre - you want to return multiple Cards, but not use an array or Collection? Given that, all I can think of is to return an Iterator or …

Member Avatar for ObSys
0
170
Member Avatar for kyriacos1986

You try to add two mm.ss as if they were ordinary decimal numbers. Eg 1.40 + 1.40 is 3.20, but added as decimals you get 2.80 which is wrong. Easiest solution is probably to covert the inputs to number of seconds, add those, then convert back to mins & secs

Member Avatar for kyriacos1986
0
135
Member Avatar for Neon Tetras

> Its strictly for beginners, and can be improved. You are being too modest. I would be perfectly happy to have written that myself. Well done.

Member Avatar for stultuske
3
5K
Member Avatar for hbhatti18

would like your help on writing this program. There are meny people here who will help you, nobody who will do it for you. Show what you have done so far.

Member Avatar for arronlee
0
635
Member Avatar for murali2489

The `classpath` should contain a list of all the locations where your .class files may be found. That is completely different from the `path` environment variable that tells the systen where to look for .exe files. If it works with `cp .` then this imples that the .class file is …

Member Avatar for murali2489
0
2K
Member Avatar for 2butawil

To sum a diagonal you just need one loop and one counter. You don't want nested loops

Member Avatar for JamesCherrill
0
125
Member Avatar for Kalamari

Hi, welcome to DaniWeb. Lower case letters are 26 consecutive Unicode values starting with 'a', so the cleanest way to generate a random lower case letter is to get a random integer in the range 0-25 and add it to 'a', as in 'a' + randNumlist.nextInt(26) But, that calculation will …

Member Avatar for JamesCherrill
0
105
Member Avatar for rovastola

You are 99% of the way there. It's really hard as a beginner to think about the logic and the Java code at the same time! Step back from the computer and just run through that on a sheet of paper. You'll soon see why its going wrong, and how …

Member Avatar for rovastola
0
117
Member Avatar for mufasil

> can you please make a program for me?? 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.

Member Avatar for mKorbel
0
3K
Member Avatar for dargokillmar

"giving me some errors" tells us nothing. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be.

Member Avatar for JamesCherrill
0
726
Member Avatar for kyle.mace.35

A word of caution - not all console devices and/or OS's support ANSI escape sequences, so if this works for you that's great, but don't assume it's portable or will work on someone else's computer. In general your chances are much better under Linux than under Windows.

Member Avatar for JamesCherrill
0
169
Member Avatar for skyyadav

"it is not giving correct result" tells us nothing. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be.

Member Avatar for noorullah06
0
217
Member Avatar for Dio1080

DaniWeb Member Rules (which you agreed to when you signed up) 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
544
Member Avatar for JBProgrammer

If you need variables to be shared between different methods, then declare them in the class but outside any one method. Variables declared at the class level can be used in any method

Member Avatar for JamesCherrill
0
1K
Member Avatar for smdjilani

Install the Java Runtime (JRE) on your linux computer https://java.com/en/download/manual.jsp

Member Avatar for jalpesh_007
0
97
Member Avatar for ferizhandi

Interesting bug... in paintComponent you call super.paint, which in turn calls the paint mathods for the various parts of the JFrame, including a call to paintComponent. That's a recursive loop. You should be calling super.paintComponent

Member Avatar for JamesCherrill
0
224
Member Avatar for Start4me

Calendar's `getTime()` method gives youa `Date` object representring the same date/time, which you can then format exactly as you like with a `SimpleDateFormat` - see the API docs for details You can put Calendars in an array or an ArrayList (or any other Collection) to process multiple Calendars

Member Avatar for JamesCherrill
0
341
Member Avatar for techxaidz

Lost ticket? Car parked but never leaves? Car parked during some kind of emergeny or system failure when the entry barrier was left open? Car exiting but credit card refused/no cash/etc so unable to complete payment but is now blocked in by a line pf cars stck behind it? (I've …

Member Avatar for JamesCherrill
0
186
Member Avatar for Gl753
Member Avatar for murali2489

[This](http://simplescrape.sourceforge.net/) sourceforge project may help, or [this blog](http://icfun.blogspot.fr/2008/03/write-web-spider-to-scrape-data-using.html) has a simple DIY example. ps: Just because info is on a web page that does not mean that you are free to use it any way you like. Please check that your use does not violate anyone's intellectual property rights.

Member Avatar for murali2489
0
253
Member Avatar for ObSys

Are you sure you want to use an accessor, or do you just need to know the number associated with whatever button has just been pressed? In that case you can use an event handler. Here's a recent post that shows how (it stores the number in an array, but …

Member Avatar for JamesCherrill
0
467
Member Avatar for littledevils326

With absolutly zero info about the algorithm, and absolutly zero code to look at, I doubt that anyone can explain your results. Can you explain your algorithm, and post all the relevant code?

Member Avatar for ObSys
0
244
Member Avatar for asif49

Everything to do with Swing (eg painting the screen, running actionPerformed methods) happens on a single thread - the "Event Dispatch Thread", or "EDT", or "Swing thread". That means that once your mouse click method starts NOTHING else will happen in Swing, including no screen updates, until your method finishes. …

Member Avatar for asif49
0
125
Member Avatar for santoshedunum
Member Avatar for JamesCherrill
0
105
Member Avatar for Student22

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
150
Member Avatar for KhubaibQaiser

Rather than have one big buffer - which limits the file size, you can have smaller buffers (eg 4k) and write/read the file one buffer at a time for unlimited file sizes. Eg for the server... byte[] data = new byte[4096]; int count; while ((count = file.read(data)) != -1) { …

Member Avatar for JamesCherrill
0
308
Member Avatar for lf95

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 JamesCherrill
0
354
Member Avatar for Benjamin_4

The compiler isn't smart enough to confirm that your for loop will always be executed, so the return inside it will always be executed. If the values were such that the for loop ran zero times you would drop through to line 9 and get to the end of the …

Member Avatar for JamesCherrill
0
133
Member Avatar for peter.son.10297

The next 10 years? No. 10 years ago who predicted iOS or Android? But many large companies have huge investments in Java (especially Java/EE) and those systems will be around and being updated for a long time. In the long term there's a massive trend away from low-level low-productivity languages …

Member Avatar for JamesCherrill
0
170
Member Avatar for ZombieKnight93

Hi ZK It's hard to answer your post because we don't understand what your real problem is. Both tasks are really small and simple - maybe you are looking for some complexity or difficulty that's not actually there? Eg. look at 2 again: "Define class SomeClass, which throws an Exception …

Member Avatar for JamesCherrill
0
185
Member Avatar for lilazn

http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners

Member Avatar for JamesCherrill
0
46
Member Avatar for johnmecanse34

Java is a language and .net is an API (library of code). To compare like with like you should compare (Java plus its API) against (c# plus .net). Java, like C#, is a language. and the Java API, like .net, is a huge library of code for user interface, networking, …

Member Avatar for JamesCherrill
0
94
Member Avatar for iTechnnn

Based on what you have posted before, the first version (delete one element) is not yet working - it doesn't check the index and it doesn't maintain the currentIndex variable correctly. Maybe you should be certain that is fixed before moving on? Anyway, I don't want to be discouraging, but …

Member Avatar for iTechnnn
0
271
Member Avatar for jonas.jude

In my opinion that would be hard to impossible in a Java application - it would need to interact with the system at quite a low level and be immune from the user stopping it. There may well be other ways to do it, eg via Group Policies in Windows …

Member Avatar for JamesCherrill
0
129
Member Avatar for iTechnnn

update current object - depends on whether it was one of the objects you moved in that loop you can't "compress" an array. If your array has unused space at the end you can copy it to a new smaller array and let the old array get garbage collected

Member Avatar for JamesCherrill
0
171
Member Avatar for infiniteloop56

Masybe you could use a boolean array or list, same size as the secret word, that shows which letters have been found. As the user guesses a letter correctly you set the corresponding entry to true. You can then use that array to control the printing of the secret word …

Member Avatar for JamesCherrill
0
388

The End.