List of usage examples for javax.swing JPasswordField setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:org.pentaho.ui.xul.swing.tags.SwingTextbox.java
@Override public Object getManagedObject() { if (super.getManagedObject() == null) { switch (this.type) { case PASSWORD: JPasswordField pass = new JPasswordField((value != null) ? value : ""); pass.setPreferredSize(new Dimension(getWidth(), 20)); pass.setMinimumSize(new Dimension(pass.getPreferredSize().width, pass.getPreferredSize().height)); pass.setEditable(!readonly); textComp = pass;//from w w w . ja v a 2 s. c o m setManagedObject(pass); break; case NUMERIC: default: // regular text if (this.multiline) { textArea = new JTextArea((value != null) ? value : ""); scrollPane = new JScrollPane(textArea); textComp = textArea; setManagedObject(scrollPane); textArea.setEditable(!readonly); this.scrollPane.setMinimumSize(new Dimension(getWidth(), this.height)); // this.scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); } else { textField = new JTextField((value != null) ? value : ""); textField.setPreferredSize(new Dimension(getWidth(), textField.getPreferredSize().height)); textField.setMinimumSize( new Dimension(textField.getPreferredSize().width, textField.getPreferredSize().height)); textField.setEditable(!readonly); setManagedObject(textField); textComp = textField; } // constrin Numeric only here if (this.type == TextType.NUMERIC) { textComp.setDocument(new NumericDocument(min, max)); } textComp.setEnabled(!disabled); break; } textComp.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { oldValue = textComp.getText(); } public void keyReleased(KeyEvent e) { if (oldValue != null && !oldValue.equals(textComp.getText())) { SwingTextbox.this.changeSupport.firePropertyChange("value", oldValue, SwingTextbox.this.getValue()); oldValue = textComp.getText(); } else if (oldValue == null) { // AWT error where sometimes the keyReleased is fired before keyPressed. oldValue = textComp.getText(); } else { logger.debug("Special key pressed, ignoring"); } } public void keyTyped(KeyEvent e) { } }); textComp.setToolTipText(this.getTooltiptext()); // Why do we need this here if we setup oninput in the setOninput // textComp.addKeyListener(new KeyAdapter() { // // public void keyReleased(KeyEvent e) { // invoke(onInput); // } // }); } return super.getManagedObject(); }