Java Code Examples for com.alee.laf.filechooser.WebFileChooser#APPROVE_OPTION

The following examples show how to use com.alee.laf.filechooser.WebFileChooser#APPROVE_OPTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentUtils.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
private void chooseImage() {
    int state = mImgChooser.showOpenDialog(this);
    if (state != WebFileChooser.APPROVE_OPTION)
        return;

    File imgFile = mImgChooser.getSelectedFile();
    if (!imgFile.isFile())
        return;

    BufferedImage img = MediaUtils.readImage(imgFile).orElse(null);
    if (img == null)
        return;

    this.changeImage(ImageUtils.createPreviewImage(img, mSize));
}
 
Example 2
Source File: ChatView.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
private void showFileDialog() {
    int option = mFileChooser.showOpenDialog(ChatView.this);
    if (option != WebFileChooser.APPROVE_OPTION)
        return;

    File file = mFileChooser.getSelectedFile();
    mFileChooser.setCurrentDirectory(file.toPath().getParent().toString());
    this.sendFile(file);
}
 
Example 3
Source File: Menu.java    From Spade with GNU General Public License v3.0 5 votes vote down vote up
public static void showOpenMenu()
{
	final WebFileChooser chooser = new WebFileChooser(Spade.getDir());
	chooser.setFileSelectionMode(WebFileChooser.FILES_ONLY);
	chooser.setAcceptAllFileFilterUsed(false);
	chooser.setFileFilter(new ReadableFileFilter());
	
	// Add ALL the custom image-importers!
	ImageImporter.addAllImporters(chooser);
	
	int returned = chooser.showOpenDialog(new WebDialog(Spade.main.gui.frame, "Load Image"));
	
	if(returned == WebFileChooser.APPROVE_OPTION)
	{
		// If a Image takes too long, the application might crash.
		// By running the actual loading process in another thread, the AWT-Event Thread can continue working while the image is being loaded.
		new Thread(new Runnable()
		{
			@Override
			public void run()
			{
				Document doc = Document.loadFromFile(chooser.getSelectedFile());
				if(doc != null)
				{
					Spade.addDocument(doc);
					Spade.setDocument(doc);
				}
			}
		}).start();
	}
}