diff options
| author | O'Shea <osheas1@wit.edu> | 2020-12-10 14:03:54 -0500 |
|---|---|---|
| committer | O'Shea <osheas1@wit.edu> | 2020-12-10 14:03:54 -0500 |
| commit | cca61c9f562d2c9e2be13ec16abe134d209b54e3 (patch) | |
| tree | 3f957b579c45d0536e7e1740acdb0cdbc773f9f4 /src/demonstration/LoginDEMO.java | |
| parent | 690bbba9550e2644e48db44fb94d4df86494a34e (diff) | |
Final implementation, ready for presentation!
Diffstat (limited to 'src/demonstration/LoginDEMO.java')
| -rw-r--r-- | src/demonstration/LoginDEMO.java | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/src/demonstration/LoginDEMO.java b/src/demonstration/LoginDEMO.java new file mode 100644 index 0000000..d67f852 --- /dev/null +++ b/src/demonstration/LoginDEMO.java @@ -0,0 +1,158 @@ +package demonstration; + +@SuppressWarnings( "javadoc" ) +public class LoginDEMO extends javax.swing.JFrame { + + /** + * Creates new form loginGUI + */ + + public String ip ; + public String username ; + public boolean done ; + + public String getIP() + { + return this.ip ; + } + + public String getUsername() + { + return this.username ; + } + + public boolean isDone() + { + return this.done ; + } + + public LoginDEMO() { + initComponents(); + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code"> + private void initComponents() { + + jPasswordField1 = new javax.swing.JPasswordField(); + jLabel1 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("java chat login DEMO"); + setAlwaysOnTop(true); + setResizable(false); + + jPasswordField1.setEditable(false); + jPasswordField1.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jPasswordField1.setText("12.34.56.78"); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText("Enter Server's IP:"); + + jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jTextField1.setToolTipText(""); + jTextField1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField1ActionPerformed(evt); + } + }); + + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setText("Enter Username:"); + + jLabel3.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N + jLabel3.setText("username must be at least one character"); + jLabel3.setEnabled(false); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(43, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jTextField1) + .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)) + .addGap(40, 40, 40)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel3) + .addContainerGap()))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(40, 40, 40) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3) + .addContainerGap(22, Short.MAX_VALUE)) + ); + + pack(); + setLocationRelativeTo(null); + }// </editor-fold> + + private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { + this.ip = "74.69.251.12" ; + if( jTextField1.getText().isBlank() ) + { + jLabel3.setEnabled( true ); + } + else + { + this.username = jTextField1.getText() ; + this.done = true ; + dispose(); + } + } + + public static void main(String args[]) { + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new LoginDEMO().setVisible(true); + } + }); + } + + // Variables declaration - do not modify + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPasswordField jPasswordField1; + private javax.swing.JTextField jTextField1; + // End of variables declaration +} |
