Changeset 525 in tmcsimulator for trunk/src/tmcsim/client/CADClient.java


Ignore:
Timestamp:
11/12/2019 07:26:10 AM (6 years ago)
Author:
jdalbey
Message:

CADClient.java implement #199 - add a splash screen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/client/CADClient.java

    r453 r525  
    11package tmcsim.client; 
    22 
     3import java.awt.BorderLayout; 
     4import java.awt.Color; 
     5import java.awt.Dialog; 
     6import java.awt.Font; 
     7import java.awt.GraphicsEnvironment; 
     8import java.awt.Point; 
    39import java.awt.event.WindowEvent; 
    410import java.awt.event.WindowListener; 
     
    1319import java.util.logging.Level; 
    1420import java.util.logging.Logger; 
     21import javax.swing.JDialog; 
    1522 
    1623import javax.swing.JFrame; 
     24import javax.swing.JLabel; 
    1725import javax.swing.JOptionPane; 
    1826import javax.swing.JWindow; 
     27import javax.swing.SwingConstants; 
    1928import javax.swing.UIManager; 
    2029 
     
    136145        if (!verifyProperties(propertiesFile)) 
    137146            System.exit(0); 
    138  
     147        // Display a splash screen. Ticket #199. 
     148        JDialog dlg = createSplashScreen(); 
     149        dlg.setVisible(true); 
     150         
    139151        connect(cadClientProp.getProperty(PROPERTIES.CAD_SIM_HOST.name).trim(), 
    140152                cadClientProp.getProperty(PROPERTIES.CAD_RMI_PORT.name).trim()); 
     
    218230                } 
    219231            }); 
    220  
     232            // Remove the splash screen. 
     233            dlg.dispose(); 
     234             
    221235            theClientScreenView.initWindow(); 
    222236            theClientScreenView.setVisible(false); 
     
    255269                } 
    256270            }); 
    257  
    258271            cadFrame.setVisible(true); 
    259272        } 
     
    269282 
    270283        ensureProperShutdown(); 
    271          
    272          
    273284    } 
    274285 
     
    504515 
    505516    } 
    506  
     517     
     518    /** Create a Splash Screen that displays a "loading" message. 
     519     *  Implements ticket #199  
     520     * @return a JDialog with a "loading" message. 
     521     */ 
     522    private JDialog createSplashScreen() 
     523    { 
     524        final int dialogSize = 300;  // desired width and height of dialog 
     525        // create the dialog 
     526        JDialog dlg = new JDialog(null,"VisiCAD loading",Dialog.ModalityType.MODELESS); 
     527        // make the dialog background a color similar to the login screen background 
     528        dlg.getContentPane().setBackground(new Color(78, 162, 210)); 
     529        // create the text message to be displayed 
     530        JLabel dlgMsg = new JLabel("Just a moment ...", SwingConstants.CENTER);  
     531        // configure the font and color of the text message 
     532        dlgMsg.setFont(new Font("Arial", Font.PLAIN, 22)); 
     533        dlgMsg.setForeground(Color.white); 
     534        // Add the msg to the center of the dialog 
     535        dlg.add(dlgMsg,BorderLayout.CENTER);  
     536        // Set how big we want the dialog to be 
     537        dlg.setSize(dialogSize, dialogSize); 
     538        // Calculate where to place the dialog on the screen 
     539        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 
     540        Point centerPoint = ge.getCenterPoint(); 
     541        int dx = centerPoint.x - dialogSize/2; 
     542        int dy = centerPoint.y - dialogSize/2; 
     543        dlg.setLocation(dx, dy); 
     544        // return the completely built dialog 
     545        return dlg; 
     546    } 
     547     
    507548    public void refresh() { 
    508549        theClientGUI.screen.refreshScreens(); 
Note: See TracChangeset for help on using the changeset viewer.