For anyone who has implemented a GUI for starting and stopping the server, did you use a JFileChooser component to allow selection of the database file? The reason for asking is that the JFileChooser takes a long time to load on a machine that has a lot of drives mapped and a lot of storage space to cover to create its internal file mapping. Is a simple text field enough? Thanks, Todd Harney PS - I have seen people mention the system property for user.dir...so where are you telling the graders to put the db.db file? Can you predict on any platform what the user.dir property will evaluate to?
Mark, So you had the client.jar and server.jar in the root of your submission and also the db.db file? Then you mentioned in the README.txt that the db.db file needed to stay there? Am I guessing correctly? Thanks, Todd PS - Also, how does the whole "user.dir" thing go? I thought it depended on platform to platform? Is there some rational pattern behind where "user.dir" will point to?
user.dir will point to the directory that is where it is running. So if you have your server.jar or client.jar in the c:\devexam directory that is what will be returned in the user.dir call. In my submission jar file, when you unzip it puts the db.db file there.
db.db file exists in the main directory that you unjarred the main jar file.
if you unjarred the file into a directory called c:\devexam you would find the db.db at c:\devexam\db.db
the above I took from my readme.txt file Hope that helps Mark
I am having problems with my gui. I do not want to place the entire jazz into into one class, ie, an FBN client. I would like to separate out stuff like te actions etc, communicating with the database etc. Could someone suggest a design please. I currently have a Client.java which is a frame and has other stuff like the action classes as well as the code to talk to the dataclient. I would like a more separated implementation but am not being able to get the right stuff in. Looks rather messy as of now.
Never be satisfied with anything less than the best and you will surely pass the test...
Kalichar you need to use MVC Model View Controller pattern. How to implement this. Make your one class that draws the GUI. For any actionlisteners that will need to be attached, make a "Hook" method to add those listeners. THis way you have no action code in the GUI class. Then in a "Controller class" you can pass a reference to the DataAccess class, and to the GUI class. Call the GUI class "Hook" method passing an Anonymous Inner class that is an action listener. It is really Easy. Here is some Sample code. In this example, when the user enters a number into the # of passengers textbox, I have an FocusAction attached to it, to 1 check if the entered number is valid. I check the # of available seats and make sure the number entered is not larger. I also enable my Book Flight button with it This is in the GUI
Now, here is the code in the controller. It just passes an anonymous inner class that passes the action to a method in my controller.
enableBookButton does all the work. Hope that clears thing up for you. there is also a tutorial, I think, at Javasoft Mark
Anything that has to do with visuals should not be in the same place as Data and the actions code. They all need to be seperate from each other. So inorder to have them working together, you have a class that is a controller that knows about all the objects and passes messages back and forth. There should be no Frames, Panels, Tables in that controller. The controller might use these objects to pass messages from them and to them, but not created directly inside the controller. Mark
Mark, My client consists of something of the following: FBNGui.java - contains all code related to visuals like layout managers, tables, buttons, etc. But it also contains several inner classes that are extensions of AbstractAction...i.e, they are action classes, but have been separated out into inner classes to keep the action code from cluttering the visual code. Also contains inner classe for my table model. FBNServices.java - there are other files too, but this a "business" type interface and factory that the gui code calls like bookFlight and searchFlights...called from my actions classes. I kept things in the gui as inner classes to avoid passing around references to gui widgets to get data and what not? Does this design seem reasonable to you? Thanks, Todd
I have gone a step furthur and have seperated model for every screen too. I have search , result and reserve screens. and for all three screens, i have Panel(GUI), model(Model af all COMPONENTS in the screen), listner (listner of all MODELS related to the screen). Now model class has only gui, listner has only model class. and also i have a componentFactory who controls all of them. Believe me it is so flexible, SIMPLE and easy to work and enhance the features. I have no listner on the components. everything goes thro model. let me know what u guyz feel abt it. amit
Hi Mark u have written that u have hardcoded the database file name and its path in your server. So now is there any need to pass db.db file name while starting the server from command prompt. I am asking so becoz in the instructions (specs) it is written that your server may take params like DNS name of the server Port number used by the server Data file name(s) (imp) java.rmi.server.codebase security manager policy file
Another thing have u implemented dynamic downloading and codebase? is this requireed ? How u have implemented policy file. Pls Help
Kalichar - Actually when I retire in 20-25 years form now, I want to teach. But I think I really want to teach Math in High School. Like Trigonometry or Calculus. By hard coding the Db.db file I do not pass the location at all. Actually I only include the policy file for the server and for remote client. In remote client I also include the IP address of the server as a regular parameter. For local mode there are no arguments passed at all. No I did not use Codebase or Dynamic Loading. I believe you need a web server for Dynamic Loading. I don't think I was going to upload one of those to Sun Mark