public JalviewFileChooser(String dir)
{
super(safePath(dir));
- setAccessory(new RecentlyOpened(this));
+ setAccessory(new RecentlyOpened());
}
public JalviewFileChooser(String dir, String[] suffix, String[] desc,
setFileFilter(chosen);
}
- setAccessory(new RecentlyOpened(this));
+ setAccessory(new RecentlyOpened());
}
@Override
}
}
+ class RecentlyOpened extends JPanel
+ {
+ private static final long serialVersionUID = 1L;
+ JList<String> list;
+
+ RecentlyOpened()
+ {
+ setPreferredSize(new Dimension(300,100));
+ String historyItems = Cache.getProperty("RECENT_FILE");
+ StringTokenizer st;
+ Vector<String> recent = new Vector<>();
+
+ if (historyItems != null)
+ {
+ st = new StringTokenizer(historyItems, "\t");
+
+ while (st.hasMoreTokens())
+ {
+ recent.addElement(st.nextToken());
+ }
+ }
+
+ list = new JList<>(recent);
+
+ DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
+// dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT);
+ list.setCellRenderer(dlcr);
+
+ list.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent evt)
+ {
+ recentListSelectionChanged(list.getSelectedValue());
+ }
+ });
+
+ this.setBorder(new javax.swing.border.TitledBorder(
+ MessageManager.getString("label.recently_opened")));
+
+ final JScrollPane scroller = new JScrollPane(list);
+
+ SpringLayout layout = new SpringLayout();
+ layout.putConstraint(SpringLayout.WEST, scroller, 5,
+ SpringLayout.WEST, this);
+ layout.putConstraint(SpringLayout.NORTH, scroller, 5,
+ SpringLayout.NORTH, this);
+
+ if (Platform.isAMac())
+ {
+ scroller.setPreferredSize(new Dimension(500, 100));
+ }
+ else
+ {
+ scroller.setPreferredSize(new Dimension(530, 200));
+ }
+
+ this.add(scroller);
+
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ scroller.getHorizontalScrollBar()
+ .setValue(scroller.getHorizontalScrollBar().getMaximum());
+ }
+ });
+
+ }
+
+ }
@Override
public DialogRunnerI setResponseHandler(Object response, Runnable action)
}
}
}
-
-class RecentlyOpened extends JPanel
-{
- private static final long serialVersionUID = 1L;
- JList<String> list;
- private JalviewFileChooser chooser;
-
- RecentlyOpened(JalviewFileChooser chooser)
- {
- this.chooser = chooser;
- setPreferredSize(new Dimension(300,100));
- String historyItems = Cache.getProperty("RECENT_FILE");
- StringTokenizer st;
- Vector<String> recent = new Vector<>();
-
- if (historyItems != null)
- {
- st = new StringTokenizer(historyItems, "\t");
-
- while (st.hasMoreTokens())
- {
- recent.addElement(st.nextToken());
- }
- }
-
- list = new JList<>(recent);
-
- DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
-// dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT);
- list.setCellRenderer(dlcr);
-
- list.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mousePressed(MouseEvent evt)
- {
- chooser.recentListSelectionChanged(list.getSelectedValue());
- }
- });
-
- this.setBorder(new javax.swing.border.TitledBorder(
- MessageManager.getString("label.recently_opened")));
-
- final JScrollPane scroller = new JScrollPane(list);
-
- SpringLayout layout = new SpringLayout();
- layout.putConstraint(SpringLayout.WEST, scroller, 5,
- SpringLayout.WEST, this);
- layout.putConstraint(SpringLayout.NORTH, scroller, 5,
- SpringLayout.NORTH, this);
-
- if (Platform.isAMac())
- {
- scroller.setPreferredSize(new Dimension(500, 100));
- }
- else
- {
- scroller.setPreferredSize(new Dimension(530, 200));
- }
-
- this.add(scroller);
-
- javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
- @Override
- public void run()
- {
- scroller.getHorizontalScrollBar()
- .setValue(scroller.getHorizontalScrollBar().getMaximum());
- }
- });
-
- }
-
-}