本文整理了Java中javax.swing.JFileChooser.getName()
方法的一些代码示例,展示了JFileChooser.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.getName()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:getName
暂无
代码示例来源:origin: org.gephi/directory-chooser
private String getNodeText(File file) {
if(file.exists()) {
return "<html>" + fileChooser.getName(file) + "</html>";
} else {
return "<html></html>";
}
}
}
代码示例来源:origin: us.ihmc/IHMCAvatarInterfaces
private File selectFile()
{
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
File selectedFile;
if (approveOption != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file :" + chooser.getName());
selectedFile = null;
}
else
selectedFile = chooser.getSelectedFile();
return selectedFile;
}
代码示例来源:origin: us.ihmc/ihmc-avatar-interfaces
private File selectFile()
{
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
File selectedFile;
if (approveOption != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file :" + chooser.getName());
selectedFile = null;
}
else
selectedFile = chooser.getSelectedFile();
return selectedFile;
}
代码示例来源:origin: us.ihmc/DarpaRoboticsChallenge
private File selectFile()
{
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
File selectedFile;
if (approveOption != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file :" + chooser.getName());
selectedFile = null;
}
else
selectedFile = chooser.getSelectedFile();
return selectedFile;
}
代码示例来源:origin: us.ihmc/ihmc-humanoid-behaviors
private static JFileChooser getFileChooser(String fileExtension)
{
JFileChooser chooser = new JFileChooser(new File(ScriptEngineSettings.scriptLoadingDirectory));
chooser.setFileFilter(getIsoDataPathFilter(fileExtension));
int returnVal = chooser.showOpenDialog(new JFrame());
if (returnVal != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file: " + chooser.getName());
return null;
}
return chooser;
}
代码示例来源:origin: stackoverflow.com
// all extensions from TXTfile
String[] extensions= {"txt","abc","xyz","wxy"};
JFileChooser fileChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXTFILES",extensions);
fileChooser.setFileFilter(filter);
int returnVal = chooser.showOpenDialog(parent);
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: "
+fileChooser.getName(new File("ext.txt")));//or you can use getSelectedFile() that user has choosen.
}
代码示例来源:origin: us.ihmc/IHMCHumanoidBehaviors
private static JFileChooser getFileChooser(String fileExtension)
{
JFileChooser chooser = new JFileChooser(new File(ScriptEngineSettings.scriptLoadingDirectory));
chooser.setFileFilter(getIsoDataPathFilter(fileExtension));
int returnVal = chooser.showOpenDialog(new JFrame());
if (returnVal != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file: " + chooser.getName());
return null;
}
return chooser;
}
代码示例来源:origin: us.ihmc/IHMCAvatarInterfaces
private boolean initPlaybackFromFile(FullRobotModel fullRobotModel, PlaybackPoseSequence sequence)
{
boolean successful = true;
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
if (approveOption != JFileChooser.APPROVE_OPTION)
{
if (chooser.getName() != null)
System.err.println("Can not load selected file :" + chooser.getName());
return successful = false;
}
File selectedFile = chooser.getSelectedFile();
sequence.clear();
PlaybackPoseSequenceReader.appendFromFile(sequence, selectedFile);
initPlayback(sequence);
return successful;
}
代码示例来源:origin: us.ihmc/DarpaRoboticsChallenge
private boolean initPlaybackFromFile(FullRobotModel fullRobotModel, PlaybackPoseSequence sequence)
{
boolean successful = true;
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
if (approveOption != JFileChooser.APPROVE_OPTION)
{
if (chooser.getName() != null)
System.err.println("Can not load selected file :" + chooser.getName());
return successful = false;
}
File selectedFile = chooser.getSelectedFile();
sequence.clear();
PlaybackPoseSequenceReader.appendFromFile(sequence, selectedFile);
initPlayback(sequence);
return successful;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
public Component getTableCellEditorComponent(
JTable table,
Object value,
boolean isSelected,
int row,
int column)
{
Component comp=
super.getTableCellEditorComponent(
table,
value,
isSelected,
row,
column);
if (value instanceof File)
{
tf.setText(chooser.getName((File) value));
tf.requestFocus();
tf.selectAll();
}
return comp;
}
});
代码示例来源:origin: us.ihmc/ihmc-avatar-interfaces
private boolean initPlaybackFromFile(FullRobotModel fullRobotModel, PlaybackPoseSequence sequence)
{
boolean successful = true;
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
if (approveOption != JFileChooser.APPROVE_OPTION)
{
if (chooser.getName() != null)
System.err.println("Can not load selected file :" + chooser.getName());
return successful = false;
}
File selectedFile = chooser.getSelectedFile();
sequence.clear();
PlaybackPoseSequenceReader.appendFromFile(sequence, selectedFile);
initPlayback(sequence);
return successful;
}
代码示例来源:origin: org.gephi/directory-chooser
@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
Component c = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
DirectoryNode node = (DirectoryNode)value;
editorPanel.setOpaque(false);
editorPanel.add(new JLabel(fileChooser.getIcon(node.getFile())), BorderLayout.CENTER);
editorPanel.add(c, BorderLayout.EAST);
textField = (JTextField)getComponent();
String text = fileChooser.getName(node.getFile());
textField.setText(text);
textField.setColumns(text.length());
return editorPanel;
}
代码示例来源:origin: org.gephi/directory-chooser
@Override
public void keyTyped(KeyEvent evt) {
char keyChar = evt.getKeyChar();
if (isCharForSearch(evt)) {
if (paths == null) {
paths = getVisiblePaths();
}
searchBuf.append(keyChar);
String searchedText = searchBuf.toString().toLowerCase();
String curFileName = null;
for (TreePath path : paths) {
curFileName = fileChooser.getName(((DirectoryNode) path.getLastPathComponent()).getFile());
if (curFileName != null && curFileName.toLowerCase().startsWith(searchedText)) {
tree.makeVisible(path);
tree.scrollPathToVisible(path);
tree.setSelectionPath(path);
break;
}
}
} else {
resetBuffer();
}
}
代码示例来源:origin: us.ihmc/IHMCAvatarInterfaces
public void variableChanged(YoVariable yoVariable)
{
System.out.println("Load Sequence Listener");
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
if (approveOption != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file :" + chooser.getName());
return;
}
File selectedFile = chooser.getSelectedFile();
PlaybackPoseSequence sequence = new PlaybackPoseSequence(fullRobotModelForSlider);
PlaybackPoseSequenceReader.appendFromFile(sequence, selectedFile);
double startTime = 0.0;
double time = startTime;
double dt = controlDT;
interpolator.startSequencePlayback(sequence, startTime);
while (!interpolator.isDone())
{
time = time + dt;
scs.setTime(time);
scs.tickAndUpdate();
}
}
}
代码示例来源:origin: us.ihmc/ihmc-avatar-interfaces
public void notifyOfVariableChange(YoVariable yoVariable)
{
System.out.println("Load Sequence Listener");
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
if (approveOption != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file :" + chooser.getName());
return;
}
File selectedFile = chooser.getSelectedFile();
PlaybackPoseSequence sequence = new PlaybackPoseSequence(fullRobotModelForSlider);
PlaybackPoseSequenceReader.appendFromFile(sequence, selectedFile);
double startTime = 0.0;
double time = startTime;
double dt = controlDT;
interpolator.startSequencePlayback(sequence, startTime);
while (!interpolator.isDone())
{
time = time + dt;
scs.setTime(time);
scs.tickAndUpdate();
}
}
}
代码示例来源:origin: us.ihmc/DarpaRoboticsChallenge
public void variableChanged(YoVariable yoVariable)
{
System.out.println("Load Sequence Listener");
JFileChooser chooser = new JFileChooser(new File("PoseSequences"));
int approveOption = chooser.showOpenDialog(null);
if (approveOption != JFileChooser.APPROVE_OPTION)
{
System.err.println("Can not load selected file :" + chooser.getName());
return;
}
File selectedFile = chooser.getSelectedFile();
PlaybackPoseSequence sequence = new PlaybackPoseSequence(fullRobotModelForSlider);
PlaybackPoseSequenceReader.appendFromFile(sequence, selectedFile);
double startTime = 0.0;
double time = startTime;
double dt = controlDT;
interpolator.startSequencePlayback(sequence, startTime);
while (!interpolator.isDone())
{
time = time + dt;
scs.setTime(time);
scs.tickAndUpdate();
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
{
super.getListCellRendererComponent(
list,
value,
index,
isSelected,
cellHasFocus);
File file= (File) value;
String fileName= getFileChooser().getName(file);
setText(fileName);
Icon icon= FileChooserUI.getIcon(file, fileIcon, getFileChooser().getFileSystemView());
setIcon(icon);
if (isSelected)
{
// PENDING(jeff) - grab padding (4) below from defaults table.
editX= icon.getIconWidth() + 4;
}
return this;
}
}
代码示例来源:origin: org.gephi/directory-chooser
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected,
boolean cellHasFocus) {
// #89393: GTK needs name to render cell renderer "natively"
setName("ComboBox.listRenderer"); // NOI18N
if (value == null) {
setText("");
return this;
}
File directory = (File)value;
setText(getFileChooser().getName(directory));
Icon icon = getFileChooser().getIcon(directory);
indenter.icon = icon;
indenter.depth = directoryComboBoxModel.getDepth(index);
setIcon(indenter);
if ( isSelected ) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
return this;
}
代码示例来源:origin: joel-costigliola/assertj-swing
/**
* Returns the {@code String} representation of the given {@code Component}, which should be a {@code JFileChooser}.
*
* @param c the given {@code Component}.
* @return the {@code String} representation of the given {@code JFileChooser}.
*/
@RunsInCurrentThread
@Override
@Nonnull protected String doFormat(@Nonnull Component c) {
JFileChooser fileChooser = (JFileChooser) c;
String format = "%s[name=%s, dialogTitle=%s, dialogType=%s, currentDirectory=%s, enabled=%b, visible=%b, showing=%b";
return String.format(format, getRealClassName(c), quote(fileChooser.getName()),
quote(fileChooser.getDialogTitle()), DIALOG_TYPES.get(fileChooser.getDialogType()),
new StandardRepresentation().toStringOf(fileChooser.getCurrentDirectory()),
fileChooser.isEnabled(),
fileChooser.isVisible(), fileChooser.isShowing());
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
public void setValue(Object value)
{
setIcon(null);
if (value instanceof File)
{
File file= (File) value;
String fileName= chooser.getName(file);
setText(fileName);
Icon icon= FileChooserUI.getIcon(file, fileIcon, getFileChooser().getFileSystemView());
setIcon(icon);
}
else if (value instanceof Date)
{
setText((value == null) ? "" : df.format((Date) value));
}
else
{
super.setValue(value);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!