File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Java Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java Swing" Watch "Java Swing" New topic
Author

Java Swing

Arun Kumarr Jeyaseelan
Greenhorn

Joined: Nov 25, 2004
Posts: 2
I am rendering my JTable with JPassword Field,but it is rendered as password field only after I am typed the value, but while I am entering the value in the rendered cell it is not showing as '***' instead it is showing as 'abc'(For eg.).How can I achieve it while typing itself.
If anybody can help me please let me know.
sasi kala
Ranch Hand

Joined: Dec 17, 2004
Posts: 68
Hi Arun Kumar,

Add this below method to your Editor class

public Object getCellEditorValue()
{
String label = new String(password.getPassword());
System.out.println("Password is: "+label);
return label;
}




I am sending some code for further help:
1) Add this line to paswordfiled column

table.getColumnModel().getColumn(0).setCellEditor(new PasswordEditor(new JCheckBox()));

2) Use this editor class

class PasswordEditor extends javax.swing.DefaultCellEditor {
protected JPasswordField password;

public PasswordEditor(JCheckBox checkBox) {
super(checkBox);

password = new JPasswordField();
password.setOpaque(true);
}

public java.awt.Component getTableCellEditorComponent(JTable table, Object value,boolean isSelected, int row, int column)
{
String label = (value ==null) ? "" : value.toString();
password.setText( label );
return password;
}

public Object getCellEditorValue()
{
String label = new String(password.getPassword());
System.out.println("Password is: "+label);
return label;
}
}


All The Best.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Swing