📄 seeimage.java
字号:
.add(jButton5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jTextField1)) .add(56, 56, 56) .add(jButton6)))) .add(layout.createSequentialGroup() .add(39, 39, 39) .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1237, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.linkSize(new java.awt.Component[] {jButton1, jButton2, jButton3, jButton4, jButton7}, org.jdesktop.layout.GroupLayout.HORIZONTAL); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jButton7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jButton5) .add(jButton6)) .add(layout.createSequentialGroup() .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel2) .add(59, 59, 59)) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE) .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE) .add(jButton3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE) .add(jButton4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)) .add(28, 28, 28))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(1017, 1017, 1017) .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(layout.createSequentialGroup() .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jToolBar2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 676, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed// TODO add your handling code here: nextpicture(); }//GEN-LAST:event_jButton4ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed// TODO add your handling code here: lastpicture(); }//GEN-LAST:event_jButton3ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed// TODO add your handling code here: mythread df=new mythread(); df.start(); }//GEN-LAST:event_jButton2ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed// TODO add your handling code here: OpenImage(); }//GEN-LAST:event_jButton1ActionPerformedprivate void jLabel1AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jLabel1AncestorAdded// TODO add your handling code here:}//GEN-LAST:event_jLabel1AncestorAddedprivate void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed// TODO add your handling code here: setVisible(false);}//GEN-LAST:event_jMenuItem1ActionPerformedprivate void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed// TODO add your handling code here: this.setVisible(false);}//GEN-LAST:event_jButton7ActionPerformedprivate void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed// TODO add your handling code here: File file=new File(changdizhi); if(jTextField1.getText()!="") { file.renameTo(new File(imagepath+"\\"+jTextField1.getText())); JOptionPane.showMessageDialog(null,"命名为"+jTextField1.getText(),"命名成功",JOptionPane.INFORMATION_MESSAGE); }}//GEN-LAST:event_jButton5ActionPerformedprivate void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed// TODO add your handling code here: File file=new File(changdizhi); file.delete(); JOptionPane.showMessageDialog(null,"删除了"+jTextField1.getText(),"删除成功",JOptionPane.INFORMATION_MESSAGE); }//GEN-LAST:event_jButton6ActionPerformed /* */ private void OpenImage() { int yn=fileChooser.showOpenDialog(this); imageName=fileChooser.getSelectedFile().getName(); this.setTitle(imageName); if(yn==JFileChooser.APPROVE_OPTION){ String Imagepath=fileChooser.getCurrentDirectory()+"\\"+fileChooser.getSelectedFile().getName(); ImageIcon imageicon=new ImageIcon(Imagepath); int k=imageicon.getIconWidth()*this.jLabel1.getSize().height; imageicon.setImage(imageicon.getImage().getScaledInstance(k/imageicon.getIconHeight(),this.jLabel1.getSize().height,java.awt.Image.SCALE_DEFAULT)); //��� this.jLabel1.setIcon(imageicon); } else return; } public void showImageIcon(){ int i=0; // File imagepath=fileChooser.getCurrentDirectory(); File [] filearray=imagepath.listFiles(); while(filearray[i]!=null){ if(accept(filearray[i].getPath())){ imageName = filearray[i].getName(); this.setTitle(imageName); ImageIcon imageicon=new ImageIcon(filearray[i].getPath()); int k=imageicon.getIconWidth()*(jLabel1.getSize().height-12); imageicon.setImage(imageicon.getImage().getScaledInstance(k/imageicon.getIconHeight(),jLabel1.getSize().height-12,java.awt.Image.SCALE_DEFAULT)); jLabel1.setIcon(imageicon); } try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(SeeImage.class.getName()).log(Level.SEVERE, null, ex); } i++; } } class mythread extends Thread{ public void run() { showImageIcon(); try { sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } } private boolean accept(String fileName) { boolean flag=false; if(fileName.toLowerCase().endsWith(".jpg")){ flag=true; } else if(fileName.toLowerCase().endsWith(".jpeg")){ flag=true; } else if(fileName.toLowerCase().endsWith(".gif")){ flag=true; } return flag; } private void lastpicture() { // File imagepath=fileChooser.getCurrentDirectory(); // File imagepath=new File (FolderExplorer.dizhi); File [] filearray=imagepath.listFiles(); int n= filearray.length; System.out.println(filearray.length); for(int i=0;i<n;i++){ if(filearray[i].getName().equals(imageName)){ if(i==0) { break; } else{ ImageIcon imageicon=new ImageIcon(filearray[i-1].getPath()); imageName=filearray[i-1].getName(); this.setTitle(imageName); int k=imageicon.getIconWidth()*(jLabel1.getSize().height-12); imageicon.setImage(imageicon.getImage().getScaledInstance(k/imageicon.getIconHeight(),jLabel1.getSize().height-12,java.awt.Image.SCALE_DEFAULT)); jLabel1.setIcon(imageicon); } } } } private void nextpicture() { // File imagepath=fileChooser.getCurrentDirectory(); // File imagepath=new File (FolderExplorer.dizhi); File [] filearray=imagepath.listFiles(); int n= filearray.length; for(int i=n-1;i>=0;i--){ if(filearray[i].getName().equals(imageName)){ if(i==n-1) { break; } else{ ImageIcon imageicon=new ImageIcon(filearray[i+1].getPath()); imageName=filearray[i+1].getName(); this.setTitle(imageName); int k=imageicon.getIconWidth()*(jLabel1.getSize().height-12); imageicon.setImage(imageicon.getImage().getScaledInstance(k/imageicon.getIconHeight(),jLabel1.getSize().height-12,java.awt.Image.SCALE_DEFAULT)); jLabel1.setIcon(imageicon); } } } } class JPGFiliter extends FileFilter{ boolean flag; public boolean accept(File file){ if(file.getName().toLowerCase().endsWith(".jpg")){ flag=true; } else if(file.isDirectory()){ flag=true; } else{flag=false;} return flag; } public String getDescription(){ return "JPG �ļ�"; } } class GIFFiliter extends FileFilter{ boolean flag; public boolean accept(File file){ if(file.getName().toLowerCase().endsWith(".gif")){ flag=true; } else if(file.isDirectory()){ flag=true; } else{flag=false;} return flag; } public String getDescription(){ return "GIF �ļ�"; } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JDesktopPane jDesktopPane1; private javax.swing.JFrame jFrame1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu10; private javax.swing.JMenu jMenu11; private javax.swing.JMenu jMenu12; private javax.swing.JMenu jMenu13; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenu jMenu4; private javax.swing.JMenu jMenu5; private javax.swing.JMenu jMenu6; private javax.swing.JMenu jMenu7; private javax.swing.JMenu jMenu8; private javax.swing.JMenu jMenu9; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuBar jMenuBar2; private javax.swing.JMenuBar jMenuBar3; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JSeparator jSeparator4; private javax.swing.JSeparator jSeparator5; private javax.swing.JSeparator jSeparator6; private javax.swing.JSeparator jSeparator7; private javax.swing.JSeparator jSeparator8; private javax.swing.JSeparator jSeparator9; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JTextField jTextField1; private javax.swing.JToggleButton jToggleButton1; private javax.swing.JToolBar jToolBar1; private javax.swing.JToolBar jToolBar2; private javax.swing.JTree jTree1; private java.awt.Menu menu1; private java.awt.MenuBar menuBar1; // End of variables declaration//GEN-END:variables javax.swing.JFileChooser fileChooser=new javax.swing.JFileChooser(); private File imagepath=new File (FolderExplorer.dizhi); private String[] iconFileName; // private String imageName; private Thread t=new Thread();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -