//************************************************************* // ImageIOで扱える画像を調べる // 「UsableImageInfo」 // //          作 成 者:ルート高菜    //          作成開始月:2009/11 //          最終更新月:2009/11 [TN125/J115] //************************************************************* import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.imageio.ImageIO; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class UsableImageInfo extends JPanel implements ActionListener { //Eclipseの場合、シリアライズ可能クラスでこれがないと警告が出る private static final long serialVersionUID=0; // public static void main(String[] args) { JFrame frame=new JFrame(); frame.getContentPane().add(new UsableImageInfo()); frame.setTitle("UsableImageInfo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //右上×印で終了 frame.setSize(400,300); frame.setVisible(true); frame.setLocationRelativeTo(null); //画面の真ん中に表示 } // JButton buttonFormatNames=new JButton("Format Names"); JButton buttonMIMETypes=new JButton("MIME Types"); JButton buttonFileSuffixes=new JButton("File Suffixes"); // JTextArea textInfoReader=new JTextArea(); JTextArea textInfoWriter=new JTextArea(); //------------------------------------------------------------------コンストラクタ // public UsableImageInfo() { JPanel panelButton=new JPanel(); panelButton.add(buttonFormatNames); panelButton.add(buttonMIMETypes); panelButton.add(buttonFileSuffixes); // JPanel panelInfo=new JPanel(); panelInfo.setLayout(new GridLayout(1,2)); panelInfo.add(new JScrollPane(textInfoReader)); panelInfo.add(new JScrollPane(textInfoWriter)); // setLayout(new BorderLayout()); add(panelButton,BorderLayout.NORTH); add(panelInfo,BorderLayout.CENTER); // buttonFormatNames.addActionListener(this); buttonMIMETypes.addActionListener(this); buttonFileSuffixes.addActionListener(this); } //------------------------------------------------------------------イベント // public void actionPerformed(ActionEvent e) { StringBuffer bufReader=new StringBuffer(); StringBuffer bufWriter=new StringBuffer(); String[] names; // Object object=e.getSource(); if(object==buttonFormatNames){ //画像フォーマット名(ImageIO.writeの中で指定する?) // bufReader.append("ReaderFormatNames:"); bufReader.append(System.getProperty("line.separator")); names=ImageIO.getReaderFormatNames(); for(int n=0;n