use of java.awt.FileDialog in project megameklab by MegaMek.
the class StatusBar method getFluffImage.
private void getFluffImage() {
// copied from structureTab
FileDialog fDialog = new FileDialog(getParentFrame(), "Image Path", FileDialog.LOAD);
fDialog.setDirectory(new File(ImageHelper.fluffPath).getAbsolutePath() + File.separatorChar + ImageHelper.imageMech + File.separatorChar);
/*
//This does not seem to be working
if (getMech().getFluff().getMMLImagePath().trim().length() > 0) {
String fullPath = new File(getMech().getFluff().getMMLImagePath()).getAbsolutePath();
String imageName = fullPath.substring(fullPath.lastIndexOf(File.separatorChar) + 1);
fullPath = fullPath.substring(0, fullPath.lastIndexOf(File.separatorChar) + 1);
fDialog.setDirectory(fullPath);
fDialog.setFile(imageName);
} else {
fDialog.setDirectory(new File(ImageHelper.fluffPath).getAbsolutePath() + File.separatorChar + ImageHelper.imageMech + File.separatorChar);
fDialog.setFile(getMech().getChassis() + " " + getMech().getModel() + ".png");
}
*/
fDialog.setLocationRelativeTo(this);
fDialog.setVisible(true);
if (fDialog.getFile() != null) {
String relativeFilePath = new File(fDialog.getDirectory() + fDialog.getFile()).getAbsolutePath();
relativeFilePath = "." + File.separatorChar + relativeFilePath.substring(new File(System.getProperty("user.dir").toString()).getAbsolutePath().length() + 1);
getTank().getFluff().setMMLImagePath(relativeFilePath);
}
refresh.refreshPreview();
return;
}
use of java.awt.FileDialog in project algs4 by kevin-wayne.
the class StdDraw method actionPerformed.
/**
* This method cannot be called directly.
*/
@Override
public void actionPerformed(ActionEvent e) {
FileDialog chooser = new FileDialog(StdDraw.frame, "Use a .png or .jpg extension", FileDialog.SAVE);
chooser.setVisible(true);
String filename = chooser.getFile();
if (filename != null) {
StdDraw.save(chooser.getDirectory() + File.separator + chooser.getFile());
}
}
use of java.awt.FileDialog in project Spark by igniterealtime.
the class ChatRoomTransferDecorator method showFilePicker.
private void showFilePicker() {
SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(10);
} catch (InterruptedException e1) {
Log.error(e1);
}
return true;
}
public void finished() {
FileDialog fileChooser = SparkManager.getTransferManager().getFileChooser(SparkManager.getChatManager().getChatContainer().getChatFrame(), Res.getString("title.select.file.to.send"));
if (SparkManager.getTransferManager().getDefaultDirectory() != null) {
fileChooser.setDirectory(SparkManager.getTransferManager().getDefaultDirectory().getAbsolutePath());
}
fileChooser.setVisible(true);
final File[] files = fileChooser.getFiles();
if (files.length == 0) {
// no selection
return;
}
// Single-file selection is used. Using the first array item is safe.
File file = files[0];
if (file.exists()) {
SparkManager.getTransferManager().setDefaultDirectory(file.getParentFile());
SparkManager.getTransferManager().sendFile(file, ((ChatRoomImpl) chatRoom).getParticipantJID());
}
}
};
worker.start();
}
use of java.awt.FileDialog in project Spark by igniterealtime.
the class SparkTransferManager method sendFileTo.
public void sendFileTo(ContactItem item) {
FileDialog fileChooser = getFileChooser(SparkManager.getMainWindow(), Res.getString("title.select.file.to.send"));
if (defaultDirectory != null) {
fileChooser.setDirectory(defaultDirectory.getAbsolutePath());
}
fileChooser.setVisible(true);
final File[] files = fileChooser.getFiles();
if (files.length == 0) {
// no selection
return;
}
// Single-file selection is used. Using the first array item is safe.
File file = files[0];
if (file.exists()) {
defaultDirectory = file.getParentFile();
sendFile(file, item.getJID());
}
}
use of java.awt.FileDialog in project Spark by igniterealtime.
the class AvatarPanel method initFileChooser.
public void initFileChooser() {
if (fileChooser == null) {
fileChooser = new FileDialog(dlg, "Choose Avatar", FileDialog.LOAD);
fileChooser.setFilenameFilter(new ImageFilter());
}
}
Aggregations