Guest User

Main.java

a guest
Jul 17th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.01 KB | None | 0 0
  1. import java.io.IOException;
  2.  
  3. /**
  4.  *
  5.  * @author dubstep
  6.  */
  7. public class Main extends javax.swing.JFrame {
  8.  
  9.     /**
  10.      * Creates new form Main
  11.      */
  12.     public Main() {
  13.         initComponents();
  14.     }
  15.  
  16.     /**
  17.      * This method is called from within the constructor to initialize the form.
  18.      * WARNING: Do NOT modify this code. The content of this method is always
  19.      * regenerated by the Form Editor.
  20.      */
  21.     @SuppressWarnings("unchecked")
  22.     // <editor-fold defaultstate="collapsed" desc="Generated Code">
  23.     private void initComponents() {
  24.  
  25.         Prev = new javax.swing.JButton();
  26.         Next = new javax.swing.JButton();
  27.         ImgLab = new javax.swing.JLabel();
  28.         iG = new IcoGen();
  29.  
  30.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  31.  
  32.         Prev.setText("Prev");
  33.         Prev.addActionListener(new java.awt.event.ActionListener() {
  34.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  35.                 PrevActionPerformed(evt);
  36.             }
  37.         });
  38.  
  39.         Next.setText("Next");
  40.         Next.setToolTipText("");
  41.         Next.addActionListener(new java.awt.event.ActionListener() {
  42.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  43.                 NextActionPerformed(evt);
  44.             }
  45.         });
  46.  
  47.         ImgLab.setText("Img here");
  48.  
  49.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  50.         getContentPane().setLayout(layout);
  51.         layout.setHorizontalGroup(
  52.                 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  53.                         .addGroup(layout.createSequentialGroup()
  54.                                 .addComponent(Prev, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)
  55.                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
  56.                                 .addComponent(Next, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE))
  57.                         .addGroup(layout.createSequentialGroup()
  58.                                 .addComponent(ImgLab, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  59.                                 .addContainerGap())
  60.         );
  61.         layout.setVerticalGroup(
  62.                 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  63.                         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  64.                                 .addComponent(ImgLab, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
  65.                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  66.                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  67.                                         .addComponent(Prev, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
  68.                                         .addComponent(Next, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
  69.         );
  70.  
  71.         pack();
  72.     }// </editor-fold>
  73.     public void nextSlide(int currentSlide) {
  74.         if (currentSlide < iG.icons.length - 1) {
  75.             currentSlide++;
  76.             ImgLab.setIcon(iG.icons[currentSlide]);
  77.         }
  78.     }
  79.     public void PrevSlide(int currentSlide) {
  80.         if (currentSlide < iG.icons.length - 1) {
  81.             currentSlide--;
  82.             ImgLab.setIcon(iG.icons[currentSlide]);
  83.         }
  84.     }
  85.  
  86.     private void PrevActionPerformed(java.awt.event.ActionEvent evt) {
  87.         // TODO add your handling code here:
  88.         PrevSlide(currentSlide);
  89.     }
  90.  
  91.     private void NextActionPerformed(java.awt.event.ActionEvent evt) {
  92.         // TODO add your handling code here:
  93.         nextSlide(currentSlide);
  94.     }
  95.  
  96.     /**
  97.      * @param args the command line arguments
  98.      */
  99.     public static void main(String args[]) throws IOException {
  100.         /* Set the Nimbus look and feel */
  101.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  102.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  103.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  104.          */
  105.         IcoGen IcoG = new IcoGen();
  106.         IcoG.ListFiles();
  107.         IcoG.writeToFile();
  108.         IcoG.icoRead();
  109.         try {
  110.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  111.                 if ("Nimbus".equals(info.getName())) {
  112.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  113.                     break;
  114.                 }
  115.             }
  116.         } catch (ClassNotFoundException ex) {
  117.             java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  118.         } catch (InstantiationException ex) {
  119.             java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  120.         } catch (IllegalAccessException ex) {
  121.             java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  122.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  123.             java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  124.         }
  125.         //</editor-fold>
  126.  
  127.         /* Create and display the form */
  128.         java.awt.EventQueue.invokeLater(new Runnable() {
  129.             public void run() {
  130.                 new Main().setVisible(true);
  131.             }
  132.         });
  133.     }
  134.  
  135.     // Variables declaration - do not modify
  136.     private javax.swing.JLabel ImgLab;
  137.     private javax.swing.JButton Next;
  138.     private javax.swing.JButton Prev;
  139.     private int currentSlide = -1;
  140.     private IcoGen iG;
  141.     // End of variables declaration
  142. }
Advertisement
Add Comment
Please, Sign In to add comment