Using JFileChooser
for Java Swing projects.
I made a code to load the image and print it out to the label. However, the image rendering on the label is too slow. (30 seconds to 60 seconds)
The file size is 30KB to 50KB.
moviePosterButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser movieImageChooser = new JFileChooser();
movieImageChooser.setDialogTitle("image load");
int returnVal = movieImageChooser.showOpenDialog(frame);
if(returnVal == JFileChooser.APPROVE_OPTION) {
filePath = movieImageChooser.getSelectedFile().getPath();
fileName = movieImageChooser.getSelectedFile().getName();
System.out.println(fileName);
System.out.println(filePath);
image_save = new File(filePath);
JLabel moviePosterPrintLabel = new JLabel();
moviePosterPrintLabel.setIcon(new ImageIcon(filePath));
moviePosterPrintLabel.setBounds(70, 140, 230, 342);
movieUploadPanel.add(moviePosterPrintLabel);
}
}
});