Java 类javax.swing.table.TableCellEditor 实例源码

项目:incubator-netbeans    文件:TableUISupport.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if (column == 2){
        if (getModel() instanceof TableClassNamesModel) {
            TableClassNamesModel model = (TableClassNamesModel)getModel();
            Table table = model.getTableAt(row);
            DisabledReason dr = table.getDisabledReason();
            boolean existing = dr instanceof Table.ExistingDisabledReason;
            if (existing){
                return new DefaultCellEditor(new JComboBox(new UpdateType[]{UpdateType.UPDATE, UpdateType.RECREATE}));
            } else {
                return new DefaultCellEditor(new JComboBox(new UpdateType[]{UpdateType.NEW}));
            }
        }
    } 
    return super.getCellEditor(row, column);
}
项目:incubator-netbeans    文件:CodeSetupPanel.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if(showParamTypes) {
        String paramName = (String) tableModel.getValueAt(row, 0);
        Class type = (column == 2) ? (Class) tableModel.getValueAt(row, 1) : Boolean.class;

        if (Enum.class.isAssignableFrom(type)) {
            JComboBox combo = new JComboBox(type.getEnumConstants());
            return new DefaultCellEditor(combo);
        } else if (type == Boolean.class || type == Boolean.TYPE) {
            JCheckBox cb = new JCheckBox();
            cb.setHorizontalAlignment(JLabel.CENTER);
            cb.setBorderPainted(true);
            return new DefaultCellEditor(cb);
        } else if (paramName.toLowerCase().contains(Constants.PASSWORD)) {
            return new DefaultCellEditor(new JPasswordField());
        }
    }

    return super.getCellEditor(row, column);
}
项目:QN-ACTR-Release    文件:AllBlockingRegionsPanel.java   
/**
 * Returns an appropriate editor for the cell specified by
 * <code>row</code> and <code>column</code>. If the
 * <code>TableColumn</code> for this column has a non-null editor,
 * returns that.  If not, finds the class of the data in this
 * column (using <code>getColumnClass</code>)
 * and returns the default editor for this type of data.
 *
 * @param row    the row of the cell to edit, where 0 is the first row
 * @param column the column of the cell to edit,
 *               where 0 is the first column
 * @return the editor for this cell;
 *         if <code>null</code> return the default editor for
 *         this type of cell
 */
@Override
public TableCellEditor getCellEditor(int row, int column) {
    switch (column) {
        case 0:
            return new BlockingTableEditor();
        case 1:
            return super.getDefaultEditor(String.class);
        case 2:
            return super.getDefaultEditor(Boolean.class);
        case 3:
            return new ButtonCellEditor(delete);
        default:
            return null;
    }
}
项目:QN-ACTR-Release    文件:ImagedComboBoxCellEditorFactory.java   
/**
 * Returns an instance of editor, given search key for elements to be shown
 * @param data vector with search's key for elements to be shown
 */
public TableCellEditor getEditor(List data) {
    if (editor == null) {
        editor = new ImagedComboEditor();
    }
    LabelRenderer[] rend;
    if (allowsNull) {
        rend = new LabelRenderer[data.size() + 1];
        rend[0] = getDrawComponent(null);
        for (int i = 1; i < rend.length; i++) {
            rend[i] = getDrawComponent(data.get(i - 1));
        }
    } else {
        rend = new LabelRenderer[data.size()];
        for (int i = 0; i < data.size(); i++) {
            rend[i] = getDrawComponent(data.get(i));
        }
    }
    editor.setData(rend);
    return editor;
}
项目:openjdk-jdk10    文件:OldJTable.java   
public TableColumn addColumn(Object columnIdentifier, int width,
                             TableCellRenderer renderer,
                             TableCellEditor editor, List columnData) {
    checkDefaultTableModel();

    // Set up the model side first
    DefaultTableModel m = (DefaultTableModel)getModel();
    m.addColumn(columnIdentifier, columnData.toArray());

    // The column will have been added to the end, so the index of the
    // column in the model is the last element.
    TableColumn newColumn = new TableColumn(
            m.getColumnCount()-1, width, renderer, editor);
    super.addColumn(newColumn);
    return newColumn;
}
项目:AgentWorkbench    文件:ComponentTypeDialog.java   
/**
 * Rename domain in components.
 *
 * @param oldDomainName the old domain name
 * @param newDomainName the new domain name
 */
public void renameDomainInComponents(String oldDomainName, String newDomainName) {

    DefaultTableModel dtmComponents = this.getTableModel4ComponentTypes();
    int column = getColumnHeaderIndexComponents(COL_Domain);

    // --- Get the component type definitions from table ----
    JTable jtComponents = this.getJTable4ComponentTypes();
    // --- Confirm, apply changes in table ------------------                       
    TableCellEditor tceComponents = jtComponents.getCellEditor();
    if (tceComponents!=null) {
        tceComponents.stopCellEditing();
    }
    for(int row=0; row<dtmComponents.getRowCount(); row++){
        String currValue = (String) dtmComponents.getValueAt(row, column);
        if (currValue.equals(oldDomainName)) {
            dtmComponents.setValueAt(newDomainName, row, column);   
        }
    }
    this.setTableCellEditor4DomainsInComponents(null);
}
项目:jmt    文件:ImagedComboBoxCellEditorFactory.java   
/**
 * Returns an instance of editor, given search key for elements to be shown
 * @param data array with search's key for elements to be shown
 */
public TableCellEditor getEditor(Object[] data) {
    if (editor == null) {
        editor = new ImagedComboEditor();
    }
    LabelRenderer[] rend;
    if (allowsNull) {
        rend = new LabelRenderer[data.length + 1];
        rend[0] = getDrawComponent(null);
        for (int i = 1; i < rend.length; i++) {
            rend[i] = getDrawComponent(data[i - 1]);
        }
    } else {
        rend = new LabelRenderer[data.length];
        for (int i = 0; i < data.length; i++) {
            rend[i] = getDrawComponent(data[i]);
        }
    }
    editor.setData(rend);
    return editor;
}
项目:jdk8u-jdk    文件:XMBeanAttributes.java   
@Override
public final boolean editCellAt(final int row, final int column, EventObject e) {
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("editCellAt(row="+row+", col="+column+
                ", e="+e+")");
    }
    if (JConsole.isDebug()) {
        System.err.println("edit: "+getValueName(row)+"="+getValue(row));
    }
    boolean retVal = super.editCellAt(row, column, e);
    if (retVal) {
        final TableCellEditor tableCellEditor =
                getColumnModel().getColumn(column).getCellEditor();
        if (tableCellEditor == valueCellEditor) {
            ((JComponent) tableCellEditor).requestFocus();
        }
    }
    return retVal;
}
项目:rapidminer    文件:EditableTableHeader.java   
public void removeEditor() {
    TableCellEditor editor = getCellEditor();
    if (editor != null) {
        editor.removeCellEditorListener(this);

        requestFocus();
        remove(editorComp);

        int index = getEditingColumn();
        Rectangle cellRect = getHeaderRect(index);

        setCellEditor(null);
        setEditingColumn(-1);
        editorComp = null;

        repaint(cellRect);
    }
}
项目:Pogamut3    文件:VariableTable.java   
public void editingStopped(ChangeEvent e) {
    synchronized(mutex) {
        if (recursion) return;
        recursion = true;
    }
    try {
        // Take in the new value
        TableCellEditor editor = getCellEditor();
        if (editor != null) {
            editor.stopCellEditing();
            Object value = editor.getCellEditorValue();
            setValueAt(value, editingRow, editingColumn);
            removeEditor();
        }
    } finally {
        recursion = false;
    }
}
项目:jmt    文件:GraphPanel.java   
/**
 * Returns an appropriate editor for the cell specified by
 * <code>row</code> and <code>column</code>. If the
 * <code>TableColumn</code> for this column has a non-null editor,
 * returns that.  If not, finds the class of the data in this
 * column (using <code>getColumnClass</code>)
 * and returns the default editor for this type of data.
 * <p/>
 *
 * @param row    the row of the cell to edit, where 0 is the first row
 * @param column the column of the cell to edit,
 *               where 0 is the first column
 * @return the editor for this cell;
 *         if <code>null</code> return the default editor for
 *         this type of cell
 * @see javax.swing.DefaultCellEditor
 */
@Override
public TableCellEditor getCellEditor(int row, int column) {
    LinesTableColumn columnType = getColumnType(column);
    switch (columnType) {
        case CLASS:
            return classEditor;
        case STATION:
            if (currentIndex.equals(ExactConstants.INDICES_TYPES[3])) {
                return uStationsEditor;
            } else {
                return stationsEditor;
            }
        case ALGORITHM:
            return algorithmEditor;
    }
    return null;
}
项目:JavaGraph    文件:PropertiesDialog.java   
/**
 * Lazily creates and returns a button labelled OK that signals the editors
 * to stop editing. This makes sure that any partially edited result is not
 * lost.
 */
JButton getOkButton() {
    if (this.okButton == null) {
        this.okButton = new JButton("OK");
        this.okButton.addActionListener(new CloseListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                TableCellEditor editor = getInnerTable().getCellEditor();
                if (editor == null || editor.stopCellEditing()) {
                    super.actionPerformed(e);
                }
            }
        });
    }
    return this.okButton;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:TestsetComponent.java   
public TestsetComponent(TestExecution testExecution) {
    this.testExecution = testExecution;
    testSetTable = new XTable() {

        @Override
        public Component prepareEditor(TableCellEditor editor, int row, int column) {
            Component c = super.prepareEditor(editor, row, column);
            if (c instanceof JCheckBox) {
                JCheckBox b = (JCheckBox) c;
                b.setBackground(getSelectionBackground());
                b.setBorderPainted(true);
            }
            return c;
        }

    };
    toolBar = new TestSetToolBar(this);
    validator = new TestSetValidator(testSetTable);
    popupMenu = new TestSetPopupMenu(this);
    quickSettings = new QuickSettings(this);
    executePopupMenu = new ExecutePopupMenu();
    init();
}
项目:jmt    文件:AllBlockingRegionsPanel.java   
/**
 * Returns an appropriate editor for the cell specified by
 * <code>row</code> and <code>column</code>. If the
 * <code>TableColumn</code> for this column has a non-null editor,
 * returns that.  If not, finds the class of the data in this
 * column (using <code>getColumnClass</code>)
 * and returns the default editor for this type of data.
 *
 * @param row    the row of the cell to edit, where 0 is the first row
 * @param column the column of the cell to edit,
 *               where 0 is the first column
 * @return the editor for this cell;
 *         if <code>null</code> return the default editor for
 *         this type of cell
 */
@Override
public TableCellEditor getCellEditor(int row, int column) {
    switch (column) {
        case 0:
            return new BlockingTableEditor();
        case 1:
            return super.getDefaultEditor(String.class);
        case 2:
            return super.getDefaultEditor(Boolean.class);
        case 3:
            return super.getDefaultEditor(String.class);
        case 4:
            return super.getDefaultEditor(Boolean.class);
        case 5:
            return super.getDefaultEditor(String.class);
        case 6:
            return super.getDefaultEditor(Boolean.class);
        case 7:
            return new ButtonCellEditor(delete);
        default:
            return null;
    }
}
项目:jmt    文件:ClassesPanel.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if (column == 1) {
        return comboEditor.getEditor(classTypes);
    } else if (column == 5) {
        if (getValueAt(row, 4) != null) {
            return new ButtonCellEditor(new JButton(editDistribution));
        } else {
            return getDefaultEditor(String.class);
        }
    } else if (column == 6) {
        return new ButtonCellEditor(new JButton(deleteClass));
    } else {
        return getDefaultEditor(getModel().getColumnClass(column));
    }
}
项目:ramus    文件:TableCellEditorFactory.java   
private TableCellEditor createBaseQualifierEditor() {
    List<Qualifier> qualifiers = engine.getQualifiers();
    Collections.sort(qualifiers, new Comparator<Qualifier>() {
        @Override
        public int compare(Qualifier o1, Qualifier o2) {
            return collator.compare(o1.getName(), o2.getName());
        }
    });

    JComboBox box = new JComboBox();

    box.addItem(null);
    for (Qualifier qualifier : qualifiers)
        box.addItem(qualifier);

    return new DefaultCellEditor(box);
}
项目:jmt    文件:InputSectionPanel.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if (column == 1) {
        if (data.getStationType(stationKey).equals(STATION_TYPE_SERVER)) {
            if (data.getStationQueueStrategy(stationKey).equals(STATION_QUEUE_STRATEGY_PREEMPTIVE)) {
                return ComboBoxCellEditor.getEditorInstance(serverPreemptiveQueuePolicies);
            } else {
                return ComboBoxCellEditor.getEditorInstance(serverNonPreemptiveQueuePolicies);
            }
        } else {
            return ComboBoxCellEditor.getEditorInstance(otherNonPreemptiveQueuePolicies);
        }
    } else if (column == 2) {
        return ComboBoxCellEditor.getEditorInstance(dropRules);
    } else {
        return super.getCellEditor(row, column);
    }
}
项目:incubator-netbeans    文件:TreeTable.java   
@Override
public TableCellEditor getDefaultEditor(Class columnClass) {
    if (!edCreated && (columnClass == TreeTableModelAdapter.class)) {
        //Creating this editor in the constructor can take > 100ms even
        //on a very fast machine, so do it lazily here to improve 
        //performance of creating a TreeTable
        setDefaultEditor(TreeTableModelAdapter.class, new TreeTableCellEditor());
        edCreated = true;
    }

    return super.getDefaultEditor(columnClass);
}
项目:incubator-netbeans    文件:SheetTable.java   
/** Returns a reference to the static editor shared among all instances
 * of SheetTable */
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if( 0 == column ) {
        TableCellEditor res = getCustomEditor( row );
        if( null != res )
            return res;
    }

    return getEditor();
}
项目:incubator-netbeans    文件:EditablePropertyDisplayer.java   
private void cancelEditor() {
    if (getInplaceEditor() != null) {
        java.awt.Container parent = getParent();
        while (parent != null && !(parent instanceof javax.swing.JTable)) {
            parent = parent.getParent();
        }
        if (parent != null) {
            TableCellEditor tce = ((javax.swing.JTable) parent).getCellEditor();
            if (tce != null) {
                tce.cancelCellEditing();
            }
        }
    }
}
项目:QN-ACTR-Release    文件:MeasurePanel.java   
/**
 * called by the Wizard before when switching to another panel
 */
@Override
public void lostFocus() {
    // Aborts editing of table
    TableCellEditor editor = measureTable.getCellEditor();
    if (editor != null) {
        editor.stopCellEditing();
    }
}
项目:jmt    文件:TimingSectionPanel.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if (column == 3) {
        return ComboBoxCellEditor.getEditorInstance(timingStrategies);
    } else if (column == 5) {
        return distributionEditor;
    } else if (column == 8) {
        return deleteEditor;
    } else {
        return super.getCellEditor(row, column);
    }
}
项目:Logisim    文件:AttrTable.java   
void setAttrTableModel(AttrTableModel value) {
    if (attrModel != value) {
        TableCellEditor editor = table.getCellEditor();
        if (editor != null) {
            editor.cancelCellEditing();
        }
        attrModel.removeAttrTableModelListener(this);
        attrModel = value;
        attrModel.addAttrTableModelListener(this);
        fireTableChanged();
    }
}
项目:ramus    文件:TableCellEditorFactory.java   
private TableCellEditor createFontTypeEditor() {
    JComboBox box = new JComboBox();
    box.addItem(null);
    box.addItem(BOLD);
    box.addItem(ITALIC);
    box.addItem(BOLD_ITALIC);

    return new DefaultCellEditor(box);
}
项目:openjdk-jdk10    文件:XMBeanAttributes.java   
public void cancelCellEditing() {
    if (LOGGER.isLoggable(Level.TRACE)) {
        LOGGER.log(Level.TRACE, "Cancel Editing Row: "+getEditingRow());
    }
    final TableCellEditor tableCellEditor = getCellEditor();
    if (tableCellEditor != null) {
        tableCellEditor.cancelCellEditing();
    }
}
项目:incubator-netbeans    文件:DelegatingCellEditor.java   
@Override
public Object getCellEditorValue() {
    if (currentEditor != null) {
        return currentEditor.getCellEditorValue();
    }
    if (canceledEditorRef != null) {
        TableCellEditor canceledEditor = canceledEditorRef.get();
        if (canceledEditor != null) {
            return canceledEditor.getCellEditorValue();
        }
    }
    Exceptions.printStackTrace(new IllegalStateException("No current editor."));
    return null;
}
项目:incubator-netbeans    文件:DelegatingCellEditor.java   
@Override
public boolean isCellEditable(EventObject anEvent) {
    if (!(anEvent.getSource() instanceof Outline)) {
        return false;
    }
    Outline outline = (Outline) anEvent.getSource();
    int row;
    if (anEvent instanceof MouseEvent) {
        MouseEvent event = (MouseEvent) anEvent;
        Point p = event.getPoint();
        // Locate the editor under the event location
        //int column = outline.columnAtPoint(p);
        row = outline.rowAtPoint(p);
    } else {
        row = outline.getSelectedRow();
    }
    Node n = DelegatingCellRenderer.getNodeAt(outline, row);
    if (n instanceof TreeModelNode) {
        TreeModelNode tmn = (TreeModelNode) n;
        TableRendererModel trm = tmn.getModel();
        try {
            boolean canEdit = trm.canEditCell(tmn.getObject(), columnID);
            if (canEdit) {
                TableCellEditor tce = trm.getCellEditor(tmn.getObject(), columnID);
                canEdit = tce.isCellEditable(anEvent);
                return canEdit;
            }
        } catch (UnknownTypeException ex) {
        }
    }
    return defaultEditor.isCellEditable(anEvent);
}
项目:incubator-netbeans    文件:DelegatingCellEditor.java   
@Override
public boolean shouldSelectCell(EventObject anEvent) {
    if (!(anEvent.getSource() instanceof Outline)) {
        return false;
    }
    Outline outline = (Outline) anEvent.getSource();
    if (!(anEvent instanceof MouseEvent)) {
        return false;
    }
    MouseEvent event = (MouseEvent) anEvent;
    Point p = event.getPoint();

    // Locate the editor under the event location
    //int column = outline.columnAtPoint(p);
    int row = outline.rowAtPoint(p);
    Node n = DelegatingCellRenderer.getNodeAt(outline, row);
    if (n instanceof TreeModelNode) {
        TreeModelNode tmn = (TreeModelNode) n;
        TableRendererModel trm = tmn.getModel();
        try {
            if (trm.canEditCell(tmn.getObject(), columnID)) {
                TableCellEditor editor = trm.getCellEditor(tmn.getObject(), columnID);
                if (editor != null) {
                    return editor.shouldSelectCell(anEvent);
                }
            }
        } catch (UnknownTypeException ex) {
        }
    }
    return defaultEditor.shouldSelectCell(anEvent);
}
项目:incubator-netbeans    文件:DelegatingCellEditor.java   
@Override
public void cancelCellEditing() {
    if (currentEditor != null) {
        currentEditor.cancelCellEditing();
        canceledEditorRef = new WeakReference<TableCellEditor>(currentEditor);
        currentEditor = null;
        return ;
    }
}
项目:jmt    文件:LDStrategyEditor.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if (column == 2) {
        return distributionEditor;
    } else if (column == 5) {
        return new ButtonCellEditor(new JButton(deleteRange));
    } else {
        return super.getCellEditor(row, column);
    }
}
项目:jmt    文件:BlockingRegionGroupPanel.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if (column == 5) {
        return new ButtonCellEditor(new JButton(editMemberClasses));
    } else if (column == 6) {
        return new ButtonCellEditor(new JButton(deleteGroup));
    } else {
        return super.getCellEditor(row, column);
    }
}
项目:incubator-netbeans    文件:Models.java   
@Override
public TableCellEditor getCellEditor(Object node, String columnID) throws UnknownTypeException {
    if (tableRendererModel != null) {
        return tableRendererModel.getCellEditor(node, columnID);
    } else {
        return null;
    }
}
项目:QN-ACTR-Release    文件:InputSectionPanel.java   
/**
 * called by the Wizard before when switching to another panel
 */
@Override
public void lostFocus() {
    // Aborts editing of table
    TableCellEditor editor = queueTable.getCellEditor();
    if (editor != null) {
        editor.stopCellEditing();
    }
}
项目:incubator-netbeans    文件:TableRendererTest.java   
@Override
public TableCellEditor getCellEditor(Object node, String columnID) throws UnknownTypeException {
    if (!(Integer.parseInt((String) node) % 3 == 0)) {
        throw new IllegalStateException("Trying to get editor even if we can not provide it node = "+node);
    }
    return new CellEditorImpl(node, columnID);
}
项目:incubator-netbeans    文件:ProfilerTable.java   
public Component prepareEditor(TableCellEditor editor, int row, int column) {
    Component c = super.prepareEditor(editor, row, column);

    c.setForeground(getSelectionForeground());
    c.setBackground(getSelectionBackground());

    return c;
}
项目:Logisim    文件:AttrTable.java   
@Override
public void attrValueChanged(AttrTableModelEvent e) {
    if (e.getSource() != attrModel) {
        attrModel.removeAttrTableModelListener(this);
        return;
    }
    int row = e.getRowIndex();
    TableCellEditor ed = table.getCellEditor();
    if (row >= 0 && ed instanceof CellEditor && attrModel.getRow(row) == ((CellEditor) ed).currentRow) {
        ed.cancelCellEditing();
    }
    fireTableChanged();
}
项目:incubator-netbeans    文件:FmtImports.java   
private void removeStarImportPackageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeStarImportPackageButtonActionPerformed
    int row = starImportPackagesTable.getSelectedRow();
    if (row >= 0) {
        TableCellEditor cellEditor = starImportPackagesTable.getCellEditor();
        if (cellEditor != null)
            cellEditor.cancelCellEditing();
        ((DefaultTableModel)starImportPackagesTable.getModel()).removeRow(row);
    }
}
项目:QN-ACTR-Release    文件:ClassesPanel.java   
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if (column == 1) {
        return comboEditor.getEditor(classTypes);
    } else if (column == 5 && getValueAt(row, column - 1) != null) {
        return new ButtonCellEditor(new JButton(editDistribution));
    } else if (column == 6) {
        return new ButtonCellEditor(new JButton(deleteClass));
    } else {
        return super.getCellEditor(row, column);
    }
}
项目:jmt    文件:InputSectionPanel.java   
private void setQueueLength() {
    if (infiniteQueueSelector.isSelected()) {
        queueLengthSpinner.setEnabled(false);
        data.setStationQueueCapacity(stationKey, new Integer(-1));
        TableCellEditor editor = queueTable.getCellEditor();
        if (editor != null) {
            editor.cancelCellEditing();
        }
        queueTable.repaint();
    } else {
        queueLengthSpinner.setEnabled(true);
        data.setStationQueueCapacity(stationKey, (Integer) queueLengthSpinner.getValue());
        queueTable.repaint();
    }
}
项目:AgentWorkbench    文件:ComponentTypeDialog.java   
/**
 * Registers the escape key stroke in order to close this dialog.
 */
private void registerEscapeKeyStroke() {
    final ComponentTypeDialog compTypeDialog = this;
    final ActionListener listener = new ActionListener() {
        public final void actionPerformed(final ActionEvent ae) {
            // --- Stop cell editing, if required ----- 
            TableCellEditor editor = getJTable4DomainTypes().getCellEditor();
if (editor!=null)  {
    editor.stopCellEditing();
    return;
}
editor = getJTable4ComponentTypes().getCellEditor();
if (editor!=null)  {
    editor.stopCellEditing();
    return;
}

            // --- Close dialog -----------------------
String title = Language.translate("Schließen") + " ?";
String message = Language.translate("Dialog schließen") + " ?";
if (JOptionPane.showConfirmDialog(compTypeDialog, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION) {
    canceled = true;
            setVisible(false);  
}
        }
    };
    final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
    this.getRootPane().registerKeyboardAction(listener, keyStroke, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}