日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

Eclipse+Java+Swing实现电子相册管理系统

發(fā)布時(shí)間:2024/3/24 windows 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Eclipse+Java+Swing实现电子相册管理系统 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Java+Swing實(shí)現(xiàn)電子相冊管理系統(tǒng)

  • 一、系統(tǒng)介紹
  • 二、系統(tǒng)展示
    • 1.主界面
    • 2.全屏主界面
    • 3.放大圖片
    • 4.縮小圖片
    • 5.幻燈片放映
  • 三、系統(tǒng)實(shí)現(xiàn)
    • AutoPlay.java
    • FileNode.java
    • FullFrame.java
    • PFileSystemView.java
    • ThreadImages.java
  • 四、其他
    • 1.其他系統(tǒng)實(shí)現(xiàn)
      • JavaWeb系統(tǒng)系列實(shí)現(xiàn)
      • JavaSwing系統(tǒng)系列實(shí)現(xiàn)
    • 2.獲取源碼
    • 3.運(yùn)行項(xiàng)目
    • 4.備注
    • 5.聯(lián)系博主

一、系統(tǒng)介紹

本系統(tǒng)實(shí)現(xiàn)了對電腦目錄的讀取,實(shí)現(xiàn)電腦目錄的前進(jìn)后退功能;實(shí)現(xiàn)電子相冊的查看、重命名,復(fù)制,粘貼,刪除功能;實(shí)現(xiàn)電子相冊的上一張,下一張全屏播放,幻燈片播放,每2s一次,可以自己設(shè)置。界面良好。

二、系統(tǒng)展示

1.主界面

2.全屏主界面

3.放大圖片

4.縮小圖片

5.幻燈片放映

三、系統(tǒng)實(shí)現(xiàn)

AutoPlay.java

package com.sjsq;import java.util.Timer; import java.util.TimerTask;/*** * 自動(dòng)播放* * @author 浪客劍心* * @author shuijianshiqing** @date 2020-09-08 19:29**/public class AutoPlay {private int second;FullFrame frame;private final Timer timer = new Timer();// 設(shè)置播放時(shí)間間隔為2spublic AutoPlay(FullFrame fullFrame) {this.frame = fullFrame;second = 2;}public void start() {timer.schedule(new TimerTask() {public void run() {frame.Forward();frame.getJButton1().setEnabled(false);}}, second * 1000, second * 1000);}public void stop() {timer.cancel();} }

FileNode.java

package com.sjsq;import java.io.File; import java.io.IOException; import javax.swing.tree.DefaultMutableTreeNode;public class FileNode extends DefaultMutableTreeNode {private boolean explored_ = false;public FileNode(File file) {setUserObject(file);}public boolean getAllowChildren() {return isDirectory();}public boolean isLeaf() {return !isDirectory();}public File getFile() {return (File) getUserObject();}public boolean isExplored() {return explored_;}public boolean isDirectory() {File file = getFile();return file.isDirectory();}public String toString() {File file = getFile();String filename = file.toString();int index = filename.lastIndexOf("\\");return (index != -1 && index != filename.length() - 1) ? filename.substring(index + 1) : filename;}public String getString() {File file = getFile();String filename = file.getAbsolutePath();return filename;}public File getWorR() {File file = getFile();File file1 = file.getAbsoluteFile();return file1;}public String getWorR1() throws IOException {File file = getFile();String file1 = file.getPath();return file1;}public void explore() {if (!isDirectory()) {return;}if (!isExplored()) {File file = getFile();File[] children = file.listFiles();for (int i = 0; i < children.length; ++i) {if (children[i].isDirectory()) {add(new FileNode(children[i]));}}explored_ = true;}} }

FullFrame.java

package com.sjsq;import java.awt.Image; import java.io.File; import java.util.ArrayList;import javax.swing.GroupLayout; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.JToolBar; import javax.swing.LayoutStyle; import javax.swing.SwingConstants;/*** * 全屏* * @author shuijianshiqing** @date 2020-09-08 19:32**/ public class FullFrame extends JFrame {private JButton jButton1;private JButton jButton2;private JButton jButton3;private JButton jButton4;private JButton jButton5;private JButton jButton6;private JLabel jLabel1;private JScrollPane jScrollPane1;private JToolBar jToolBar1;ArrayList<File> ClickedFilePath = new ArrayList<File>();ArrayList<JTextField> ImagesNameTF = new ArrayList<JTextField>();ArrayList<JLabel> SmallLabels = new ArrayList<JLabel>();int SelectImage = 0;double CurrentMultiple = 1;int ImagesQuantity = 0;int flag = 0;AutoPlay play;String OpenFilePath;public FullFrame(ArrayList<File> ClickedFilePath, ArrayList<JTextField> ImagesNameTF, int SelectImage,int ImagesQuantity, ArrayList<JLabel> SmallLabels, String OpenFilePath) {initComponents();setTitle("電子相冊全屏操作頁面");setExtendedState(JFrame.MAXIMIZED_BOTH);this.ClickedFilePath = ClickedFilePath;this.ImagesNameTF = ImagesNameTF;this.SelectImage = SelectImage;this.ImagesQuantity = ImagesQuantity - 1;this.SmallLabels = SmallLabels;this.OpenFilePath = OpenFilePath;if (SelectImage == -1) {jButton2.setEnabled(false);jButton1.setEnabled(false);jButton5.setEnabled(false);jButton6.setEnabled(false);}if (SelectImage == 0) {jButton1.setEnabled(false);jButton1.setEnabled(false);}if (SelectImage == ImagesQuantity - 1) {jButton1.setEnabled(true);jButton2.setEnabled(false);jButton3.setEnabled(true);jButton4.setEnabled(true);jButton5.setEnabled(false);jButton6.setEnabled(false);}if (SelectImage != ImagesQuantity - 1 && SelectImage != 0 && SelectImage != -1) {jButton1.setEnabled(true);jButton2.setEnabled(true);jButton3.setEnabled(true);jButton4.setEnabled(true);jButton5.setEnabled(true);jButton6.setEnabled(true);}}public void Back() {if (SelectImage - 1 >= 0) {for (int i = 0; i < ClickedFilePath.size(); i++) {if (ClickedFilePath.get(i).getName().equals(ImagesNameTF.get(SelectImage - 1).getText())) {ImageIcon ic1 = new ImageIcon(ClickedFilePath.get(i).getAbsolutePath());Image im = ic1.getImage().getScaledInstance(ic1.getIconWidth(), ic1.getIconHeight(),Image.SCALE_DEFAULT);ImageIcon ic2 = new ImageIcon(im);getJLabel1().setIcon(ic2);}}SelectImage = SelectImage - 1;if (SelectImage == 0) {getJButton1().setEnabled(false);} else {getJButton1().setEnabled(true);jButton2.setEnabled(true);jButton3.setEnabled(true);jButton4.setEnabled(true);jButton5.setEnabled(true);jButton6.setEnabled(true);}}}public void Forward() {if (SelectImage + 1 <= ImagesQuantity) {for (int i = 0; i < ClickedFilePath.size(); i++) {if (ClickedFilePath.get(i).getName().equals(ImagesNameTF.get(SelectImage + 1).getText())) {ImageIcon ic1 = new ImageIcon(ClickedFilePath.get(i).getAbsolutePath());Image im = ic1.getImage().getScaledInstance(ic1.getIconWidth(), ic1.getIconHeight(),Image.SCALE_DEFAULT);ImageIcon ic2 = new ImageIcon(im);getJLabel1().setIcon(ic2);}}SelectImage = SelectImage + 1;if (SelectImage == ImagesQuantity) {jButton2.setEnabled(false);jButton5.setEnabled(false);jButton6.setEnabled(false);getJButton1().setEnabled(true);jButton3.setEnabled(true);jButton4.setEnabled(true);} else {jButton1.setEnabled(true);}}}public void Enlarge() {if (SelectImage == -1) {ImageIcon ic1 = new ImageIcon(OpenFilePath);double w = ic1.getIconWidth();double h = ic1.getIconHeight();Image im = ic1.getImage().getScaledInstance((int) (w * (CurrentMultiple + 0.25)),(int) (h * (CurrentMultiple + 0.25)), Image.SCALE_DEFAULT);ImageIcon ic2 = new ImageIcon(im);getJLabel1().setIcon(ic2);} else {if (SelectImage != flag) {CurrentMultiple = 1;}for (int i = 0; i < ClickedFilePath.size(); i++) {if (ClickedFilePath.get(i).getName().equals(ImagesNameTF.get(SelectImage).getText())) {ImageIcon ic1 = new ImageIcon(ClickedFilePath.get(i).getAbsolutePath());double w = ic1.getIconWidth();double h = ic1.getIconHeight();Image im = ic1.getImage().getScaledInstance((int) (w * (CurrentMultiple + 0.25)),(int) (h * (CurrentMultiple + 0.25)), Image.SCALE_DEFAULT);ImageIcon ic2 = new ImageIcon(im);getJLabel1().setIcon(ic2);}}}CurrentMultiple = CurrentMultiple + 0.25;flag = SelectImage;}public void Decrease() {if (SelectImage == -1) {ImageIcon ic1 = new ImageIcon(OpenFilePath);double w = ic1.getIconWidth();double h = ic1.getIconHeight();Image im = ic1.getImage().getScaledInstance((int) (w * (CurrentMultiple - 0.25)),(int) (h * (CurrentMultiple - 0.25)), Image.SCALE_DEFAULT);ImageIcon ic2 = new ImageIcon(im);getJLabel1().setIcon(ic2);} else {if (SelectImage != flag) {CurrentMultiple = 1;}for (int i = 0; i < ClickedFilePath.size(); i++) {if (ClickedFilePath.get(i).getName().equals(ImagesNameTF.get(SelectImage).getText())) {ImageIcon ic1 = new ImageIcon(ClickedFilePath.get(i).getAbsolutePath());double w = ic1.getIconWidth();double h = ic1.getIconHeight();Image im = ic1.getImage().getScaledInstance((int) (w * (CurrentMultiple - 0.25)),(int) (h * (CurrentMultiple - 0.25)), Image.SCALE_DEFAULT);ImageIcon ic2 = new ImageIcon(im);getJLabel1().setIcon(ic2);}}}CurrentMultiple = CurrentMultiple - 0.25;flag = SelectImage;}@SuppressWarnings("unchecked")private void initComponents() {jToolBar1 = new JToolBar();jButton1 = new JButton();jButton2 = new JButton();jButton3 = new JButton();jButton4 = new JButton();jButton5 = new JButton();jButton6 = new JButton();jScrollPane1 = new JScrollPane();jLabel1 = new JLabel();jToolBar1.setRollover(true);jButton1.setIcon(new ImageIcon(getClass().getResource("/images/2.JPG"))); // NOI18NjButton1.setFocusable(false);jButton1.setHorizontalTextPosition(SwingConstants.CENTER);jButton1.setVerticalTextPosition(SwingConstants.BOTTOM);jButton1.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {jButton1ActionPerformed(evt);}});jToolBar1.add(jButton1);jButton2.setIcon(new ImageIcon(getClass().getResource("/images/1.jpg")));jButton2.setFocusable(false);jButton2.setHorizontalTextPosition(SwingConstants.CENTER);jButton2.setVerticalTextPosition(SwingConstants.BOTTOM);jButton2.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {jButton2ActionPerformed(evt);}});jToolBar1.add(jButton2);jButton3.setIcon(new ImageIcon(getClass().getResource("/images/3.jpg"))); // NOI18NjButton3.setFocusable(false);jButton3.setHorizontalTextPosition(SwingConstants.CENTER);jButton3.setVerticalTextPosition(SwingConstants.BOTTOM);jButton3.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {jButton3ActionPerformed(evt);}});jToolBar1.add(jButton3);jButton4.setIcon(new ImageIcon(getClass().getResource("/images/4.jpg"))); // NOI18NjButton4.setFocusable(false);jButton4.setHorizontalTextPosition(SwingConstants.CENTER);jButton4.setVerticalTextPosition(SwingConstants.BOTTOM);jButton4.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {jButton4ActionPerformed(evt);}});jToolBar1.add(jButton4);jButton5.setIcon(new ImageIcon(getClass().getResource("/images/5.jpg"))); // NOI18NjButton5.setFocusable(false);jButton5.setHorizontalTextPosition(SwingConstants.CENTER);jButton5.setVerticalTextPosition(SwingConstants.BOTTOM);jButton5.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {jButton5ActionPerformed(evt);}});jToolBar1.add(jButton5);jButton6.setIcon(new ImageIcon(getClass().getResource("/images/6.jpg"))); // NOI18NjButton6.setFocusable(false);jButton6.setHorizontalTextPosition(SwingConstants.CENTER);jButton6.setVerticalTextPosition(SwingConstants.BOTTOM);jButton6.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {jButton6ActionPerformed(evt);}});jToolBar1.add(jButton6);jScrollPane1.setViewportView(jLabel1);GroupLayout layout = new GroupLayout(getContentPane());getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jToolBar1, GroupLayout.PREFERRED_SIZE, 382,GroupLayout.PREFERRED_SIZE).addContainerGap(278, Short.MAX_VALUE)).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 660, Short.MAX_VALUE));layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jToolBar1, GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)));pack();}@SuppressWarnings("empty-statement")private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {Decrease();}private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {Back();}private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {Forward();}private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {Enlarge();}private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {jButton6.setEnabled(true);jButton2.setEnabled(false);getJButton1().setEnabled(false);jButton3.setEnabled(false);jButton4.setEnabled(false);jButton5.setEnabled(false);play = new AutoPlay(this);play.start();}private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {play.stop();jButton2.setEnabled(true);getJButton1().setEnabled(true);jButton3.setEnabled(true);jButton4.setEnabled(true);jButton5.setEnabled(true);}public JLabel getJLabel1() {return jLabel1;}public void setJLabel1(JLabel jLabel1) {this.jLabel1 = jLabel1;}public JButton getJButton1() {return jButton1;} }

PFileSystemView.java

package com.sjsq;import java.io.File; import java.io.IOException; import javax.swing.filechooser.FileSystemView;/*** * 創(chuàng)建新文件* * @author shuijianshiqing** @date 2020-09-08 19:26**/class PFileSystemView extends FileSystemView {public File createNewFolder(File containingDir) throws IOException {return null;} }

ThreadImages.java

package com.sjsq;import java.awt.Image; import java.io.File; import java.util.ArrayList; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants;public class ThreadImages implements Runnable {ArrayList<JLabel> SmallLabels = new ArrayList<JLabel>();ArrayList<JTextField> SmallTextFields = new ArrayList<JTextField>();ArrayList<JPanel> SmallPanels = new ArrayList<JPanel>();JPanel ImagePanel;int i;ArrayList<File> ImageFiles;int k;ThreadImages(ArrayList<File> ImageFiles, int k, int i, ArrayList<JLabel> SmallLabels,ArrayList<JTextField> SmallTextFields, ArrayList<JPanel> SmallPanels, JPanel ImagePanel) {this.k = k;this.ImageFiles = ImageFiles;this.i = i;this.SmallLabels = SmallLabels;this.SmallTextFields = SmallTextFields;this.SmallPanels = SmallPanels;this.ImagePanel = ImagePanel;}public synchronized void run() {for (int j = k; j < i; j++) {ImageIcon ic1 = new ImageIcon(ImageFiles.get(j).getAbsolutePath());double h1 = ic1.getIconHeight();double w1 = ic1.getIconWidth();if (h1 < 77 && w1 < 100) {Image im = ic1.getImage().getScaledInstance((int) w1, (int) h1, Image.SCALE_DEFAULT);// 改變大小ImageIcon ic2 = new ImageIcon(im);// 從新得到一個(gè)固定圖片// SmallLabels.add(j, new JLabel());// SmallTextFields.add(j, new JTextField());SmallLabels.get(j).setIcon(ic2);ic2.setImageObserver(SmallLabels.get(j));SmallTextFields.get(j).setText(ImageFiles.get(j).getName());} else {if (h1 * 180 > w1 * 142) {Image im = ic1.getImage().getScaledInstance((int) (w1 / (h1 / 81)), 81, Image.SCALE_DEFAULT);// 改變大小ImageIcon ic2 = new ImageIcon(im);// 從新得到一個(gè)固定圖片SmallLabels.get(j).setIcon(ic2);ic2.setImageObserver(SmallLabels.get(j));SmallTextFields.get(j).setText(ImageFiles.get(j).getName());} else {Image im = ic1.getImage().getScaledInstance(105, (int) (h1 / (w1 / 105)), Image.SCALE_DEFAULT);// 改變大小final ImageIcon ic2 = new ImageIcon(im);// 從新得到一個(gè)固定圖片SmallLabels.get(j).setIcon(ic2);ic2.setImageObserver(SmallLabels.get(j));SmallTextFields.get(j).setText(ImageFiles.get(j).getName());}}ImagePanel.add(SmallPanels.get(j));if (ImageFiles.size() > 20) {SmallPanels.get(j).setBounds(j % 5 * 131, 1 + (j / 5 * 125), 120, 110);} else {SmallPanels.get(j).setBounds(j % 5 * 135, 1 + (j / 5 * 125), 120, 110);}SmallPanels.get(j).setLayout(new java.awt.BorderLayout(0, 0));SmallPanels.get(j).add(SmallLabels.get(j), java.awt.BorderLayout.CENTER);SmallPanels.get(j).add(SmallTextFields.get(j), java.awt.BorderLayout.PAGE_END);SmallTextFields.get(j).setBorder(null);SmallTextFields.get(j).setHorizontalAlignment(SwingConstants.CENTER);SmallTextFields.get(j).setEditable(false);if (j == 0) {SmallLabels.get(0).setDisplayedMnemonic(501);} else {SmallLabels.get(j).setDisplayedMnemonic(j);}SmallLabels.get(j).setHorizontalAlignment(SwingConstants.CENTER);SmallLabels.get(j).setOpaque(true);SmallLabels.get(j).setBackground(new java.awt.Color(244, 244, 244));}} }

四、其他

1.其他系統(tǒng)實(shí)現(xiàn)

JavaWeb系統(tǒng)系列實(shí)現(xiàn)

Java+JSP實(shí)現(xiàn)學(xué)生圖書管理系統(tǒng)
Java+JSP實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
Java+JSP實(shí)現(xiàn)用戶信息管理系統(tǒng)
Java+Servlet+JSP實(shí)現(xiàn)航空訂票系統(tǒng)
Java+Servlet+JSP實(shí)現(xiàn)房屋租賃管理系統(tǒng)
Java+Servlet+JSP實(shí)現(xiàn)學(xué)生選課管理系統(tǒng)
Java+Servlet+JSP實(shí)現(xiàn)學(xué)生成績管理系統(tǒng)
Java+Servlet+JSP實(shí)現(xiàn)寵物診所管理系統(tǒng)
Java+SSM+Easyui實(shí)現(xiàn)網(wǎng)上考試系統(tǒng)
Java+Springboot+H-ui實(shí)現(xiàn)營銷管理系統(tǒng)
Java+Springboot+Mybatis+Bootstrap實(shí)現(xiàn)網(wǎng)上商城系統(tǒng)

JavaSwing系統(tǒng)系列實(shí)現(xiàn)

Java+Swing實(shí)現(xiàn)斗地主游戲
Java+Swing實(shí)現(xiàn)圖書管理系統(tǒng)
Java+Swing實(shí)現(xiàn)醫(yī)院管理系統(tǒng)
Java+Swing實(shí)現(xiàn)倉庫管理系統(tǒng)
Java+Swing實(shí)現(xiàn)考試管理系統(tǒng)
Java+Swing實(shí)現(xiàn)通訊錄管理系統(tǒng)
Java+Swing實(shí)現(xiàn)停車場管理系統(tǒng)
Java+Swing實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
Java+Swing實(shí)現(xiàn)學(xué)生宿舍管理系統(tǒng)
Java+Swing實(shí)現(xiàn)學(xué)生選課管理系統(tǒng)
Java+Swing實(shí)現(xiàn)學(xué)生成績管理系統(tǒng)
Java+Swing實(shí)現(xiàn)學(xué)校教材管理系統(tǒng)
Java+Swing實(shí)現(xiàn)學(xué)校教務(wù)管理系統(tǒng)
Java+Swing實(shí)現(xiàn)企業(yè)人事管理系統(tǒng)
Java+Swing實(shí)現(xiàn)電子相冊管理系統(tǒng)
Java+Swing實(shí)現(xiàn)自助取款機(jī)(ATM)系統(tǒng)
Java+Swing實(shí)現(xiàn)超市管理系統(tǒng)-TXT存儲(chǔ)信息
Java+Swing實(shí)現(xiàn)寵物商店管理系統(tǒng)-TXT存儲(chǔ)信息

2.獲取源碼

點(diǎn)擊以下鏈接獲取源碼。
Java+Swing實(shí)現(xiàn)電子相冊管理系統(tǒng)源碼

3.運(yùn)行項(xiàng)目

請點(diǎn)擊以下鏈接,部署你的項(xiàng)目。這個(gè)項(xiàng)目沒有sql,可直接跳過sql部分。
Eclipse如何導(dǎo)入JavaSwing項(xiàng)目超詳細(xì)圖文教程
Eclipse如何導(dǎo)入JavaSwing項(xiàng)目超詳細(xì)視頻教程

4.備注

如有侵權(quán)請聯(lián)系我刪除。

5.聯(lián)系博主

左側(cè)關(guān)注微信公眾號(hào),里面有Java教程和一些Java資源。如果此文對您有幫助,請關(guān)注加點(diǎn)贊,謝謝!

總結(jié)

以上是生活随笔為你收集整理的Eclipse+Java+Swing实现电子相册管理系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。