256 buttons.add(Box.createRigidArea(HGAP10));
257 buttons.add(createButton(createAboutAction()));
258 buttons.add(Box.createRigidArea(HGAP10));
259 buttons.add(createButton(okAction));
260 buttons.add(Box.createRigidArea(HGAP10));
261 buttons.add(createButton(createCancelAction()));
262 buttons.add(Box.createRigidArea(HGAP10));
263 buttons.add(createImageButton(createHelpAction()));
264 buttons.add(Box.createRigidArea(HGAP10));
265
266 custom.add(buttons);
267 custom.add(Box.createRigidArea(VGAP10));
268
269 // show the filechooser
270 Frame parent = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, getDemoPanel());
271 dialog = new JDialog(parent, getString("FileChooserDemo.dialogtitle"), true);
272 dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
273 dialog.getContentPane().add(custom, BorderLayout.CENTER);
274 dialog.pack();
275 dialog.setLocationRelativeTo(getDemoPanel());
276 dialog.show();
277 }
278 };
279 return createButton(a);
280 }
281
282 public Action createAboutAction() {
283 return new AbstractAction(getString("FileChooserDemo.about")) {
284 public void actionPerformed(ActionEvent e) {
285 File file = fc.getSelectedFile();
286 String text;
287 if(file == null) {
288 text = getString("FileChooserDemo.nofileselected");
289 } else {
290 text = "<html>" + getString("FileChooserDemo.thefile");
291 text += "<br><font color=green>" + file.getName() + "</font><br>";
292 text += getString("FileChooserDemo.isprobably") + "</html>";
293 }
294 JOptionPane.showMessageDialog(getDemoPanel(), text);
295 }
296 };
|
256 buttons.add(Box.createRigidArea(HGAP10));
257 buttons.add(createButton(createAboutAction()));
258 buttons.add(Box.createRigidArea(HGAP10));
259 buttons.add(createButton(okAction));
260 buttons.add(Box.createRigidArea(HGAP10));
261 buttons.add(createButton(createCancelAction()));
262 buttons.add(Box.createRigidArea(HGAP10));
263 buttons.add(createImageButton(createHelpAction()));
264 buttons.add(Box.createRigidArea(HGAP10));
265
266 custom.add(buttons);
267 custom.add(Box.createRigidArea(VGAP10));
268
269 // show the filechooser
270 Frame parent = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, getDemoPanel());
271 dialog = new JDialog(parent, getString("FileChooserDemo.dialogtitle"), true);
272 dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
273 dialog.getContentPane().add(custom, BorderLayout.CENTER);
274 dialog.pack();
275 dialog.setLocationRelativeTo(getDemoPanel());
276 dialog.setVisible(true);
277 }
278 };
279 return createButton(a);
280 }
281
282 public Action createAboutAction() {
283 return new AbstractAction(getString("FileChooserDemo.about")) {
284 public void actionPerformed(ActionEvent e) {
285 File file = fc.getSelectedFile();
286 String text;
287 if(file == null) {
288 text = getString("FileChooserDemo.nofileselected");
289 } else {
290 text = "<html>" + getString("FileChooserDemo.thefile");
291 text += "<br><font color=green>" + file.getName() + "</font><br>";
292 text += getString("FileChooserDemo.isprobably") + "</html>";
293 }
294 JOptionPane.showMessageDialog(getDemoPanel(), text);
295 }
296 };
|