|
@@ -1,4 +1,5 @@
|
|
|
import java.io.*;
|
|
|
+import java.io.file;
|
|
|
import java.util.*;
|
|
|
import java.awt.*;
|
|
|
import javax.swing.*;
|
|
@@ -7,6 +8,7 @@ import java.awt.event.*;
|
|
|
import javax.swing.ImageIcon;
|
|
|
import java.awt.image.*;
|
|
|
import javax.imageio.ImageIO;
|
|
|
+import javax.swing.JFileChooser;
|
|
|
|
|
|
public class Controls extends JPanel implements Observer
|
|
|
{
|
|
@@ -17,9 +19,12 @@ public class Controls extends JPanel implements Observer
|
|
|
private Image starImg;
|
|
|
private Image gridImg;
|
|
|
private Image listImg;
|
|
|
+ private Image folderImg;
|
|
|
private ImageIcon starIcon;
|
|
|
private ImageIcon gridIcon;
|
|
|
private ImageIcon listIcon;
|
|
|
+ private ImageIcon folderIcon;
|
|
|
+ private JButton fileButton;
|
|
|
|
|
|
// Bob the Builder this shit
|
|
|
public Controls(Model model)
|
|
@@ -47,13 +52,20 @@ public class Controls extends JPanel implements Observer
|
|
|
this.listImg = ImageIO.read(new File("src/main/resources/list.png"));
|
|
|
} catch(IOException e) {}
|
|
|
|
|
|
+ try
|
|
|
+ {
|
|
|
+ this.folderImg = ImageIO.read(new File("src/main/resources/folder.jpg"));
|
|
|
+ } catch(IOException e) {}
|
|
|
+
|
|
|
|
|
|
this.starImg = starImg.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
|
this.gridImg = gridImg.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
|
this.listImg = listImg.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
|
+ this.folderImg = folderImg.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
|
this.starIcon = new ImageIcon(starImg);
|
|
|
this.gridIcon = new ImageIcon(gridImg);
|
|
|
this.listIcon = new ImageIcon(listImg);
|
|
|
+ this.folderIcon = new ImageIcon(folderImg);
|
|
|
|
|
|
this.grid = new JRadioButton(gridIcon, true);
|
|
|
grid.addActionListener(new ActionListener()
|
|
@@ -73,6 +85,25 @@ public class Controls extends JPanel implements Observer
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ this.fileChooser = new JFileChooser();
|
|
|
+ this.fileButton = new JButton(folderIcon);
|
|
|
+ fileButton.addActionListener(new ActionListener()
|
|
|
+ {
|
|
|
+ public void actionPerformed(ActionEvent e)
|
|
|
+ {
|
|
|
+ int retval = fileChooser.showOpenDialog(null);
|
|
|
+
|
|
|
+ if (retval == JFileChooser.APPROVE_OPTION)
|
|
|
+ {
|
|
|
+ File file = jfc.getSelectedFile();
|
|
|
+ if (file.isFile())
|
|
|
+ {
|
|
|
+ model.newPic(file.getAbsolutePath(), file.getName(), file.length(), file.lastModified());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
this.rating = new JSlider(0, 5, 0);
|
|
|
rating.addChangeListener(new ChangeListener()
|
|
|
{
|
|
@@ -86,6 +117,7 @@ public class Controls extends JPanel implements Observer
|
|
|
this.add(grid);
|
|
|
this.add(list);
|
|
|
this.add(rating);
|
|
|
+ this.add(fileButton);
|
|
|
model.addObserver(this);
|
|
|
}
|
|
|
|