RSS Forums RSS
Please support our Java advertiser: Lunarpages Java Web Hosting

re: Trouble with GUI

Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 19
Solved Threads: 200
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Trouble with GUI

  #2  
Apr 14th, 2006
You did some modification to the code JBuilder generates for you I see

You will need to design your screen and hook up the controls to enable the interaction.
You should also go for a proper object oriented approach, which would have the RMI functionality separate from the user interface.

That way you can do something like:
        if (!GraphicsEnvironment.isHeadless()) {
            // graphical environment available, launch GUI for interactive mode

            MainFrame frame = new MainFrame(serverProps);
            frame.validate();
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Dimension frameSize = frame.getSize();
            if (frameSize.height > screenSize.height) {
                frameSize.height = screenSize.height;
            }
            if (frameSize.width > screenSize.width) {
                frameSize.width = screenSize.width;
            }
            frame.setLocation((screenSize.width - frameSize.width) / 2,
                              (screenSize.height - frameSize.height) / 2);
            frame.setVisible(true);

        } else {
            // no graphical subsystem, launch server without interactive mode
            // using the values from the properties file
            Server server = new Server(
                Integer.parseInt(serverProps.getProperty("rmi.port")),
                serverProps.getProperty("server.file"),
                serverProps.getProperty("rmi.service"),
                Integer.parseInt(serverProps.getProperty("server.timeout")));
            try {
                server.startServer();
            } catch (RemoteException ex) {
                System.err.println(server.getMessages());
                return;
            } catch (IOException ex) {
                System.err.println(server.getMessages());
                return;
            }

        }

to allow your server to also function on a machine that has no graphical shell using a configuration file to initialise it.
Mind I've not yet been able to actually test that code to see if the headless mode works, but I see no reason why it shouldn't.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:32 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC