private void createUI() { try { this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); Border border = BorderFactory.createEmptyBorder(5, 5, 5, 5); this.setBorder(border); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); Box box = Box.createVerticalBox(); String[] args = new String[7]; args[0] = "fileSelector"; // Name args[1] = "file selector"; // Description args[2] = "Input shapefile:"; // getTextValue(el, "LabelText"); args[3] = Integer.toString(DialogFile.MODE_OPEN); args[4] = "true"; // getTextValue(el, "ShowButton").toLowerCase(); args[5] = "ShapeFile (*.shp), SHP"; // getTextValue(el, "Filter"); args[6] = "false"; // getTextValue(el, "MakeOptional").toLowerCase(); df = new DialogFile(hostDialog); df.setArgs(args); df.addPropertyChangeListener("value", this); df.setTextFieldActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); box.add(df); // list.addListSelectionListener(this); Box hbox = Box.createHorizontalBox(); lbl = new JLabel(label); hbox.add(lbl); hbox.add(Box.createHorizontalGlue()); box.add(hbox); box.add(Box.createHorizontalStrut(5)); list = new JList(); if (!multiSelect) { list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else { // true list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } updateList(); JScrollPane scroller1 = new JScrollPane(list); box.add(scroller1); box.setToolTipText(description); this.setToolTipText(description); list.setToolTipText(description); lbl.setToolTipText(description); panel.add(box); this.add(panel); this.add(Box.createHorizontalGlue()); this.setMaximumSize(new Dimension(2500, 140)); this.setPreferredSize(new Dimension(350, 140)); } catch (Exception e) { System.out.println(e.getCause()); } }
@Override public void propertyChange(PropertyChangeEvent evt) { shapefile = df.getValue(); updateList(); }