wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Data Server GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Data Server GUI" Watch "Data Server GUI" New topic
Author

Data Server GUI

Todd Harney
Greenhorn

Joined: Jan 25, 2002
Posts: 23
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 Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Actually I had neither. I just make it mandatory that the db.db file is in the same directory as the jar files. So the "path" is hard coded via

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Todd Harney
Greenhorn

Joined: Jan 25, 2002
Posts: 23
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?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
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...
Gregory Garrison
Ranch Hand

Joined: Oct 05, 2001
Posts: 107
Todd - I used the GUI to stop/start server. I used a Input dialog box for a user to enter the path.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Mark,
Thanks for the reply. I have this main client frame class that starts up the client Client.java.
Should it contain the table, the data accessor client etc?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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
Todd Harney
Greenhorn

Joined: Jan 25, 2002
Posts: 23
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Todd - Yes it seems reasonable. You have the actions and the gui split into two different classes.
Mark
amit ahuja
Ranch Hand

Joined: Nov 20, 2001
Posts: 38
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
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Hey Mark dude, have u ever considered becoming a professor? You just triggered my head to come up with a solid solution...Thanks Prof.Mark Einstien . God blesh ya!
Amit Kr Kumar
Ranch Hand

Joined: Feb 08, 2002
Posts: 100
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data Server GUI