Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * Demonstriert: FileChooser + Windows Look&Feel = Exceptions **/ public class FileChooserDemo extends JPanel implements ActionListener { private JFileChooser fc; public FileChooserDemo () { super(); JButton openButton = new JButton("Datei öffnen..."); openButton.addActionListener(this); add(openButton); } public void actionPerformed(ActionEvent e) { fc = new JFileChooser(); System.out.println("<<---- Diese Zeile wird im Windows L&F NIE erreicht ---->>"); int returnVal = fc.showDialog(FileChooserDemo.this,"Datei Öffnen..."); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.println("ausgewählte Datei: " + file.getName()); } fc.setSelectedFile(null); } /** * GUI erstellen. */ private static void createGUI() { JFrame frame = new JFrame("FileChooserDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent newContentPane = new FileChooserDemo(); newContentPane.setOpaque(true); frame.setContentPane(newContentPane); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { String laf = UIManager.getSystemLookAndFeelClassName(); if(laf!=null) { try { System.out.println(laf); UIManager.setLookAndFeel(laf); } catch(Exception e) { e.printStackTrace(); } } createGUI(); } } |
This post has been edited 4 times, last edit by "double" (Oct 27th 2004, 3:54pm)
This post has been edited 1 times, last edit by "double" (Oct 27th 2004, 3:52pm)
Source code |
|
1 |
System.setProperty("swing.disableFileChooserSpeedFix", "true"); |
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
com.sun.java.swing.plaf.windows.WindowsLookAndFeel Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:161) at javax.swing.ImageIcon.<init>(ImageIcon.java:147) at sun.swing.WindowsPlacesBar.<init>(WindowsPlacesBar.java:82) at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFo lder(WindowsFileChooserUI.java:509) at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponent s(WindowsFileChooserUI.java:203) at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserU I.java:136) at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Window sFileChooserUI.java:140) at javax.swing.JComponent.setUI(JComponent.java:650) at javax.swing.JFileChooser.updateUI(JFileChooser.java:1755) |
This post has been edited 5 times, last edit by "double" (Oct 28th 2004, 4:34pm)
This post has been edited 1 times, last edit by "double" (Oct 30th 2004, 12:39pm)