1 19 20 package org.netbeans.modules.tasklist.usertasks.editors; 21 22 import java.awt.Component ; 23 24 import javax.swing.DefaultCellEditor ; 25 import javax.swing.JComboBox ; 26 import javax.swing.JTable ; 27 28 31 public class PercentsTableCellEditor extends DefaultCellEditor { 32 private static String [] TAGS = { 33 "0%", "5%", "10%", "15%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%", "60%", "65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%" }; 36 37 40 public PercentsTableCellEditor() { 41 super(new JComboBox (TAGS)); 42 } 43 44 public Component getTableCellEditorComponent(JTable table, Object value, 45 boolean isSelected, int row, int column) { 46 int p = ((Integer ) value).intValue(); 47 ((JComboBox ) editorComponent).setSelectedIndex((p + 4) / 5); 48 return editorComponent; 49 } 50 51 public Object getCellEditorValue() { 52 int index = ((JComboBox ) editorComponent).getSelectedIndex(); 53 return new Integer (index * 5); 54 } 55 } 56 | Popular Tags |