7,116 Posted Topics
Re: Maybe the code isn't of the highest professional standard, but honestly it's not particularly messy either. Good enough for an early-stage learner. So what EXACTLY do you need help with? | |
Re: The AIC approach gives you a separate handler for each event, which is typically what you want. You use a "normal" inner class when you want to pass parameters into the handler when setting it up - that's something you do when you create dynamiclally changing layouts for example. Using … | |
Re: You are having problems because you are using an OO language as if it was purely procedural. The big clues are all those static members and classes whose names are verbs not nouns. If you make a ClientRequest class to encapsulate a client request, and RequestGUI class to encapsulate an … | |
Re: What do you mean "cannot use"? What exactly is your question? | |
Re: Yes, you can put components directly into a JFrame (well, actually there are some panels that are part of every JFrame, and one of those is where your components are placed, but that's hidden from you so you don't need to worry about it unless you have some special requirement. … | |
Re: It would help if you gave some better info than "it wont let me". 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 … | |
Re: Create a Memento before each time you add or remove. Use the latest Memento to roll back the latest change. The WikiPedia article on memento design pattern has an example in Java. | |
Re: When you have the month number as a String you can convert that to an Integer using the `Integer.parseInt `method (see API doc for details). Then you can use that Integer as an index to get the correct element from you month name array. There is a `SimpleDateFormat` class that … | |
Re: Why? Canvas is an old AWT component that you would use in an old AWT Frame. Forget it, and use a JPanel. | |
Re: Before going any further I urge you to look at David W's post again ... creating a full deck, shuffling it, and taking cards from it. His approach is going to work for dealing one hand, n hands, discard piles, hidden and face-up hands... Any card game, and scales trivially … | |
Re: That's a good question. All the definitions of mediant that I found in a quick google had no use or meaning for such a parameter. Are you sure that method signature is right? Is there any supporting documentation? | |
Re: I'm not c++ buff, but it looks to me like you have set the precision for printing numbers, but that has no effect on the numbers themselves. fx could still be 0.000001, you are just printing it to 4 decimal places | |
Re: 1: You get an exception (null pointer, zero divide etc) or the program behaves in a way didnlt expect (wrong output etc) 2: Trace the execution one step at a time, using a debugger or lots of print statements until you find where its going wrong 3: Design top-down - … | |
Re: Tag this with `Java` so it shows up in the best place to get an answer. That looks like a decent piece of code - what do you want it yo do that it doesn't do now? | |
Re: Make the superclass default constructor private and provide a public constructor that takes a parameter ? | |
Re: Every class in Java has a toString method. It's defined in the Object class so everyone inherits it if they don't override it. It returns the name of the class followed by the instance's hash (that's the garbage you referred to). You are right, print always calls the toString method … | |
Re: Looking at the print method, where the error is generated, I see 2*i+1 etc in a loop where I goes up to the list size, so the out of bounds is inevitable | |
Re: I looked at your code on GitHub. Seems pretty complete. Nothing nasty sprang to my notice. What exactly is your question? | |
Re: That's not exactly what I would think of as MVC either. But it does look like good architecture, regardless of what you call it. | |
Re: How about replacing all those difficult characters with blanks befor splitting the sentence? | |
Re: This appears to be a continuation of Katie's previous thread that was missing the `Java` tag https://www.daniweb.com/programming/computer-science/threads/500517/crossing-english-words-in-java the new `crossesAt` method just duplicates the single line at 19 for some reason the new `printCross` method seems inspired by a suggestion I posted while ignoring the content of my suggestion | |
Re: Are you saying that you want the database retrieval to be three records at a time, rather than getting them all them you processing them 3 at a a time? Why? Do you have shares in a server hardware company? | |
Re: You probably want to print the average, and amy other results you calculate. You can put all that inside a `while` loop so it will keep repeating the input and calculations until thr user types false. | |
Re: Please post the compiler error messages (including the line numbers). There's no way you have reached a limit on the number of nested if's etc, so it's not that. | |
Re: Just use ` setEnabled(true); ` or `setEnabled(false);` for your buttons in the appropriate listeners | |
Re: new ImageIcon(...) is famous for not throwing any exceptions when it fails to find the file; it just returns null. JLabel is happy to accept null for its image icon, so the final result is no image and no error messages. We see that quite often in DaniWeb "help!" posts. … | |
Re: If you get that information from the user then you have to store that in a configuration file (or equivalent) somewhere so you can find it next time the program is run. So your startup code can look something like: p s v main(etc) { get config file if file … | |
Re: I noticed lines 487/488 yourMoney=Integer.parseInt(jTextField1.getText()); yourMoney=hold; // overwrites the value you just set in the previous line | |
Re: The common factor on those two lines is the `contacts` variable You declare it on line 23, but you never initailse it, so it's null. And before you refer me to line 153... that creates and initialises a second variable, also called contacts, that is local to the main method, … | |
Re: 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 … | |
Re: Could it be because you are closing the window while the transition animation is still in progress? Maybe try stopping the animations before closing the window? | |
Re: You have written the array of data to a text file, so loading it is a question of Reading each line from the text file (see any tutorial for reading lines from a text file) Splitting that line into fields using the tabs as separators (see String's `split` method) Storing … | |
Re: Have you checked owner.getAppWidth/Height? Maybe those values have not yet been initialised when the panel is painted for the very first time? | |
Re: Starting at the beginning... line 2 starts a loop using the value of various count variables, but these are never changed in the loop. So either it will execute zero times, or it will loop forever. Similarly the next loop (line 25), except because it has an unconditional break in … | |
Re: Hi Muwanguzi Lynda 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: … | |
Re: the problem is with the variable you call "total". Your loop sets total to 15/15 then 15/14, then 5/13 etc - which in integer arithmetic keeps giving you 1's I don't undersatnd what that variable is for anyway. In pseudo-code all you need is for possible = 2 to (number-1) … | |
Re: So much in life depends on luck, but you can make yourself sa lucky person by: 1. Giving yourself chances to be lucky - eg it's wondeful luck to meet the person who will be your soul-mate. But you won't have much luck if you stay at home. So meet … ![]() | |
Re: It's often a much higher level description of a process or algorithm, eg rubberman's example could be Do <stuff> for each whole number between 1 and 10 In general you can take pseudo-code and turn it into a program in a language of your choice - the pseudo code will … | |
Re: You have 3 while loops using columncounter, and in each case you forgot to initialise/reinitialise columncounter before entering the loop(s). | |
Re: That question doesn't seem to make any sense. Pleae explain exactly what you want to do. | |
Re: It's impossible to give a definitive answer without complete info, but at first sight my gut feel is: Customer and CustomerEnquiry are clearly different things, witha clear "has-a" relationship. There's no doubt that you would model these as different classes. Maybe there would be technical reasons to combine them at … | |
Re: LInes 46,47 The only place you can draw to the Graphics is inside the `paint` method (or `paintComponent`, which would be better). Swing is double-buffered and anything you draw in other methods is most likely never going to de used. f.getContentPane().add(ok); you haven't needed to do this for about 10 … | |
Re: If you search DaniWeb for Java Chat you will find lots of discussions abou this topic, including the kinds of problems people encounter and how they can be solved. But the one thing you are certain to need is a multi-threaded server using Sockets. This tutorial is excellent... http://www.oracle.com/technetwork/java/socket-140484.html | |
Re: You say you have a "Non-Static Method Cannot be referenced from static context.", but you forgot to tell us which line that was referring to. But then you say you have incorrect output - which is impossible if you have the "Non-Static Method Cannot be referenced from static context." because … | |
Re: Although algorithms in general are used outside programming (eg in maths), in this context an algorithm is a way of solving a programming problem. If you don't have some knowledge of programming then the algorithms will make little or no sense to you. I'm 100% voting for learning at least … | |
Re: Agree Coding `<some boolean expression> == true` is a novice mistake. However the name of the method should include a verb and clearly express some assertion with obvious meanings for true/false, eg ItemExists, IsValid, HasMore, MeetsEPARegulations, WasAchievedByCheating etc | |
Re: Are you sure you mean RAM and not hard disk? Windows 8 occupies that much disk storage, but will run in a far smaller amount of RAM. Any machine that really has 20 gig of RAM should be able to run MySQL with ease. | |
Re: That is ok for a simple case. If you have multiple windows that may be called in various sequences, and complex data to be shared, then the standard approach is to create a new class that holds all the data and make that class available to all windows. | |
Re: Maybe your teacher didn't explain it because (s)he probably wanted you to go through the process of working it out for yourself. Give it your best shot before askiing for more help here. |
The End.