I have a JScrollPane
that has a filedrop feature to allow the dragging of files. I have the JScrollPane being called with a JOptionPanel.showConfirmDialog
so there are ok and cancel buttons. I want to be able to put my mouse on the edge of the window and drag to resize it. I have researched many different ways but most of them involve frames and none of them had JOptionPanes
in them. How can I do this or make a resizable panel with ok and cancel buttons like a showConfirmDialog
.
here is the function for my panels:
public static List<String> displayFilePanel() {
// Declare return object
final List<String> listOfFiles = new ArrayList<String>();
// Create scrollable panel to hold file list
final JTextArea text = new JTextArea();
JScrollPane scrollPane = new JScrollPane(text);
text.setLineWrap(true);
text.setWrapStyleWord(true);
scrollPane.setPreferredSize( new Dimension( 800, 800 ) );
// Drag and drop feature
// Add each file to listofFiles
//new FileDrop( System.out, text, /*dragBorder,*/ new FileDrop.Listener() for debugging
new FileDrop( null, text, /*dragBorder,*/ new FileDrop.Listener()
{ public void filesDropped( java.io.File[] files )
{ for( int i = 0; i < files.length; i++ )
{ try
{
text.append( files[i].getCanonicalPath() + "\n" );
listOfFiles.add(files[i].getCanonicalPath());
} // end try
catch( java.io.IOException e ) {}
} // end for: through each dropped file
} // end filesDropped
}); // end FileDrop.Listener
int result = JOptionPane.showConfirmDialog(null, scrollPane, "Files To rename",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
//System.out.println(text.getText());
} else {
System.out.println("File Pane Cancelled");
//if Cancelled is pressed clear the listOfFiles so a blank list is returned
listOfFiles.clear();
}
return listOfFiles;
}