Methods Summary |
---|
public int | getColumnCount()
return 2;
|
public java.lang.String | getColumnName(int col)
if (0 == col)
return bundle.getString("COL_HEADER_PRINCIPAL"); //NOI18N
if (1 == col)
return bundle.getString("COL_HEADER_DESCRIPTION"); //NOI18N
throw new RuntimeException(bundle.getString("COL_HEADER_ERR_ERR_ERR")); //NOI18N
|
public java.util.Vector | getPrincipals()
return principals;
|
public int | getRowCount()
return principals.size() + 1;
|
public java.lang.Object | getValueAt(int row, int column)
if (row < principals.size())
return ((String[])principals.elementAt(row))[column];
else
return ""; //NOI18N
|
public boolean | isCellEditable(int row, int col)
return true;
|
public static void | main(java.lang.String[] args)
String[] principal = {"user-name", "description"}; //NOI18N
Vector principals = new Vector();
principals.add(principal);
javax.swing.JTable table = new javax.swing.JTable(new PrincipalTableModel(principals));
javax.swing.JScrollPane sp = new javax.swing.JScrollPane(table);
/*
javax.swing.JFrame f = new javax.swing.JFrame();
f.addWindowListener(new CloseTestWindow(principals));
f.getContentPane().add(sp);
f.show();
*/
final JDialog d = new JDialog();
d.setSize(200, 150);
d.getContentPane().setLayout(new BorderLayout());
d.getContentPane().add(sp, BorderLayout.CENTER);
JButton okButton = new JButton("OK"); //NOI18N
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
d.setVisible(false);
d.dispose();
}
});
JPanel buttonsPane = new JPanel();
buttonsPane.add(okButton);
d.getContentPane().add(buttonsPane, BorderLayout.SOUTH);
d.setVisible(true);
|
public void | setValueAt(java.lang.Object val, int row, int col)
// System.out.println("val = " + (String)val + ", row = " + new Integer(row) + ", col = " + new Integer(col));
int pre = principals.size();
if (row >= pre) {
String[] newPrincipal = new String[2];
principals.add(newPrincipal);
}
if (!(val instanceof String)) {
throw new IllegalArgumentException();
}
String input = (String)val;
if (col == 0 && (input == null || input.trim().length() == 0)) {
Reporter.info("row has no value (" + input + ")"); //NOI18N
principals.removeElementAt(row);
} else {
Reporter.info("(" + input.trim() + ")"); //NOI18N
((String[])principals.elementAt(row))[col] = input.trim();
}
if (principals.size() < pre) {
// System.out.println("fireTableStructureChanged");
fireTableStructureChanged();
}
|