| Java Spring 2006 - HW7 FAQ |
|   Java Prog Home   |   HW7 Assignment |
+ TableSorter class
|
Question: | Can I use the TableSorter class that is provided by Sun in the Sun document: How to use Tables ? |
|
Answer: | Yes - feel free to use this (it looks very useful). Note that this is not part of any default package, you need to get it... Make sure you leave the author information in the file intact (you are free to use this as long as you are not trying to pretend you wrote it!). |
+ Hung User Interface
|
Question: | When a user clicks a button, my program creates a new window, but nothing ever appears in that window. In fact, it appears that all of my windows are hung (nothing happens in any of them). What am I doing wrong? |
|
Answer: | Remember that when processing any GUI generated event (like a button press), the GUI thread is what calls your code. This is the same thread that is responsible for updating the display, interpreting user actions, etc. If you try to do anything GUI related (like create a new window, or wait for a button press) inside the GUI thread, it won't work. In general, if you have an event handler that does anything non-trival (like creating a window, etc), you should createa new thread to do this. This allows your event handler to return (and then the GUI thread can handle other tasks, like drawing your new window). There are many ways to create a new thread, here is one (probably the simplest). Assume you have some code in an event handler that calls some method named
Thread t = new Thread() {
public void run() {
createNewSongWindow();
}
};
t.start();
|
+ MP3s, CDs, Playing Music
|
Question: | I found some Java code that extracts information from MP3s, or from CDs or plays Music, can I use it in my project? |
|
Answer: | Yes, just document (in your README) any code that is part of your project that you did not write, including where you got it from. |