Search results

  1. N

    Java question

    Please note that I haven't done Java in like 5 years, so it's a bit rusty. By default you can't. that is, a static method belongs to the class itself. One workaround is to simply define an argument for your static method. public static doThing(Object caller) { //Print name of class...
  2. N

    Java Swing JLayeredPanel Help

    I'll be honest Billy, I've took up a bit more time then usual on your little problem. But Eureka! My answer finally came to me when I read this little tidbit Well, there you go. Hope it's clear what you have to do! Cheers, Simon.
  3. N

    Concurrent Threading Java Help

    I don't think what you are asking for is any harder then the "java.lang.Object.wait()" and the "java.lang.Object.notify()". Cheers! Simon.
  4. N

    Java - JFrame.setBackground not working

    Actually, the problem is with the api itself. The method you are calling has been "sorta" deprecated. That is, what you are using is, AWT tech. Where as your JFrame is Swing tech. In other words, everything about the JFrame relating to it being a container has been rendered void of use...
  5. N

    Need help using a hidden field as a switch in a JSP.

    Call me old fashon, but if I were you, I'd simply check to see if there are parameters. if (request.getParameter("firstInteger") != null || request.getParameter("secondInteger") != null) { //Since I know that there is at least one "thing" entered in the texfields, I can try and add them...
  6. N

    Stuck on instanceOf - ArrayList - Java

    So now go back to post #2 of this thread and answer the darn question :o
  7. N

    Stuck on instanceOf - ArrayList - Java

    Well, yeah, I was just trying to point out one of your trouble. Also, you may want to check your spelling, it doens't look very good. (instanceOf?)
  8. N

    Java errors?

    The simple answer is that the last item you inserted in the array "items" was at index "used" as per this line: items[used] = new GroceryItem(); Now, right below this you call: used++; So, when finally you get to line 67, you ask for the "GroceryItem" from "items"...
  9. N

    Java Application & XML

    Well, here's my input on the choices you have. Save as a text file; Not a horrible idea. You could implement the RTF (Rich Text Format) format and have a pretty descent text editor. Save the Object itself ie; Serialization: This would be the easiest method to store your file. If would...
  10. N

    Java Hashtable

    I usually like to extrapolate on my answers in this forum... But your question it to straigthforward... So. To answer your question: Yes.
  11. N

    a beginner in java needs helpq

    Class: The blue print of an Object, it's definition. You code what the Object should be able to do, what it should be, it's very EXISTENCE!!!111. Example, you have the blue print of a Police car. This plan, is in no way a Police car. It's just a few pieces of paper with pictures, designs and...
  12. N

    Java: Innerclasses and Event Handling

    Your single problem is in your inner class "RedButtonHandler". public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); Color color = getBackground(); if (source == yellowButton) color = Color.yellow; else if (source == blueButton) color =...
  13. N

    Java ComboBox Weirdness

    Unless I am mistaken, Canvas is a heavyweight components? If that's the case, you will be almost unable to mix and match ligthweight (Swing) with heavyweights (AWT). Your best bet is to remake your class so that it extends JLabel instead. Cheers!
  14. N

    Help with my print out ( java )

    Without going indepth into your code, the reason you have a little runtime problem isn't related to the getCheckDigit () method as far as I'm aware. It's simply that at that peticular point in time, your argument "zipCodeStr" is null. Thus crashing the app. Were you to replace "zipCodeStr"...
  15. N

    java question

    A plain way to do it is to create a context class for your application. That is, an Object that is accessible to both JFrames. Let's create a class called "MyContext". He will have two variables; "username" and "password". With the proper getters and setters method of course. Now simply add a...
  16. N

    java navigation buttons?

    Well, you can start by giving us a bit more code. From what you posted, everything should be working. But, like I said, you haven't posted much. Simon.
  17. N

    Need help in Java graphics

    Well, I am always interested in helping people out. At first glance, you simply need to use the javax.swing.Timer class. Simply create a Thread that will invoke your GUI's paint method on a timed basis, (every 60 millis) and there's no more to it then that. If you have a more specific...
  18. N

    java problem (GUI)

    In response to your edit. You need two variables for that. First you need to know the Dimentions of your Frame; javax.swing.JFrame.getSize(); and then you need to know the resolution of the clients computer; java.awt.Toolkit.getScreenSize(); Afterwards, a little magic like; x =...
  19. N

    java problem (GUI)

    (Nemezer eagerly awaits the return of jonneymendoza when he'll realize that he still isn't out of the woods!) But I'm glad it worked. Cheers! Simon.
  20. N

    java problem (GUI)

    Well alright, we'll try and get it working so let's try this then: Put things as they were, meaning that Login extends JFrame. Now, replace your Main.main method to this: public static void main(String[] args) { Login test1 = new Login()...
  21. N

    java problem (GUI)

    Well, that's probably because you have no imports at the start of the file ;) Wether add; import javax.swing.*; or simply extend; class Login extends javax.swing.JPanel implements java.awt.event.ActionListener { Cheers! Simon.
  22. N

    java problem (GUI)

    Well there you go, class Login extends javax.swing.JFrame You cannot add a JFrame to a panel. You just need to make Login extends JPanel or some other low-level container and you'll be good to go! Cheers, Simon.
  23. N

    java problem (GUI)

    Off the top of my head, I can't figure out the problem. I'm pretty sure the problem lies in the code that you didn't give us :p If you could provide us with the code of the Login class, then we could be able to recreate the problem on our own machines. Which would help us greatly in helping...
  24. N

    java problem (GUI)

    Login extends which class?
  25. N

    Java Help

    Well to simply answer your question. When you wish to place a background image centered, the easiest way that I know of using AWT, is to simply draw it at the right place! Such as; g.drawImage(image, 0, 0, this); Instead of drawing it at the top left of the screen, simply make this...
  26. N

    Java help

    For all intents and purposes, you can easily fix this problem by changing one line of code.Instead of having one line to declare your variables, simply put in this code. int grade1 = 0; int grade2 = 0; int sum = 0; int average = 0; Or if you want to keep your code as condense as...
  27. N

    Linebreaks in Java

    To asnwer the original poster, the preffered way to handle such a situation is to go all the way by changing your InputStream into a BufferedReader. Simply use the readLine function and you can be assured nothing wicked will ever happen.
  28. N

    JAVA: Need help with bug in my program

    Well... Just before I leave, I will tell one quick and dirty hack that will allow you to make your program work as inteneded. Note that as far as I'm aware, the trouble isn't in you teachers Keyboard class. If you are in a windows machine, as soon as you call readChar make a couple of empty...
  29. N

    JAVA: Need help with bug in my program

    I was able to find the symtom of your problem, but I am yet unsure of why things are going the way they are. Here's what happens, You ask the first question, the user then enters the letter 'y' and presses the enter key. In the System.in buffer, you have now these chars {'n', '\13'...
  30. N

    Trigger for when actionPerformed returns?

    How about putting the entire method into a try/finally statement? actionPerformed { // change cursor at the start of the method. try { //Do your code that could very well go beserk. finally { //Revert to the old cursor } } Would this help?
  31. N

    Java Thread making

    Well yes, what I meant to say is that the code works fine for me. I copy pasted it and when i run it I can see the Thread working. Thus your trouble is something else that is not in the code you gave us.
  32. N

    Java Thread making

    Well I copy pasted your code and the good news is that it runs fine. So the problem lies elsewhere. If you need more help just post up more code. Cheers!
  33. N

    Java questions

    No, you never write .java in your imports. The thing is, if your two classes are in the default package then there is no reason to import them. If your compiler is unable to find the NetMyThread class, it's either that the NetMyThread class is in a different package (check at the start of the...
  34. N

    Java questions

    Glad to hear you got rid of that nasty warning. So to answer your first problem, you simply have to add an import at the start of your main class. import NetMyThread; That is if your NetMyThread class is the same folder and is in your current workspace.
  35. N

    Java questions

    Not easy questions to answer. 1) Well I have three sugestions -"Are you sure your class name is spelled correctly :p " -It might probably be a problem with of namespace. Is your other class in the same package as this one? -Or it could be a problem that you have never successfully...
  36. N

    Comparing files in java

    Being a non-native english speaker, I am entitled to certain perks :cool: Knowing that forums such as these are viewable all around the world, colloquialism is bound to arise. That cannot be helped. Best hope is to try and read the meaning, not the words. IMHO of course.
  37. N

    Comparing files in java

    Programers are usually curious as you probably well know :o
  38. N

    Comparing files in java

    Not to my knowledge. Which is why I call it a hack. Something not pretty that has to be done.
  39. N

    Comparing files in java

    Because the files can be big. Very big. Doing a bit-for-bit comparison of a 4 gig file is not a fun party :p
Back
Top