|
@@ -16,6 +16,25 @@ public class Controls extends JPanel implements Observer
|
|
private JSlider rating;
|
|
private JSlider rating;
|
|
private JRadioButton grid;
|
|
private JRadioButton grid;
|
|
private JRadioButton list;
|
|
private JRadioButton list;
|
|
|
|
+ private class customListener implements ActionListener
|
|
|
|
+ {
|
|
|
|
+ public void actionPerformed(ActionEvent e)
|
|
|
|
+ {
|
|
|
|
+ if (e.getSource() ==grid)
|
|
|
|
+ {
|
|
|
|
+ grid.setSelected(true);
|
|
|
|
+ list.setSelected(false);
|
|
|
|
+ model.switchLayout();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ list.setSelected(true);
|
|
|
|
+ grid.setSelected(false);
|
|
|
|
+ model.switchLayout();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private ButtonGroup layouts;
|
|
private ButtonGroup layouts;
|
|
private Image starImg;
|
|
private Image starImg;
|
|
private Image gridImg;
|
|
private Image gridImg;
|
|
@@ -70,33 +89,10 @@ public class Controls extends JPanel implements Observer
|
|
this.folderIcon = new ImageIcon(folderImg);
|
|
this.folderIcon = new ImageIcon(folderImg);
|
|
|
|
|
|
this.grid = new JRadioButton(gridIcon, true);
|
|
this.grid = new JRadioButton(gridIcon, true);
|
|
- grid.addActionListener(new ActionListener()
|
|
|
|
- {
|
|
|
|
- public void actionPerformed(ActionEvent e)
|
|
|
|
- {
|
|
|
|
- if (!(grid.isSelected()))
|
|
|
|
- {
|
|
|
|
- grid.setSelected(true);
|
|
|
|
- list.setSelected(false);
|
|
|
|
- model.switchLayout();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ grid.addActionListener(customListener);
|
|
|
|
|
|
this.list = new JRadioButton(listIcon, false);
|
|
this.list = new JRadioButton(listIcon, false);
|
|
- list.addActionListener(new ActionListener()
|
|
|
|
- {
|
|
|
|
- public void actionPerformed(ActionEvent e)
|
|
|
|
- {
|
|
|
|
- System.out.println("Click!");
|
|
|
|
- if (!(list.isSelected()))
|
|
|
|
- {
|
|
|
|
- list.setSelected(true);
|
|
|
|
- grid.setSelected(false);
|
|
|
|
- model.switchLayout();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ list.addActionListener(customListener);
|
|
|
|
|
|
this.layouts = new ButtonGroup();
|
|
this.layouts = new ButtonGroup();
|
|
layouts.add(grid);
|
|
layouts.add(grid);
|