public PasswordDialog(final JFrame owner) { super(owner, "Login", true); setSize(280, 150); user = new JTextField(10); user.addActionListener(this); password = new JPasswordField(10); password.addActionListener(this); JPanel center = new JPanel(); center.setLayout(new GridLayout(3, 2)); center.add(new JLabel("Enter UserName:"******"Enter Password: "******"Submit"); submitButton.setActionCommand("SUBMIT"); submitButton.addActionListener(this); JButton helpButton = new JButton("Help"); south.add(submitButton); south.add(helpButton); helpButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent aEvent) { JOptionPane.showMessageDialog( owner, "Your username and password are the same as those\n" + "you use to access your O'Reilly School of Technology courses. \n"); } }); Container contentPane = getContentPane(); contentPane.add(center, BorderLayout.CENTER); contentPane.add(south, BorderLayout.SOUTH); }
public TextoSenha() { super( "User e Password"); // Ao chamada a classe Frame passa a String como parametro e gera o // titulo da mesma setLayout(new FlowLayout()); // Os objetos se alinham conforma são inseridos campoTexto1 = new JTextField(10); // 10 colunas como campo add(campoTexto1); campoTexto2 = new JTextField("Entra com o texto aqui:"); add(campoTexto2); campoTexto3 = new JTextField("Edição cortada", 21); // texto padrão e 21 colunas campoTexto3.setSize(200, 200); campoTexto3.setEditable(false); // Corta edição add(campoTexto3); campoSenha = new JPasswordField("texto escondido"); // constroi com texto padrão add(campoSenha); // handlers de eventos regustradores TextFieldHandler handler = new TextFieldHandler(); campoTexto1.addActionListener(handler); campoTexto2.addActionListener(handler); campoTexto3.addActionListener(handler); campoSenha.addActionListener(handler); }
/** Creates new form LogIn */ public LogIn() { initComponents(); btnLogIn.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent ke) { if (ke.getKeyCode() == KeyEvent.VK_ENTER) { btnLogIn.doClick(); } } }); txtfldUserName.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { txtfldPassword.requestFocus(); } }); txtfldPassword.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { btnLogIn.requestFocus(); } }); this.setAlwaysOnTop(true); this.setResizable(false); this.setLocationRelativeTo(null); }
/** Adds listeners to the UI components. */ private void initListeners() { user.getDocument().addDocumentListener(this); pass.getDocument().addDocumentListener(this); login.addActionListener(this); user.addActionListener(this); pass.addActionListener(this); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); configButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { config(); } }); encryptionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { encrypt(); } }; encryptedButton.addActionListener(encryptionListener); addWindowListener( new WindowAdapter() { public void windowOpened(WindowEvent e) { requestFocusOnField(); } }); user.addMouseListener( new MouseAdapter() { /** * Fires a property to move the window to the front. * * @see MouseListener#mouseClicked(MouseEvent) */ public void mouseClicked(MouseEvent e) { firePropertyChange(TO_FRONT_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true)); user.requestFocus(); // if (user.getText() != null) // user.selectAll(); } }); pass.addMouseListener( new MouseAdapter() { /** * Fires a property to move the window to the front. * * @see MouseListener#mouseClicked(MouseEvent) */ public void mouseClicked(MouseEvent e) { firePropertyChange(TO_FRONT_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true)); // requestFocusOnField(); } }); }
/** * This method initializes jtxtPasswd * * @return javax.swing.JPasswordField */ private JPasswordField getJtxtPasswd() { if (jtxtPasswd == null) { jtxtPasswd = new JPasswordField(); jtxtPasswd.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jbtnLogin_actionPerformed(e); } }); } return jtxtPasswd; }
/** * This method places all the components onto the panel. * * @param panel (a {@link JPanel} giving the the panel where to place components) */ private void placeComponents(JPanel panel) { panel.removeAll(); panel.setLayout(null); Font fontTitre = new Font("Courier", Font.BOLD, 20); // Adding Labels JLabel addUserTitle = new JLabel(); addUserTitle.setBounds(250, 30, 300, 100); addUserTitle.setFont(fontTitre); addUserTitle.setText("<html>Add a User</html>"); panel.add(addUserTitle); // Adding Buttons returnUsersButton.addActionListener(this); panel.add(returnUsersButton); validateAddUserButton.addActionListener(this); panel.add(validateAddUserButton); // Adding Text Fields addUserNickname.addActionListener(this); addUserNickname.setBounds(250, 100, 200, 25); panel.add(addUserNickname); addUserPassword.addActionListener(this); addUserPassword.setBounds(250, 140, 200, 25); panel.add(addUserPassword); addUserEMail.addActionListener(this); addUserEMail.setBounds(250, 180, 200, 25); panel.add(addUserEMail); // Adding Roles List addUserRole.addItem("Simple User"); addUserRole.addItem("Seller"); addUserRole.addItem("Admin"); addUserRole.setSelectedIndex(0); addUserRole.addActionListener(this); addUserRole.setBounds(250, 220, 200, 25); panel.add(addUserRole); // Adding Logo JLabel image = new JLabel(new ImageIcon("logo.png")); JPanel panelLogo = new JPanel(); panelLogo.setBounds(5, 5, 150, 150); panelLogo.setLayout(new BorderLayout()); panelLogo.add(image, BorderLayout.CENTER); panel.add(panelLogo); }
private LoginPanel() { JLabel messengerLabel = new JLabel("Instant Messaging Provider:"); add( messengerLabel, "x=0,y=0,top=5,left=5,bottom=0,right=5,anchor=nw,fill=n,weightx=0,weighty=0,gridwidth=1,gridheight=1"); Object[] items = new Object[] {TestMessenger.DISPLAY_NAME}; // Object[] items = new Object[] { YahooMessenger.DISPLAY_NAME }; messengerComboBox = new JComboBox(items); add( messengerComboBox, "x=0,y=1,top=0,left=5,bottom=0,right=5,anchor=nw,fill=h,weightx=1,weighty=0,gridwidth=1,gridheight=1"); JLabel userIdLabel = new JLabel("User ID:"); add( userIdLabel, "x=0,y=2,top=5,left=5,bottom=0,right=5,anchor=nw,fill=n,weightx=0,weighty=0,gridwidth=1,gridheight=1"); userIdTextField = new JTextField(); add( userIdTextField, "x=0,y=3,top=0,left=5,bottom=0,right=5,anchor=nw,fill=h,weightx=1,weighty=0,gridwidth=1,gridheight=1"); JLabel passwordLabel = new JLabel("Password:"******"x=0,y=4,top=5,left=5,bottom=0,right=5,anchor=nw,fill=n,weightx=0,weighty=0,gridwidth=1,gridheight=1"); LoginActionListener loginActionListener = new LoginActionListener(); passwordTextField = new JPasswordField(); passwordTextField.addActionListener(loginActionListener); add( passwordTextField, "x=0,y=5,top=0,left=5,bottom=0,right=5,anchor=nw,fill=h,weightx=1,weighty=0,gridwidth=1,gridheight=1"); JButton loginButton = new JButton("Login"); loginButton.addActionListener(loginActionListener); add( loginButton, "x=0,y=6,top=15,left=0,bottom=0,right=5,anchor=ne,fill=n,weightx=0,weighty=0,gridwidth=1,gridheight=1"); JPanel spacerPanel = new JPanel(); add( spacerPanel, "x=0,y=7,top=0,left=0,bottom=0,right=0,anchor=e,fill=b,weightx=1,weighty=1,gridwidth=1,gridheight=1"); }
public AccesoSistema() { super("Ingreso Al Sistema"); setSize(400, 200); // el tamaño de la venta setLocationRelativeTo(null); // es para que la pantalla aparezaca en el centro setLayout(null); setVisible(true); // para mostrar la ventana // esta parte de arriba es el constructor : es el que le premite crear componentes lblimagen.setIcon(getClass().getResource("/Imagenes/Escudo.png")); lblimagen.setBounds(270, 10, 120, 140); this.add(lblimagen); lblusuario = new JLabel("Usuario: "); lblclave = new JLabel("Contraseña: "); txtusuario = new JTextField(""); txtclave = new JPasswordField(""); btningresar = new JButton("Ingresar"); txtusuario.addActionListener(this); txtclave.addActionListener(this); btningresar.addActionListener(this); // Ponemos A Escuchar El Boton btnsalir = new JButton("Salir"); btnsalir.addActionListener(this); lblusuario.setBounds(20, 20, 80, 25); lblclave.setBounds(20, 60, 80, 25); txtusuario.setBounds(130, 20, 120, 25); txtclave.setBounds(130, 60, 120, 25); btningresar.setBounds(20, 100, 120, 25); btnsalir.setBounds(150, 100, 120, 25); lblusuario.setForeground(new Color(0, 0, 0)); // lblusuario.setBorder(BorderFactory.createLineBorder(Color.yellow, WIDTH));//sirve para // mostrar el tamaño del lbl txtusuario.setBackground(Color.WHITE); // este es para darle color a la caja de texto txtusuario.setToolTipText("Ingrese Su Usuario"); // sirve para mostrar mensajes emergentes this.add(lblusuario); this.add(lblclave); this.add(txtusuario); this.add(txtclave); this.add(btningresar); this.add(btnsalir); this.repaint(); }
/** * Prompt for a password, and wait until the user enters it. * * @param prompt The prompt string * @return The new password. */ @SuppressWarnings("serial") private String getPassword(String prompt) { final JDialog input = new JDialog(mainWindow, "Prompt", true); input.setLayout(new FlowLayout()); input.add(new JLabel(prompt)); JPasswordField textField = new JPasswordField(10); input.add(textField); Action okAction = new AbstractAction("OK") { public void actionPerformed(ActionEvent e) { input.dispose(); } }; textField.addActionListener(okAction); JButton ok = new JButton(okAction); input.add(ok); input.pack(); input.setLocationRelativeTo(mainWindow); input.setVisible(true); // BLOCKING return new String(textField.getPassword()); }
/** * Initializes SealObject with input password. Used to decrypt Model Objects * * @param panel Optional component to display on password entry window. Can be null * @return a SealObject initialized with the given password * @throws CEEncryptionErrorException */ protected static SealObject initializeSealedObject(final JPanel panel) throws CEEncryptionErrorException { // CHECK FOR FILE FIRST! INFORM IF FILE NOT FOUND THAT THIS SETS PASSWORD FOR DATABASE try { JPasswordField psswrd = new JPasswordField(10); final Object[] message = {"Enter Decryption Password:"******"OK", "Cancel"}; JOptionPane pane = new JOptionPane( message, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, message[1]); final JDialog diag = pane.createDialog("Database Decryption"); psswrd.addActionListener(disposeDialogActionListener(diag)); diag.setVisible(true); if (psswrd.getPassword() == null || psswrd.getPassword().length == 0 || pane.getValue() == null || pane.getValue().equals(options[1])) throw new InvalidKeyException("User did not enter a password for decryption"); return new SealObject(new String(((JPasswordField) message[1]).getPassword())); } catch (NoSuchAlgorithmException | InvalidKeySpecException | NoSuchPaddingException ex) { Logger.getLogger(ViewerController.class.getName()).log(Level.SEVERE, null, ex); throw new CEEncryptionErrorException("Bad decryption (non-user-caused error)"); } catch (InvalidKeyException ex) { Logger.getLogger(ViewerController.class.getName()).log(Level.WARNING, null, ex); throw new CEEncryptionErrorException("Bad decryption password from user"); } }
public Preference() { super(); setSize(600, 600); setTitle("Preference"); setResizable(false); setDefaultLookAndFeelDecorated(true); setLocationRelativeTo(null); this.setIconImage(new ImageIcon("calendar.png").getImage()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setVisible(true); nom = new JTextField("New Login"); prenom = new JTextField("New Password"); date_naissance = new JTextField("New Password"); email = new JTextField("New Name"); adresse = new JTextField("New Firstname"); ville = new JTextField("New Comments"); code_postal = new JTextField("New code postal"); telephone = new JTextField("New telephone"); mobile = new JTextField("New mobile"); password1 = new JPasswordField("New password"); password2 = new JPasswordField("New password"); nomI = new JTextField("New Login"); prenomI = new JTextField("New Password"); date_naissanceI = new JTextField("New Password"); emailI = new JTextField("New Name"); adresseI = new JTextField("New Firstname"); villeI = new JTextField("New Comments"); code_postalI = new JTextField("New code postal"); telephoneI = new JTextField("New telephone"); mobileI = new JTextField("New mobile"); passwordI1 = new JPasswordField("New password"); passwordI2 = new JPasswordField("New password"); JLabel edit = new JLabel("Pour modifier votre compte, remplir les champs suivants : "); JPanel panneau1 = new JPanel(); panneau1.setLayout(null); panneau1.setPreferredSize(new Dimension(500, 500)); edit.setBounds(100, 20, 900, 50); nom.setBounds(50, 100, 200, 30); prenom.setBounds(300, 100, 200, 30); date_naissance.setBounds(300, 150, 200, 30); email.setBounds(50, 200, 200, 30); password1.setBounds(300, 200, 200, 30); password2.setBounds(300, 200, 200, 30); adresse.setBounds(300, 200, 200, 30); ville.setBounds(50, 300, 450, 40); code_postal.setBounds(50, 300, 450, 40); telephone.setBounds(50, 300, 450, 40); mobile.setBounds(50, 300, 450, 40); effacer_edit.setBounds(1, 420, 580, 40); fermer_edit.setBounds(1, 380, 580, 40); enregistrer_edit.setBounds(1, 460, 580, 40); panneau1.add(edit); panneau1.add(nom); panneau1.add(prenom); panneau1.add(date_naissance); panneau1.add(email); panneau1.add(password1); panneau1.add(password2); panneau1.add(adresse); panneau1.add(ville); panneau1.add(code_postal); panneau1.add(telephone); panneau1.add(mobile); panneau1.add(effacer_edit); panneau1.add(fermer_edit); panneau1.add(enregistrer_edit); onglet.addTab("Edit", new JScrollPane(panneau1)); JLabel inscription = new JLabel("Pour ajouter un compte manuellement, remplir les champs suivants : "); JPanel panneau2 = new JPanel(); panneau2.setLayout(null); panneau2.setPreferredSize(new Dimension(500, 500)); inscription.setBounds(100, 20, 900, 50); nomI.setBounds(50, 100, 200, 30); prenomI.setBounds(50, 300, 450, 40); date_naissanceI.setBounds(50, 300, 450, 40); emailI.setBounds(50, 300, 450, 40); passwordI1.setBounds(300, 100, 200, 30); passwordI2.setBounds(300, 150, 200, 30); adresseI.setBounds(50, 200, 200, 30); villeI.setBounds(300, 200, 200, 30); code_postalI.setBounds(50, 300, 450, 40); telephoneI.setBounds(50, 300, 450, 40); mobileI.setBounds(50, 300, 450, 40); code_postalI.setBounds(50, 300, 450, 40); effacer_inscription.setBounds(1, 420, 580, 40); fermer_inscription.setBounds(1, 380, 580, 40); enregistrer_inscription.setBounds(1, 460, 580, 40); panneau2.add(inscription); panneau2.add(nomI); panneau2.add(prenomI); panneau2.add(date_naissanceI); panneau2.add(emailI); panneau2.add(passwordI1); panneau2.add(passwordI2); panneau2.add(adresseI); panneau2.add(villeI); panneau2.add(code_postalI); panneau2.add(telephoneI); panneau2.add(mobileI); panneau2.add(effacer_inscription); panneau2.add(fermer_inscription); panneau2.add(enregistrer_inscription); onglet.addTab("Inscription", new JScrollPane(panneau2)); fermer_edit.addActionListener(this); enregistrer_edit.addActionListener(this); effacer_edit.addActionListener(this); fermer_inscription.addActionListener(this); enregistrer_inscription.addActionListener(this); effacer_inscription.addActionListener(this); nom.addActionListener(this); prenom.addActionListener(this); date_naissance.addActionListener(this); email.addActionListener(this); password1.addActionListener(this); password2.addActionListener(this); adresse.addActionListener(this); ville.addActionListener(this); code_postal.addActionListener(this); telephone.addActionListener(this); mobile.addActionListener(this); nomI.addActionListener(this); prenomI.addActionListener(this); date_naissanceI.addActionListener(this); emailI.addActionListener(this); passwordI1.addActionListener(this); passwordI2.addActionListener(this); adresseI.addActionListener(this); villeI.addActionListener(this); code_postalI.addActionListener(this); telephoneI.addActionListener(this); mobileI.addActionListener(this); this.getContentPane().add(onglet, BorderLayout.NORTH); this.setVisible(true); }
public void setListeners() { btLogin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { DatabaseUtility dbInstance = new DatabaseUtility(); Object loggedInUserId = dbInstance.execute( "SELECT * FROM users WHERE username = '******' AND password = '******'", "id"); if (loggedInUserId == null && users .stream() .filter( user -> { return user.getUsername().equals(tfUsername.getText()) && user.getPassword() .equals( new BigInteger( 1, md.digest( new String(tfPassword.getPassword()) .getBytes())) .toString(16)); }) .collect(Collectors.toList()) .size() > 0) { loggedInUserId = users .stream() .filter( user -> { return user.getUsername().equals(tfUsername.getText()) && user.getPassword() .equals( new BigInteger( 1, md.digest( new String(tfPassword.getPassword()) .getBytes())) .toString(16)); }) .map(User::getId) .collect(Collectors.toList()) .toArray(new Integer[] {})[0]; Loggo.log("User authentication through XML"); } else { Loggo.log("User authentication through DB"); } if (loggedInUserId != null) { login((int) loggedInUserId); } else { JOptionPane.showMessageDialog(null, "Wrong username and/or password"); } } }); tfUsername.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { btLogin.doClick(); } }); tfPassword.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { btLogin.doClick(); } }); tfUsername.addFocusListener( new FocusListener() { public void focusLost(FocusEvent arg0) {} public void focusGained(FocusEvent arg0) { ((JTextField) arg0.getSource()).selectAll(); } }); tfPassword.addFocusListener( new FocusListener() { public void focusLost(FocusEvent arg0) {} public void focusGained(FocusEvent arg0) { ((JTextField) arg0.getSource()).selectAll(); } }); }
/** * Called by constructors to initialize the dialog. * * @since ostermillerutils 1.00.00 */ @Override protected void dialogInit() { if (labels == null) { setLocale(Locale.getDefault()); } name = new JTextField("", 20); pass = new JPasswordField("", 20); okButton = new JButton(labels.getString("dialog.ok")); cancelButton = new JButton(labels.getString("dialog.cancel")); nameLabel = new JLabel(labels.getString("dialog.name") + " "); passLabel = new JLabel(labels.getString("dialog.pass") + " "); super.dialogInit(); KeyListener keyListener = (new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE || (e.getSource() == cancelButton && e.getKeyCode() == KeyEvent.VK_ENTER)) { pressed_OK = false; PasswordDialog.this.setVisible(false); } if (e.getSource() == okButton && e.getKeyCode() == KeyEvent.VK_ENTER) { pressed_OK = true; PasswordDialog.this.setVisible(false); } } }); addKeyListener(keyListener); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == name) { // the user pressed enter in the name field. name.transferFocus(); } else { // other actions close the dialog. pressed_OK = (source == pass || source == okButton); PasswordDialog.this.setVisible(false); } } }; GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.insets.top = 5; c.insets.bottom = 5; JPanel pane = new JPanel(gridbag); pane.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20)); c.anchor = GridBagConstraints.EAST; gridbag.setConstraints(nameLabel, c); pane.add(nameLabel); gridbag.setConstraints(name, c); name.addActionListener(actionListener); name.addKeyListener(keyListener); pane.add(name); c.gridy = 1; gridbag.setConstraints(passLabel, c); pane.add(passLabel); gridbag.setConstraints(pass, c); pass.addActionListener(actionListener); pass.addKeyListener(keyListener); pane.add(pass); c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.CENTER; JPanel panel = new JPanel(); okButton.addActionListener(actionListener); okButton.addKeyListener(keyListener); panel.add(okButton); cancelButton.addActionListener(actionListener); cancelButton.addKeyListener(keyListener); panel.add(cancelButton); gridbag.setConstraints(panel, c); pane.add(panel); getContentPane().add(pane); pack(); }
public TableDisplay(boolean usePress0, boolean usePress1, IPressControler p) { this.usePress0 = usePress0; this.usePress1 = usePress1; setLayout(new MigLayout()); press = p; getTable().setBorder(BorderFactory.createLoweredBevelBorder()); setBorder(BorderFactory.createLoweredBevelBorder()); // Disable auto resizing getTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); getTable().getColumnModel().getColumn(0).setPreferredWidth(70); getTable().getColumnModel().getColumn(1).setPreferredWidth(70); setEditable(true); abortTime = new AbortTimeWidget(usePress0, usePress1, p.getPressHardware()); setTemp.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { press.setTempreture(getStartingTempreture()); waitingForTemp = true; notes.setText("Waiting for press to \nreach to temperature..."); } }); start.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { ButtonModel aModel = start.getModel(); if (aModel.isArmed() && aModel.isPressed()) { System.out.println("Starting..."); press.onCycleStart(getCurrentCycleConfig()); notes.setText( "Waiting for press to \nreach desired pressure.\nDo not release button until it is safe."); } } }); start.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (isPressReady()) { System.out.println("Press Running"); abortTime.setEnabled(true); notes.setText("Press running.\nHit Abort to stop cycle."); start.setEnabled(false); } else { press.abortCycle(); } } }); save.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { CycleConfig conf = getCurrentCycleConfig(); currentSave = FileSelectionFactory.GetFile(confDir, new XmlFilter()); System.out.println("Using file: " + currentSave); conf.saveToFile(currentSave); try { // validation step conf = new CycleConfig(currentSave); if (conf != null) setCycleConfig(conf); } catch (FileNotFoundException e) { // TODO Auto-generated catch block // e.printStackTrace(); } } }); load.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { File nFile = FileSelectionFactory.GetFile(confDir, new XmlFilter()); if (nFile != null) { CycleConfig conf; try { conf = new CycleConfig(nFile); setCycleConfig(conf); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); return; } currentSave = nFile; } } }); cycleName.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selected = getSelectedFile(); if (selected.equalsIgnoreCase(defaultFileString)) { System.out.println("Using default values"); setCycleConfig(new CycleConfig()); return; } for (int i = 0; i < availibleFiles.size(); i++) { if (selected.equalsIgnoreCase(availibleFiles.get(i).getName())) { System.out.println("Using file: " + availibleFiles.get(i).getAbsolutePath()); try { setCycleConfig(new CycleConfig(availibleFiles.get(i))); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } fm.save(); return; } } } }); lock.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setDataTebleLockState(true); } }); unlock.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireUnlockEvent(); } }); passwd.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { fireUnlockEvent(); } }); ready.setVisible(false); // ready.setEnabled(false); // ready.setColor(Color.green); start.setColor(Color.yellow); JPanel tablePanel = new JPanel(new MigLayout()); JPanel controlsPanel = new JPanel(new MigLayout()); tablePanel.add(new JLabel("Time(min) Temp(F)"), "wrap"); tablePanel.add(getTable(), "wrap"); controlsPanel.add(load); controlsPanel.add(save, "wrap"); controlsPanel.add(new JLabel("Cycle Name")); controlsPanel.add(cycleName, "wrap"); controlsPanel.add(new JLabel("Target Pressure (Tons)")); controlsPanel.add(tons, "wrap"); controlsPanel.add(new JLabel("Current Pressure (Tons)")); controlsPanel.add(currentPressure, "wrap"); controlsPanel.add(new JLabel("Current Temperature (F)")); controlsPanel.add(currentTemp, "wrap"); notes.setText("Start up\nPress 'Set Temp' to begin."); JPanel spacePanel = new JPanel(new MigLayout()); JLabel spaceText = new JLabel(" "); spaceText.setFont(new Font("Dialog", Font.PLAIN, 24)); spacePanel.add(setTemp, "wrap"); spacePanel.add(spaceText); controlsPanel.add(spacePanel); controlsPanel.add(notes, "wrap"); JPanel spacePanel1 = new JPanel(new MigLayout()); JLabel spaceText1 = new JLabel(" "); spaceText1.setFont(new Font("Dialog", Font.PLAIN, 24)); spacePanel1.add(start, "wrap"); spacePanel1.add(spaceText1); controlsPanel.add(spacePanel1); // controlsPanel.add(ready,"wrap"); controlsPanel.add(abortTime, "wrap"); controlsPanel.add(new JLabel("Administrator Mode Enter Password:"******"wrap"); controlsPanel.add(unlock); controlsPanel.add(lock, "wrap"); JPanel interfacePanel = new JPanel(new MigLayout()); interfacePanel.add(tablePanel); interfacePanel.add(controlsPanel); add(interfacePanel, "wrap"); // add(graph,"wrap"); // graph.onCycleStart(0,new CycleConfig(getTableDataMatrix(),getPressureSetpoint())); // Load in default values on startup setCycleConfig(new CycleConfig()); cycleName.addItem(defaultFileString); setEnabled(true); }
public ExercicioQuinze() { // TODO Auto-generated constructor stub super("Todos os eventos aprendidos"); setLayout(new GridLayout(6, 2)); jPanel = new JPanel(); jPanel.setBackground(Color.WHITE); add(jPanel); jLabel = new JLabel("Clique para ver o que aconteçe!"); add(jLabel); jButton = new JButton("Botão"); add(jButton); jCheckBox = new JCheckBox("Letras italicas"); add(jCheckBox); jRadioButton = new JRadioButton("Painel amarelo"); jRadioButton2 = new JRadioButton("Painel Laranja"); add(jRadioButton); add(jRadioButton2); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(jRadioButton); buttonGroup.add(jRadioButton2); jPasswordField = new JPasswordField(); add(jPasswordField); jTextField = new JTextField(); add(jTextField); jComboBox = new JComboBox<String>(nomes); add(jComboBox); jTextArea = new JTextArea("Texto usado para exemplificar o uso da classe JtextArea"); add(new JScrollPane(jTextArea)); jList = new JList<String>(nomes); add(new JScrollPane(jList)); ActionLinesterHandler handler1 = new ActionLinesterHandler(); ItemLinesterHandler handler2 = new ItemLinesterHandler(); ListSelectedLinesterHandler handler3 = new ListSelectedLinesterHandler(); MouseLinesterHandler handler4 = new MouseLinesterHandler(); MouseMotionLinesterHandler handler5 = new MouseMotionLinesterHandler(); KeyLinesterHandler handler6 = new KeyLinesterHandler(); jButton.addActionListener(handler1); jLabel.addMouseListener(handler4); jPanel.addMouseListener(handler4); jCheckBox.addActionListener(handler1); jList.addListSelectionListener(handler3); jComboBox.addItemListener(handler2); jPasswordField.addActionListener(handler1); addMouseMotionListener(handler5); addKeyListener(handler6); jRadioButton.addActionListener(handler1); jRadioButton2.addActionListener(handler1); jTextField.addActionListener(handler1); jTextArea.setEditable(false); }
/** Create the frame. */ public LoginWindow() { setAutoRequestFocus(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 454, 488); contentPane = new JPanel(); contentPane.setForeground(UIManager.getColor("ScrollBar.trackHighlightForeground")); contentPane.setBackground(UIManager.getColor("ScrollBar.track")); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); JTextPane WelcomeMessage = new JTextPane(); WelcomeMessage.setEditable(false); WelcomeMessage.setBackground(UIManager.getColor("Separator.highlight")); WelcomeMessage.setForeground(Color.DARK_GRAY); WelcomeMessage.setFont(new Font("Verdana", Font.BOLD, 11)); WelcomeMessage.setText("\tWelcome to Neighborhood Information Center"); JPanel panel = new JPanel(); panel.setForeground(UIManager.getColor("TextPane.caretForeground")); panel.setBorder(new LineBorder(UIManager.getColor("TextField.background"))); panel.setBackground(UIManager.getColor("TextField.disabledBackground")); JTextPane LoginMessage = new JTextPane(); LoginMessage.setEditable(false); LoginMessage.setText("Please Login to Continue"); LoginMessage.setForeground(SystemColor.controlText); LoginMessage.setFont(new Font("Verdana", Font.BOLD, 11)); LoginMessage.setBackground(UIManager.getColor("TextField.disabledBackground")); LoginField = new JTextField(); LoginField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Login = LoginField.getText(); System.out.println("\n Login-ID is : " + Login); } }); LoginField.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { LoginField.setText(""); LoginField.setForeground(Color.BLACK); } }); LoginField.setBackground(UIManager.getColor("TextField.background")); LoginField.setForeground(SystemColor.scrollbar); LoginField.setText("Login ID"); LoginField.setColumns(10); JButton LoginButton = new JButton("Login"); LoginButton.addActionListener( new ActionListener() { @SuppressWarnings({}) public void actionPerformed(ActionEvent arg0) { Login = LoginField.getText(); System.out.println("\n Login-ID is : " + Login); Password = passwordField.getText(); System.out.println("\n LOGIN BUTTON - Password is : " + Password); // ****************************************************************************** // Set LoginField Back to Normal LoginField.setText(""); LoginField.setBackground(UIManager.getColor("TextField.background")); LoginField.setForeground(SystemColor.scrollbar); LoginField.setText("Login ID"); // Set PasswordField Back to Normal passwordField.setText(""); passwordField.setBackground(UIManager.getColor("TextField.background")); passwordField.setForeground(SystemColor.scrollbar); char c = 0; passwordField.setEchoChar(c); passwordField.setText("Password"); // ******************************************************************************* int Valid = -99; try { int info = 1; Valid = database.getInfo(connection, Login, Password, info); } catch (SQLException e) { // TODO Auto-generated catch block System.out.printf("\n Failed to retrieve \n"); } if (Valid > 0) { System.out.printf(" Successful in Login App. \n"); frame.setVisible(false); userGUI program = new userGUI(); // System.exit(0); } else { UnsuccessfulLogin fail = new UnsuccessfulLogin(Login); fail.NoSuccess(Login); } } }); LoginButton.setBackground(new Color(102, 153, 255)); JTextPane txtpnCreateAnAccount = new JTextPane(); txtpnCreateAnAccount.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { CreateAccount newAcct = new CreateAccount(); newAcct.account(); } }); txtpnCreateAnAccount.setEditable(false); txtpnCreateAnAccount.setText("Create an account"); txtpnCreateAnAccount.setForeground(new Color(25, 25, 112)); txtpnCreateAnAccount.setFont(new Font("Verdana", Font.BOLD, 11)); txtpnCreateAnAccount.setBackground(SystemColor.menu); passwordField = new JPasswordField(); // Setting Password as text passwordField.setBackground(UIManager.getColor("TextField.background")); passwordField.setForeground(SystemColor.scrollbar); passwordField.setText("Password"); char c = 0; passwordField.setEchoChar(c); passwordField.setText("Password"); // Done setting text passwordField.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { char c = 183; passwordField.setForeground(Color.black); passwordField.setEchoChar(c); passwordField.setText(""); } }); passwordField.setBackground(UIManager.getColor("TextField.background")); passwordField.setForeground(SystemColor.scrollbar); passwordField.setText("Password"); passwordField.addActionListener( new ActionListener() { @SuppressWarnings("deprecation") public void actionPerformed(ActionEvent e) { Password = passwordField.getText(); System.out.println("\n Password is : " + Password); } }); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup( gl_panel .createParallelGroup(Alignment.TRAILING) .addGroup( gl_panel .createSequentialGroup() .addContainerGap(60, Short.MAX_VALUE) .addGroup( gl_panel .createParallelGroup(Alignment.TRAILING) .addGroup( gl_panel .createSequentialGroup() .addComponent( txtpnCreateAnAccount, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(63)) .addGroup( gl_panel .createSequentialGroup() .addGroup( gl_panel .createParallelGroup(Alignment.TRAILING, false) .addComponent( LoginMessage, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( LoginButton, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( LoginField, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE) .addComponent(passwordField)) .addGap(42))))); gl_panel.setVerticalGroup( gl_panel .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel .createSequentialGroup() .addGap(30) .addComponent( LoginMessage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(56) .addComponent( LoginField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent( passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(LoginButton) .addPreferredGap(ComponentPlacement.RELATED, 66, Short.MAX_VALUE) .addComponent( txtpnCreateAnAccount, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE) .addGap(47))); panel.setLayout(gl_panel); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane.setHorizontalGroup( gl_contentPane .createParallelGroup(Alignment.TRAILING) .addGroup( gl_contentPane .createSequentialGroup() .addContainerGap() .addGroup( gl_contentPane .createParallelGroup(Alignment.LEADING) .addGroup( gl_contentPane .createSequentialGroup() .addComponent( WelcomeMessage, GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE) .addGap(0)) .addGroup( Alignment.TRAILING, gl_contentPane .createSequentialGroup() .addComponent( panel, GroupLayout.PREFERRED_SIZE, 270, GroupLayout.PREFERRED_SIZE) .addGap(66))))); gl_contentPane.setVerticalGroup( gl_contentPane .createParallelGroup(Alignment.LEADING) .addGroup( gl_contentPane .createSequentialGroup() .addContainerGap() .addComponent( WelcomeMessage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent( panel, GroupLayout.PREFERRED_SIZE, 342, GroupLayout.PREFERRED_SIZE) .addContainerGap(48, Short.MAX_VALUE))); contentPane.setLayout(gl_contentPane); }
/** * Sets window contents to login interface. Handles the user interactions. * * @author Zombori Dániel * @param newParent AdWindow that displays LoginGUI * @param container Method adds elements to this container */ public void show(final AdWindow newParent, Container container) { parent = newParent; if (!created) { ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent event) { if (DataBase.login( textFieldName.getText(), Secret.encrypt(new String(textFieldPassword.getPassword()))) == null) { // bejelentkezés sikertelen labelStatus.setText("Rossz felhasználónév vagy jelszó"); } else { // bejelentkezve labelStatus.setText("Sikeres bejelentkezés"); UserGUI.resetSingleton(); parent.refreshGUI(UserGUI.getSingleton()); } textFieldPassword.setText(""); } }; // grid panelGrid = new JPanel(); panelGrid.setLayout(new GridLayout(6, 1)); labelEmpty = new JLabel(); // név és jelszó textFieldName = new JTextField("Bejelentkezési név", 30); textFieldPassword = new JPasswordField("12345", 30); textFieldName.addActionListener(al); textFieldPassword.addActionListener(al); // gombok btnLogin = new JButton("Bejelentkezés"); btnRegister = new JButton("Regisztráció"); btnLogin.addActionListener(al); btnRegister.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { parent.refreshGUI(RegisterGUI.getSingleton(), true); } }); created = true; } labelStatus = new JLabel("Adja meg adatait", JLabel.CENTER); textFieldPassword.setText(""); // grid panelGrid.add(labelStatus); panelGrid.add(textFieldName); panelGrid.add(textFieldPassword); panelGrid.add(btnLogin); panelGrid.add(labelEmpty); panelGrid.add(btnRegister); // container container.add(panelGrid); }