亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

文件上傳問題

文件上傳問題

cute倩影O_o 2016-12-11 20:37:49
?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(); }}我用鏈表導入圖片信息,可是什么都不顯示
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1611 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號