📄 longcelleditor.java
字号:
/*
* 08/10/2005
*
* LongCellEditor.java - Editor component for longs.
* Copyright (C) 2005 Robert Futrell
* email@address.com
* www.website.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.fife.ui.propertysheet.editors;
import javax.swing.JTextField;
/**
* Table cell editor for longs.
*
* @author Robert Futrell
* @version 1.0
*/
public class LongCellEditor extends IntegerCellEditor {
/**
*
*/
private static final long serialVersionUID = -5482632629323146642L;
/*****************************************************************************/
public LongCellEditor() {
super();
}
/*****************************************************************************/
public Object getCellEditorValue() {
long value = 0;
try {
String text = (String)((JTextField)editorComponent).getText();
value = Long.parseLong(text);
} catch (NumberFormatException nfe) { // Should never happen.
value = Long.MIN_VALUE;
}
cachedInfo.setValue(new Long(value));
return cachedInfo;
}
/*****************************************************************************/
/**
* Called when an editor is about to stop editing. This method is used
* to determine whether or not the editing should actually stop. It
* checks whether the entered value is a Java long; if not, an error
* is displayed and editing continues.
*
* @return Whether or not editing should cease.
*/
public boolean stopCellEditing() {
JTextField component = (JTextField)getComponent();
String text = component.getText();
try {
Long.parseLong(text);
} catch (NumberFormatException nfe) {
return doCancel(text, "Editor.ErrorMessage.Long");
}
// NOTE: Don't call super.stopCellEditing(), as that is integer-
// specific. Just do its superclass (actually AbstractCellEditor)'s
// stuff.
//return super.stopCellEditing();
fireEditingStopped();
return true;
}
/*****************************************************************************/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -