import javax.swing.*;import javax.swing.table.DefaultTableModel;import org.omg.CORBA.portable.InputStream;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.text.SimpleDateFormat;import java.util.Vector;import java.io.*;public class photos1 extends JFrame implements ActionListener { File files[]; File f; private JLabel ss;//照片标签 JTextField wen = new JTextField("图片名称"); JButton b1 = new JButton("搜索图片"); JButton b2 = new JButton("添加图片"); JButton b3 = new JButton("刪除图片"); private DefaultTableModel table; JTable biao=new JTable(); String title[]={"名称","大小","类型","时间"}; public photos1(){ super("相册管理系统主界面"); this.setSize(600, 400); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); JPanel jp = new JPanel(); JPanel jp1 = new JPanel(); JPanel jp2 = new JPanel(); JMenuBar caidan = new JMenuBar(); JMenu File = new JMenu("文件(F)"); JMenu View = new JMenu("查看(V)"); JMenu Help = new JMenu("帮助(H)"); JMenuItem Save = new JMenuItem("保存"); JMenuItem xi = new JMenuItem("图片信息"); JMenuItem Aboult = new JMenuItem("关于"); caidan.add(File); caidan.add(View); caidan.add(Help); this.add(caidan, "North"); File.add(Save); View.add(xi); Help.add(Aboult); xi.addActionListener(this); jp.setLayout(new GridLayout(4, 4, 20, 50)); jp2.add(jp, "North"); jp.add(wen); jp.add(b1); jp.add(b2); jp.add(b3); this.add(jp2, "West"); this.add(jp1, "Center"); this.table=new DefaultTableModel(title,20); this.biao=new JTable(this.table); jp1.add(new JScrollPane(this.biao),"Center"); b1.addActionListener(this); Aboult.addActionListener(this); this.f=new File("photos"); String path=this.f.getPath(); this.f=new File(path); ImageIcon aa = new ImageIcon(photos1.class.getResource("lq.jpg")); ss = new JLabel(aa); ss.setBounds(0, 0, 600, 400); this.getLayeredPane().add(ss, new Integer(Integer.MIN_VALUE)); jp.setOpaque(false); jp1.setOpaque(false); jp2.setOpaque(false); caidan.setOpaque(false); ((JPanel) this.getContentPane()).setOpaque(false); this.setVisible(true); } private void listFilesToTableModle(){ this.files=this.f.listFiles(); SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-DD hh:mm"); for(int i=0;i<this.files.length;i++) {this.table.setValueAt(this.files[i].getName(),i,0); //if(this。files[i].isFile ()) this.table.setValueAt(this.files[i].length()+"B",i, 1); if(this.files[i].isDirectory()) this.table.setValueAt("jpg", i, 2); // String d =sdf.format(new Date(files[i].lastModified())); } } @Override public void actionPerformed(ActionEvent ee) { JOptionPane.showMessageDialog(null, "您好欢迎使用相册管理系统! 请输入图片的名字进行使用 例如:“1.jpg”", "Aboult", JOptionPane.INFORMATION_MESSAGE); //else if(ee.getSource()==this.f) //this.f=((JLabel) new File( this.f)).getText()); // TODO Auto-generated method stub } public static void main(String[] args) { //主界面 new photos1(); }}我用链表导入图片信息,可是什么都不显示
添加回答
举报
0/150
提交
取消