BestJewSinceJC 700 Posting Maven

Well, I would have done so, except my computer also bluescreened, which was not firefox, my webcam froze (and caused my computer to freeze), which was not firefox, and I would sometimes see random black images cover half the screen when I started the computer, which wasn't firefox. But I reinstalled factory defaults, everything seems ok now. Haven't had problems since then. Thanks for all the help guys. If I experience any more problems I probably will dump firefox though.

BestJewSinceJC 700 Posting Maven

Yeah, I can't enter a consonant either. I tried doing so in all of the open text boxes.

BestJewSinceJC 700 Posting Maven

. . And after disabling and uninstalling the skype add-on for firefox, facebook suddenly works perfectly again. And daniweb hasn't made me log in multiple times again yet. Woohoo computer science! *very unamused*

Sorry for so many posts, but after all of these discoveries.

BestJewSinceJC 700 Posting Maven

I'm going to try the 64 bit firefox, I guess. . I also discovered that although yesterday I could go to my facebook page's "profile" tab, today, I cannot. But I can do so using internet explorer.

BestJewSinceJC 700 Posting Maven

Vernon already gave you great advice. . I noticed you have the following line of code:

double totalOilChangeCost = (distanceTravel / 3000) * 30;

Since distanceTravel is an integer, and 3000 and 30 are integers, the whole expression will, I think, result in an integer. You can use a println to test if that is true. Is that what you wanted?

In any case, you should use constants where applicable. You have a constant for 3000 - oilChangeRequired, and you have one for 30 also - oilChangeCost. Use them because it makes your code more clear and more understandable, and if the constant was to change in the future (lets say oil changes go up to $45) it would be easier to change in the code:

double totalOilChangeCost = (distanceTravel / oilChangeRequired) * oilChangeCost;

which would result in a double because oilChangeCost and oilChangeRequired were declared as doubles to begin with.

BestJewSinceJC 700 Posting Maven

The adjustment to the time between page saving on Firefox fixed the issue with the youtube videos. Thanks for that. I'm still having the weird issue with having to log in multiple times onto this website, if anyone has any ideas what could be causing that. If it isn't fixable then it isn't a big deal because it is only a small annoyance. Again, I appreciate all the help and comments you guys have already given.

BestJewSinceJC 700 Posting Maven

Thanks for the advice vincent.

BestJewSinceJC 700 Posting Maven

If you want to print a price list and then print a receipt, one good way to do it would be to look at the similarities: both a receipt and a price list contain items. So you could build an item class that had variables such as cost and sales tax along with it, then you could have a method for printing an item's price and a method for printing the item onto a receipt. You could create an array of these items, then loop through, printing the price of each to form a price list.

If you wanted to erase the price list, you could have an array or arraylist of items, and delete each one as you went, perhaps adding them to a second list of items that would aid you in printing a receipt.

If this isn't helpful then elaborate on your question.

BestJewSinceJC 700 Posting Maven

You can also use Java 3D for 3D graphics. A lot of people use OpenGL bindings for Java also.

BestJewSinceJC 700 Posting Maven

This sounds like a very cool project - one I can't help with - but please post the solution once you've worked your way through it!

BestJewSinceJC 700 Posting Maven

Thanks for the youtube tip. I just changed it to a minute inbetween saves, I'll watch some videos and let you know if that does the trick.

Oh, to add to problems I'm experiencing, I also have to log onto this website multiple times, since after I correctly log in, it immediately takes me back to daniweb.com, but I'm not logged in. After I try it a few times it eventually logs me in properly.

One more problem - I've occasionally experienced my computer freezing when I shut it down - a few times, when I shut down, it has just frozen on the screen where the little circle is supposed to revolve, showing you that it is in the process of shutting down. I have an integrated webcam and I believe every time my computer hasn't shut down properly, it has been after I was running the webcam (either with skype or gmail chat). That could be coincidence though.

Anyway, thanks for all your help guys. As you can tell I'm frustrated by the fact that all these applications and even my OS seem to be messing up on a brand new machine. However, I'm not sure where any problems lie.

BestJewSinceJC 700 Posting Maven

Hey guys,

I bought a new computer with 4 gigs of ram, 64 bit windows vista OS, dual core 2.4 ghz processor. . and I'm having some problems with it. Firefox frequently seems to mess up. Sometimes it won't stop loading a page when I click 'X', it will become unresponsive and not let me highlight the contents of the address bar, etc. I was wondering if it could be related to running a 32 bit version of firefox on 64 bit windows, but it should run correctly as far as I know. Oh, and when I play youtube videos, even though the video is already loaded, it will sometimes stop playing, show the loading circle, then resume after it loads. . although that might not be a problem, I find it surprising that my machine which should be plenty powerful could have trouble playing a 4 minute video. I also experienced a couple other things that seem strange to me, but meh.

BestJewSinceJC 700 Posting Maven

I've never done that before, so I can't help - sorry.

BestJewSinceJC 700 Posting Maven

I don't think Java 3D is a dead technology. . but I asked a similar question of an enterprise developer, and he said that he thinks OpenGL for Java is better than Java 3D. I've heard that OpenGL with C++ is faster though.

BestJewSinceJC 700 Posting Maven

RPS is an extremely simple game. . because of that, it isn't really necessary to do it OP style - what would your objects be? The Rock, Paper, and Scissors need not be Objects because they are better represented as Strings (in my opinion). I suppose you could make the Players themselves Objects and make takeTurn methods and getWinner methods. getWinner could return the name of the player who won or "tie" to keep the game going.

BestJewSinceJC 700 Posting Maven

James is right - you can create the JLabels in the class definition, but nothing further. In the future, you should use an array if you have any type of collection of Objects like you do above. For example, this code will do the same as yours does, but in a few lines:

JLabel[] blocks = new JLabel[100];
for (int i = 0; i < blocks.length; i++){
    blocks[i] = new JLabel();
    blocks[i].setOpaque(true);
    blocks[i].setBackground(MyBlue);
}
BestJewSinceJC 700 Posting Maven

GridBagLayout gives you a pretty good deal of customizability.. http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html

Alternatively, you could stick with whatever Layout Manager you're using and explicitly set the size of the text fields using setSize or setPreferredSize - either of those should stop the text fields from taking up the whole window.

BestJewSinceJC 700 Posting Maven

Yes, both are possible. Resizing the image may be tough but it is definitely possible, however, you'll have to wait on someone else to answer how to go about doing that. For forcing a window to stay open until a correct password is entered, you'd look into WindowListener. http://java.sun.com/docs/books/tutorial/uiswing/events/windowlistener.html

BestJewSinceJC 700 Posting Maven

I don't really see anything wrong. You said they are JPanels but they are JLabels. (You can set the background on either, so again, no problem). Do you mind posting your code?

BestJewSinceJC 700 Posting Maven

Have you read about JMF? There are a lot of explanations of why it is difficult to do things such as writing pause methods for audio clips. And there is guidance to how to accomplish doing it if you really decide to take on the challenge.

BestJewSinceJC 700 Posting Maven

Your main problem was probably setting the layout to null. You're supposed to use Layout Managers, which dictate how Components (such as buttons, labels, and text boxes, etc) get positioned within your Containers (JFrame and JPanel are Containers). If you set the layout manager to null, that probably means you weren't using one, which means that nothing was controlling how things were positioned. Anyway, if you're still interested in learning how to make GUIs with Swing, don't hesitate to ask for help.

BestJewSinceJC 700 Posting Maven

"What I am not checking for is a character response."

You can look into ASCII character values; in order to make sure that something is an integer (or is not a character), you would compare the character to a range of ASCII values which can be found on the table. This advice is less detailed than a lot of the other responses I see in this thread, so be warned that it isn't a solution but a useful thing to know that can help you build a solution.

BestJewSinceJC 700 Posting Maven

This isn't a website for hand holding. The information is readily available. Look it up. Figure it out.

BestJewSinceJC 700 Posting Maven

Yeah, I'm pretty sure it's because by calling repaint, you are calling paintComponent, which I believe clears the screen for you before drawing whatever it draws. So you'll either have to redraw everything that you want on the screen (which would require your programremembering what was there) or you'll have to edit paintComponent method so that it does not "erase" the screen. I could be slightly off in my advice here, but I will check a previous thread of mine that contains the correct info and I'll get back to you later tonight. (But I think this is right)

BestJewSinceJC 700 Posting Maven

Try to avoid giving people solutions unless it is impossible to help them without pointing out the exact code.

BestJewSinceJC 700 Posting Maven

WorkThread should not be running on the EDT. This indicates that WorkThread is not running in a separate thread - so the new Thread was not set up properly. Look up how to create a separate Thread on google. You should also look into Swing's WorkerThread class.

toucan commented: Good troubleshooting skills. +2
BestJewSinceJC 700 Posting Maven

"However, since I've only learnt Linked List so far so I thought that playing some tricks on Linked List would do create the Circular."

You are pretty much correct. The differences that I can think of off the top of my head:

1) Obviously, the circularly linked list needs a pointer to the next node and the previous node, whereas the singly linked list only needs a pointer to the next node.
2) The add method for the circularly linked list needs to keep a "previous" node reference, and then when a node is added, that node's previous variable should be set accordingly.
3) The remove method for the circularly linked list needs to update the previous variable as well as next variable whenever something is removed.

etc for the other methods. You're using the same exact methods, just modifying them somewhat to account for having that extra previous node. It isn't that different.

BestJewSinceJC 700 Posting Maven

Btw, the reason I'm having you do that is because if your main code is running on the Event Dispatch Thread, like it should be, and if your "WorkThread" is also, which it should not be, then it could be blocking the thread, preventing any of your mouse clicks from registering. So I'm trying to make sure your Threads are actually set up correctly as separate Threads and that the one is running on the EDT. Thanks for being so patient.

BestJewSinceJC 700 Posting Maven

"I had my event handler print a message every time it detected a mouse event and it only prints once"

Like I said, you should have at least two threads: one would be your WorkThread, and the other would be your main thread, which presumably would run your code on the Event Dispatch Thread. The main thread would be the one responsible for the event handling. You should make sure that your code is running on the Event Dispatch Thread. . you can do so by calling SwingUtilities.isEventDispatchThread() from within the thread. Your "WorkThread" should return false when you call that method, and your main thread should return true when you call that method. So put that line of code into both your main thread code and your WorkThread code and tell me what it returns for each of them.

BestJewSinceJC 700 Posting Maven

All you need to do to draw the circle in its final position is call repaint, set the coordinates of where you want the circle to be drawn, then draw the circle at that position. You'd put the method calls to do that inside of mouseReleased.

BestJewSinceJC 700 Posting Maven

"I can't interact with the GUI and trigger mouse events that should interrupt the WorkThread, even if it goes through multiple iterations of the while loop."

So you're saying that once the WorkThread starts running, your program will not trigger mouse events? Or that your program triggers mouse events, but these mouse events do not interrupt the WorkThread like they're supposed to?

BestJewSinceJC 700 Posting Maven

The best way to "translate the value of the element to the index" is to simply keep track of what index you are looking at. To do a "swap" (switch two values in the array) all you need are three pieces of information: The two indexes you want to swap, and a temporary variable to hold the value of the overwritten index.

So

array[5] = array[4];
array[4] = array[5];

Doesn't work because you just overwrote array[5]. So you'd do this instead:

int temp = array[5];
array[5] = array[4];
array[4] = temp;

That probably doesn't help.... feel free to ask some questions about sorting, we'll all be glad to help.

BestJewSinceJC 700 Posting Maven

popupPanel.setLayout(null);

^^ Looks like a bad idea although the layout manager might use a default layout as a result of you doing that. Although it was already using a default layout so.. why?

You also might want to try calling the pack() method on the popupPanel. Perhaps setVisible as well. And post all of your Java classes, I will run it and help you out.

BestJewSinceJC 700 Posting Maven

I'm not sure that this is the issue, but just so you know, the while loop condition is only going to be checked after the method call that is inside the while loop completes. You probably knew that. Other than that, I'm not sure I understand what problem you're having. What you need to do is have a different thread (probably the main thread) detect the mouse event, then set a condition that lets the other thread know it's time to stop execution. The other thread should periodically check to see if it is time to stop execution.

BestJewSinceJC 700 Posting Maven

Oh, I just edited as you posted. Since you're in here right now, if you tell me what you want your buttons to do (what their purpose is), I'll help you out.

BestJewSinceJC 700 Posting Maven

terence - I apologize for not having comments on your code, but I just don't have time to wade through it right now. But keep in mind that comments should be used for clarifying the code when it is necessary to do so, or for explaining what a line (or group of lines) of code are doing when it is not immediately obvious, not to explain exactly what the syntax of every line of code is doing.

Also, I'd help out now but you never mentioned what the first, last, and next buttons are supposed to do. What do you want them to do? What are they doing right now? Do you know what lines of code (in the code tags) are incorrect? Do you know of any problem areas or can you not figure out what is wrong? Etc.

BestJewSinceJC 700 Posting Maven

You can accomplish this in a number of ways using Swing and basically every other GUI toolkit available. Swing is easy to learn though, and it can be accomplished with only one panel, but peter's suggestion is good.

BestJewSinceJC 700 Posting Maven

If you want to sort your list but do not want to write the sorting method yourself, then you can create an ArrayList, add each of your Integers to the ArrayList, then use Collections.sort(yourArrayList) which will sort it for you. For more information on those concepts, you can look at the Javadocs for each. Here's a small example

//This assumes you already have an array of ints
//called myIntArray set up.
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < myIntArray.length; i++){
    list.add(myIntArray[i]);
}
Collections.sort(list);

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html

However, I would strongly suggest that you learn how to write at least one simple sorting method yourself, this is the easiest way to do it but not the one that will help you learn the most.

BestJewSinceJC 700 Posting Maven

I had seen that also, James, but it said JEditorPane and JTextPane among others, whereas the OP wants to use JTextPane. I guess it might be supported for JTextPane as well though.

BestJewSinceJC 700 Posting Maven

With use of plugin like Axis2 you can take WSDL and attempt to build service from it, examples

Actually, I should have already know that considering I have used Axis before to do exactly that. . although my coworker actually got it working, so I did not get as in depth as he did.


And @ the OP:
Like Peter said. . and he is correct. . you can use Axis or Axis2 to do that. You could also write the java files by hand, and hard code the requests to the server and parse the xml response. Just search for some axis tutorials.

BestJewSinceJC 700 Posting Maven

And why can't he override paintComponent, setting the color to whatever he wants, using the drawString method to write text, then changing the color when he wants to?

BestJewSinceJC 700 Posting Maven

And as far as I know a wsdl file defines the types of requests that can be made to a web service and the types of responses that will be received for those requests. I could be wrong about that, though. And what do you mean by creating a web service from the wsdl file?

here is a tutorial on wsdl, if you want:
http://www.w3schools.com/wsdl/wsdl_intro.asp

Also, you might want to consider implementing it as SOAP if you're creating a desktop application, although you should look into it further before making a decision.

BestJewSinceJC 700 Posting Maven

The method you must implement has the method header commandAction(Command, Displayable) whereas the method you wrote has the method header CommandAction(Command, Displayable). These are considered two different methods since Java is case sensitive, which is why you're getting the error. Also, keep in mind that commandAction follows the recommended syntax whereas your method, CommandAction, does not.

BestJewSinceJC 700 Posting Maven

I'm not sure about this, but I think using Collections.sort(yourArray) would also do the same thing javaAddict is suggesting. But it seems like your assignment is to write the sorting method yourself, so you'll need to specify what vernon mentioned.

BestJewSinceJC 700 Posting Maven

I don't really know, sorry

BestJewSinceJC 700 Posting Maven

If you have a couple of years of free time, go with the OS. Otherwise, I'd find a smaller project personally.

BestJewSinceJC 700 Posting Maven

I'd recommend JFreeChart. It isn't that hard to use. I'll tell you what, I'll give you a sample piece of code that my teammate wrote on our project that produces a bar graph. You'll have to edit it a lot (hopefully) to get what you want, but it should give you the general idea.

edit:

You'll have to wait for an example from me - my zip drive that has the project on it is in my car's trunk and it's dark out here so I couldn't find it. I'll try to remember to grab it tomorrow.

BestJewSinceJC 700 Posting Maven

If you want to learn some new things while doing some challenging projects, you might try http://www.csee.umbc.edu/courses/undergraduate/341/spring09/341-spring09-projects.shtml . . most of those projects use specific data structures (or, are meant to if you do them efficiently) and are *usually* challenging.

BestJewSinceJC 700 Posting Maven
BestJewSinceJC 700 Posting Maven

This is one of the most - amusing? - threads in a while.