下面列出了怎么用javax.swing.plaf.basic.BasicDirectoryModel的API类实例代码及写法,或者点击链接到github查看源代码。
protected int getNextMatch(final int startIndex, final int finishIndex) {
BasicDirectoryModel model = getModel();
JFileChooser fileChooser = getFileChooser();
DetailsTableRowSorter rowSorter = getRowSorter();
String prefix = typedString.toString().toLowerCase();
// Search element
for (int index = startIndex; index <= finishIndex; index++) {
File file = (File) model.getElementAt(rowSorter.convertRowIndexToModel(index));
String fileName = fileChooser.getName(file).toLowerCase();
if (fileName.startsWith(prefix)) {
return index;
}
}
return -1;
}
public BasicDirectoryModel getModel() {
return DarkFileChooserUIBridge.this.getModel();
}
/**
* Moves the keyboard focus to the first element whose prefix matches
* the sequence of alphanumeric keys pressed by the user with delay
* less than value of <code>timeFactor</code>. Subsequent same key
* presses move the keyboard focus to the next object that starts with
* the same letter until another key is pressed, then it is treated
* as the prefix with appropriate number of the same letters followed
* by first typed another letter.
*/
public void keyTyped(final KeyEvent e) {
BasicDirectoryModel model = getModel();
int rowCount = model.getSize();
if (detailsTable == null || rowCount == 0 ||
e.isAltDown() || e.isControlDown() || e.isMetaDown()) {
return;
}
InputMap inputMap = detailsTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
KeyStroke key = KeyStroke.getKeyStrokeForEvent(e);
if (inputMap != null && inputMap.get(key) != null) {
return;
}
int startIndex = detailsTable.getSelectionModel().getLeadSelectionIndex();
if (startIndex < 0) {
startIndex = 0;
}
if (startIndex >= rowCount) {
startIndex = rowCount - 1;
}
char c = e.getKeyChar();
long time = e.getWhen();
if (time - lastTime < timeFactor) {
if (typedString.length() == 1 && typedString.charAt(0) == c) {
// Subsequent same key presses move the keyboard focus to the next
// object that starts with the same letter.
startIndex++;
} else {
typedString.append(c);
}
} else {
startIndex++;
typedString.setLength(0);
typedString.append(c);
}
lastTime = time;
if (startIndex >= rowCount) {
startIndex = 0;
}
// Find next file
int index = getNextMatch(startIndex, rowCount - 1);
if (index < 0 && startIndex > 0) { // wrap
index = getNextMatch(0, startIndex - 1);
}
if (index >= 0) {
detailsTable.getSelectionModel().setSelectionInterval(index, index);
Rectangle cellRect = detailsTable.getCellRect(index,
detailsTable.convertColumnIndexToView(COLUMN_FILENAME),
false);
detailsTable.scrollRectToVisible(cellRect);
}
}
protected BasicDirectoryModel getModel() {
return fileChooserUIAccessor.getModel();
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
public BasicDirectoryModel getModel() {
return model;
}
@Override public BasicDirectoryModel getModel() {
return model2;
}
@Override public BasicDirectoryModel getModel() {
return model2;
}
BasicDirectoryModel getModel();