/** * Handles the UI feedback for an incorrect credentials */ public void incorrectPassword() { Preconditions.checkState(SwingUtilities.isEventDispatchThread(), "Must execute on EDT."); password.setBackground(Themes.currentTheme.invalidDataEntryBackground()); } }
private void addLabelArea() { labelPanel.setLayout(new GridLayout(3, 1)); Border labelsPadding = BorderFactory.createEmptyBorder(0, 0, 15, 0); labelPanel.setBorder(labelsPadding); deviceLabel = new JLabel(AgentConstants.APP_PUBLIC_NAME.toUpperCase()); Icon icon = new ImageIcon(TrayProcess.createImage(AgentConstants.ICON24_PATH, AgentConstants.ICON_DESCRIPTION)); deviceLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); deviceLabel.setIcon(icon); deviceLabel.setIconTextGap(10); deviceLabel.setFont(new Font(null, Font.BOLD, 15)); passcodeLabel = new JLabel(LocalizedLogger.getLocalizedMessage("DIALOG_ENTER_PIN")); passcodeField = new JPasswordField(3); passcodeField.setEditable(false); passcodeField.setBackground(Color.white); labelPanel.add(deviceLabel, BorderLayout.NORTH); labelPanel.add(passcodeLabel, BorderLayout.CENTER); labelPanel.add(passcodeField, BorderLayout.SOUTH); }
private void addInputArea() { labelPanel.setLayout(new GridLayout(3, 1)); Border labelsPadding = BorderFactory.createEmptyBorder(0, 0, 15, 0); labelPanel.setBorder(labelsPadding); deviceLabel = new JLabel(AgentConstants.APP_PUBLIC_NAME.toUpperCase()); Icon icon = new ImageIcon(TrayProcess.createImage(AgentConstants.ICON24_PATH, AgentConstants.ICON_DESCRIPTION)); deviceLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); deviceLabel.setIcon(icon); deviceLabel.setIconTextGap(10); deviceLabel.setFont(new Font(null, Font.BOLD, 15)); passcodeLabel = new JLabel(LocalizedLogger.getLocalizedMessage("DIALOG_ENTER_PASSPHRASE")); passcodeField = new JPasswordField(); passcodeField.requestFocusInWindow(); passcodeField.setBackground(Color.white); labelPanel.add(deviceLabel, BorderLayout.NORTH); labelPanel.add(passcodeLabel, BorderLayout.CENTER); labelPanel.add(passcodeField, BorderLayout.SOUTH); }
/** * Trigger any UI updates */ private void updateModel() { // Reset the credentials background password.setBackground(Themes.currentTheme.dataEntryBackground()); getModel().get().setPassword(password.getPassword()); }
private void setProxyChainPromptEnabled(boolean isEnabled) { txtProxyChainPassword.setEnabled(!isEnabled); chkShowPassword.setEnabled(!isEnabled); Color color = Color.WHITE; if (isEnabled) { txtProxyChainPassword.setText(""); color = panelProxyChain.getBackground(); } txtProxyChainPassword.setBackground(color); }
private JPasswordField password; private String typedPassword; private final String defaultPassword = "yourDesiredPassword"; public void createPasswordField(){ password = new JPasswordField(30); password.setBounds(280, 240, 90, 20); password.setEchoChar('*'); password.setBackground(Color.white); password.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { password = (JPasswordField) e.getSource(); char [] tempPass = password.getPassword(); typedPassword = new String(tempPass); if (!typedPassword.equals(defaultPassword)){ JOptionPane.showMessageDialog(null, "Your password is not correct", "Stack Over Flow example", JOptionPane.ERROR_MESSAGE); } } }); }
private void setWidgetActivation() { passwordField.setEnabled(requirePasswordCheckBox.isSelected()); final Color backGround = passwordField.isEnabled() ? portField.getBackground() : getBackground(); passwordField.setBackground(backGround); }
@Override public void installUI (JComponent c) { super.installUI (c); JPasswordField passwordField = (JPasswordField) c; passwordField.setOpaque (false); passwordField.setBorder (BorderFactory.createEmptyBorder (5, 2, 10, 0)); passwordField.setBackground (MaterialColors.LIGHT_BLUE_400); this.focusedBackground = passwordField.getBackground (); this.unfocusedBackground = MaterialColors.GRAY_200; this.focusedSelectionBackground = MaterialColors.bleach (focusedBackground, 0.3f); this.unfocusedSelectionBackground = unfocusedBackground; }
private void setProxyChainAuthEnabled(boolean isEnabled) { txtProxyChainRealm.setEnabled(isEnabled); txtProxyChainUserName.setEnabled(isEnabled); txtProxyChainPassword.setEnabled(isEnabled); // ZAP: Added prompt option chkProxyChainPrompt.setEnabled(isEnabled); chkShowPassword.setEnabled(isEnabled); if (chkProxyChainPrompt.isSelected()) { setProxyChainPromptEnabled(true); } Color color = Color.WHITE; if (!isEnabled) { // ZAP: Added prompt option color = panelProxyChain.getBackground(); } txtProxyChainRealm.setBackground(color); txtProxyChainUserName.setBackground(color); txtProxyChainPassword.setBackground(color); }
@Override public void paintSafely (Graphics g) { JPasswordField c = (JPasswordField) getComponent (); g = MaterialDrawingUtils.getAliasedGraphics (g); if (getComponent ().hasFocus ()) { c.setBackground (focusedBackground); c.setSelectionColor (focusedSelectionBackground); } else { c.setBackground (unfocusedBackground); c.setSelectionColor (unfocusedSelectionBackground); } int x = getComponent ().getInsets ().left; int y = getComponent ().getInsets ().top; int w = getComponent ().getWidth () - getComponent ().getInsets ().left - getComponent ().getInsets ().right; g.setColor (c.getBackground ()); g.fillRect (x, c.getHeight () - y, w, 2); super.paintSafely (g); }
passwordField.setBackground(Themes.currentTheme.dataEntryBackground());