📄 myviewchooser.java
字号:
// MyViewChooser.java// An example that uses custom file views to show thumbnails of graphic files// rather than the regular file icon. (see ThumbnailFileView.java)//package jswing.ch12;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MyViewChooser extends JFrame { JFrame parent; public MyViewChooser() { super("File View Test Frame"); setSize(350, 200); setDefaultCloseOperation(EXIT_ON_CLOSE); parent = this; Container c = getContentPane(); c.setLayout(new FlowLayout()); JButton openButton = new JButton("Open"); final JLabel statusbar = new JLabel("Output of your selection will go here"); openButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JFileChooser chooser = new JFileChooser(); // Ok, set up our own file view for the chooser chooser.setFileView(new ThumbNailFileView(MyViewChooser.this)); int option = chooser.showOpenDialog(parent); if (option == JFileChooser.APPROVE_OPTION) { statusbar.setText("You chose " + chooser.getSelectedFile().getName()); } else { statusbar.setText("You cancelled."); } } }); c.add(openButton); c.add(statusbar); } public static void main(String args[]) { System.setProperty("swing.defaultlaf", "javax.swing.plaf.metal.MetalLookAndFeel"); MyViewChooser vc = new MyViewChooser(); vc.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -