7,116 Posted Topics
Re: newMaze contains a copy of a reference (pointer) to the maze array in the instance of Maze, so yo can just use that as in [ICODE]newMaze[i][j][/ICODE] which will reference exactly the same memory location as the original [ICODE]maze[i][j][/ICODE] | |
Re: Encryption: there's no reason to go further than the API classes that are included with every Java installation. [url]http://download.oracle.com/javase/6/docs/technotes/guides/security/[/url] | |
Re: Line 45 you are relying on good luck with your >1. The JavaDoc says [QUOTE]Returns: a negative integer, zero, or a positive integer as the specified String is greater than, equal to, or less than this String, ignoring case considerations.[/QUOTE] The actual source code shows that it returns either the … | |
Re: You can specify a full path from the root (eg c:) to the file, check out the API doc for File. You can also get useful directories like the user's home dir or a temp directory from System.getProperty, eg System.getProperty("user.home") and use that to locate a file. | |
Re: Your use of && looks OK to me. That isn't the neatest/shortest way to code it, but as far as I can see it should work as you intended, apart from some marginal cases where the ranges don't quite meet up, eg 3.05, which isn't a B+ or a B … | |
Re: If you have the image, and are drawing it in a paintComponent method, then you can cast the Graphics g parameter to Graphics2D and use its [I]rotate [/I]method. (which is an easier cover method for a rotational AffineTransform) | |
Re: Java only makes sense if you are thinking in an object-oriented way, which VB gives you no preparation for. In VB you just write code and it does what you expect, and the reward is instant. In Java you spend much more time thinking about the object structure and the … | |
Re: [QUOTE]question 1: what do you mean by, find mode?[/QUOTE] In statistics, the mode is the value that occurs most frequently in a data set or a probability distribution. If the distribution is a nice curve that's low at both ends and highest in the middle (like most are) it's the … | |
Re: What do you men by "find a vowel"? Maybe you can give a sample input and output to illustrate what you mean? In you existing code the array vowel is a complete mystery - you fill it full of vowels, but then you just use its last element to hold … | |
Re: On line 3 you update a variable gameBoardGUI to refer to the new char[][], but that won't change any Swing components. It seems you are missing a line or two of code here to update some Swing component with that new data. | |
Re: I'm sure there are many of us here who would like to help you, but its really hard to debug 900 lines of completely uncommented code with variable and method names in a language that few of us speak. Unless you can create a smaller simpler version that displays the … | |
Re: I assume you are drawing the grid in an overridden paintComponent? After moving the label you should just call repaint() to let Swing know that the container's paintComponent needs to be called a.s.a.p. | |
Re: You can start by adding those buttons to the elseifs in you actionPerformed method - have them just call methods add(), save() etc, then write those methods, one at a time, testing each small step with lots of print statements as you go. | |
Re: You are correctly getting a wins value from your game instance [ICODE]10 int wins = game.getWins();[/ICODE] BUT you do that before starting the game, and you never update it, so it remains zero. If you just move that line to somewhere after the game is finished that should give you … | |
Re: .. or simply [CODE]double d = .... while (condition) { d = d/2; }[/CODE] ps. Watch out for capitalisation. It's while, not While, and we always give variables names that begin with a lower case letter. | |
Re: somewhere in the [I]... and so on[/I] it gives details of the lines in your program that it was executing when it overflowed. This is essential info. Anyway, it looks like it's in the middle of creating a window, so your loop is probably in the creation of the new … | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] Post your question in a new thread of your own, but also remember this: DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if … | |
Re: Your { and } are not matched up. Somewhere you have an extra } that closes the definition of a class, so the following line cannot be compiled. It will help if you indent your code properly. | |
Re: The secret of understanding this is to remember that list1, list2, list, and result are [I]references [/I](llike pointers) to an Object of type ArrayList<String>. The only way an actual ArrayList<String> object can be created is with the [I]new [/I]keyword (line 3). If you follow the code 1 step at a … | |
Re: Create a Socket connection between two programs running on different machines on the LAN. Send a lot of data (megabytes) from one to the other and record how long it takes. You'll find all the info you need on Java Sockets by searching the web. Come back here if you … | |
Re: Can we please see more of the code - those two lines don't show enough to create or diagnose a problem. Ideally, post a small runnable program that demonstrates your problem. | |
Re: 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 coding your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting … | |
Re: UDP is a connectionless protocol. What exactly do you mean by "disconnect the client" when there is no connection? ps Are you thinking of the connect method in DatagramSocket? - that just simplifies the syntax for sending messages by pre-determining the addresses. From the server end you can ignore that. … | |
Re: You can define a tautology as a logical expression whose value is true for all possible combinations of input values. Since this exercise is limited to three input symbols you can construct a complete truth table - it only has 8 rows. So maybe the approach is to parse the … | |
Re: No, it's not valid. The method currenttemp() must either have a body in {} or be declared abstract, in which case the class must also be declared abstract. Without the () currenttemp becomes a float variable, not a method, and the code is valid. We can only guess what the … | |
Re: It's not so much that it "violates encapsulation laws", it's more that it creates design problems and bugs that are really hard to fix. Declaring a constant as public is safe, but declaring a variable public means that anyone, anywhere, executing in any thread, may change its value at any … | |
Re: Looks like you are trying to add new versions of your components over the top of the previous versions? If so, it would be safer to to remove the previous ones explicitly, or to re-use them | |
Re: This is a standard problem with a standard solution: Change the NewJFrame constructor to take an instance of Watcher as a parameter and store it. So your main now looks like [CODE]Watcher beholder = new Watcher(); NewJFrame GUI = new NewJFrame(beholder); // pass Watcher instance to GUI[/CODE] now in NewJFrame … | |
Re: That's almost certainly a good idea. The code for GUIs with lots of controls like this gets out of hand very quickly; it's very long, horrible to debug, and incomprehensible for anyone else. Splitting it into separate classes for each panel helps enormously. One hint: Keep a class for the … | |
Re: I doubt it very much. Why don't you want to use the one class that was designed for exactly that kind of thing? ps: If you want to look for sample code etc on Google, the normal spelling is "pie chart" You will also find packages and products for drawing … ![]() | |
Re: Not possible using "ordinary" Java, but possible using the "reflection" classes - have a look at the class [ICODE]java.lang.reflect.Method[/ICODE] to get a quick flavour of what its all about. I can give you a lot more info on reflection if this looks like a direction you wan to go in. | |
Re: Taywin's right - the Math trig functions work in radians, not degrees (2*Pi radians = 360 degrees). Also I think zero angle is pure "East" (is along the x axis), not North. | |
Re: [QUOTE=anand01;1677614]1)Is Method Overloading considered as polymorphism? 2)Is there two types of polymorphism(run time and compile time ) available?[/QUOTE] 1. According to Oracle's web site - yes. 2. Given that Q1 answer is yes, then yes. Overridden methods are resolved at run time based on the target's run-time type. Overloaded methods … | |
Re: I'm a bit baffled by the number of arrays in this program. I would expect to see the collection class containing just one array of films, not two, and I would not expect to see any other class having any arrays of films or arrays of collections at all. With … | |
Re: The list of VK_... key codes can be found in the JavaDoc for KeyEvent. eg the control key is VK_CONTROL. I don't know about how the Mac Command key is coded, maybe its its the same as VK_WINDOWS? (easy to try!), but you could write a very small program with … | |
Re: A queue is almost identical to a stack. The only difference is the stacks are LIFO (last in, first out), but queues are FIFO (first in, first out) | |
Re: A simple solution may be to create a blank icon of exactly the same size, and just switch the icons when you want to show/hide the real one. | |
Re: Full error message please: it shows which line and where on that line | |
Re: Having a variable called "count" is confusing - is it left over from a previous exercise? To find the largest you need a variable called "largest" which is initialised to a small value. Then as you process each input you ask "is this bigger than largest" and if so, save … | |
Re: This program demonstrates one of the almost-acceptable uses of labels in Java - that is to label a loop then use that label in a break statement to make explicit the loop that is being broken out of. It can even be useful where you have nested loops and want … | |
Re: listItemListener implements ItemListener, so that code is perfectly valid and normal. | |
Re: First looks OK to me - what is it doing that's wrong? Last sets position to -1, that's not valid. Shouldn't it be productArray.length - 1? Previous is testing for position at the end of the array (it's a copy of the logic for next), shouldn't this be testing for … | |
Re: Your problem is that although you know that one of those if tests must be true, the compiler isn't quite that smart, so it worries about the case where all 3 if tests are false and execution drops out of the last elseif. In that case it gets to the … | |
Re: You can add labels to a null layout - you need to call setBounds to specify both the position and size, and request a repaint afterwards. For ultimate control over layouts while retaining all the advantages of a layout manager use GridBagLayout. The learning curve is a bit steep, but … | |
Re: Line 3 you create new log, then ask that to getUser, so of course its empty. Instead of a new log class, B needs a reference to the real log instance that you created and interacted with. How that happens depends on the code where log and B are created, … | |
Re: You never call your circleInfo method, so it doesn't get executed, so there's no user input. | |
Re: Yes, just add them one at a time and forget the second array. You already have code to find an element and flag/unflag it - so what's the problem you are asking in bold above? | |
Re: What's the question about the speed var? What you are doing now is good. Also your default value is good. No problemo. ps: Those 3 speeds should ideally be an enum. If you have not covered enums in your course then ignore this comment! | |
Re: Yes, you can use your image to make an [I]ImageIcon [/I]and put that in your JLabel. Documentation is in the usual places. |
The End.