~tapaal-contributor/tapaal/weight-values-fix-1770637

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/gui/FileNameCellRenderer.java

merged in branch lp:~tapaal-contributor/tapaal/Batch-export-PNML-XML-queries-1754675
adding batch export of files to PNML and XML

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package dk.aau.cs.gui;
 
2
 
 
3
import java.awt.Component;
 
4
import java.io.File;
 
5
 
 
6
import javax.swing.JLabel;
 
7
import javax.swing.JList;
 
8
import javax.swing.ListCellRenderer;
 
9
 
 
10
public class FileNameCellRenderer extends JLabel implements ListCellRenderer  {
 
11
        // Custom cell renderer for the file list to only display the name of the
 
12
        // file 
 
13
        // instead of the whole path.{
 
14
        private static final long serialVersionUID = 3071924451912979500L;
 
15
        
 
16
        public Component getListCellRendererComponent(JList list, Object value,
 
17
                        int index, boolean isSelected, boolean cellHasFocus) {
 
18
                if (value instanceof File)
 
19
                        setText(((File) value).getName());
 
20
                else
 
21
                        setText(value.toString());
 
22
                if (isSelected) {
 
23
                        setBackground(list.getSelectionBackground());
 
24
                        setForeground(list.getSelectionForeground());
 
25
                } else {
 
26
                        setBackground(list.getBackground());
 
27
                        setForeground(list.getForeground());
 
28
                }
 
29
                setEnabled(list.isEnabled());
 
30
                setFont(list.getFont());
 
31
                setOpaque(true);
 
32
                return this;
 
33
        }
 
34
}