/** * Initializes this authentication window. * * @param server the server * @param isUserNameEditable indicates if the user name is editable * @param icon the icon to show on the authentication window */ private void init( String userName, char[] password, String server, boolean isUserNameEditable, ImageIcon icon, String errorMessage) { this.server = server; initIcon(icon); if (!isUserNameEditable) this.uinValue = new JLabel(); else this.uinValue = new JTextField(); this.init(); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.enableKeyActions(); this.setResizable(false); /* * Workaround for the following bug: * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4446522 * Need to pack() the window after it's opened in order to obtain the * correct size of our infoTextArea, otherwise window size is wrong and * buttons on the south are cut. */ this.addWindowListener( new WindowAdapter() { public void windowOpened(WindowEvent e) { pack(); removeWindowListener(this); } }); if (OSUtils.IS_MAC) getRootPane().putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE); if (userName != null) { if (uinValue instanceof JLabel) ((JLabel) uinValue).setText(userName); else if (uinValue instanceof JTextField) ((JTextField) uinValue).setText(userName); } if (password != null) passwdField.setText(new String(password)); if (errorMessage != null) { this.infoTextArea.setForeground(Color.RED); this.infoTextArea.setText(errorMessage); } }