Neon Tetras 24 Newbie Poster

Hi guys.
I decided to post this simple Photo viewer application.
Its strictly for beginners, and cab be improved.

    /**
     *
     * @author Neon Tetras
     */
    import java.awt.Image;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;

    public class ImageViewer extends javax.swing.JFrame {

        /**
         * Class constructor: ImageViewer
         */
        public ImageViewer() {
            initComponents();

            listFiles(Path);    //Lists all the files in the directory on window opening

            setLabelIcon(Path,filenames[position]); //sets the label to display the first
                                                    //image in the directory on window opening.
            PreviousButton.setEnabled(false);
        }
        /**
         *Initialize components
         */
        private void initComponents() {
            setTitle("Image Viewer");
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setLayout(new java.awt.BorderLayout());// The layout is BorderLayout
            //setBorder(javax.swing.BorderFactory.createEtchedBorder());
            setBackground(java.awt.Color.GRAY);

            picLabel = new javax.swing.JLabel();        //Create the Label to display the picture
            picLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            picLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

            PreviousButton = new javax.swing.JButton();
            PreviousButton.setText("Previous");
            PreviousButton.setIconTextGap(10); //Distance between the icon and text is 10

            PreviousButton.addActionListener(new java.awt.event.ActionListener() { //Register an actionListener for the PreviousButton
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    PreviousButtonActionPerformed(evt);
                }
            });

            NextButton = new javax.swing.JButton();
            NextButton.setPreferredSize(PreviousButton.getPreferredSize());
            NextButton.setText("Next");
            NextButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
            NextButton.setIconTextGap(10); //Distance between the icon and text is 10

            NextButton.addActionListener(new java.awt.event.ActionListener() {  //Registers an actionListener for the NextButton
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    NextButtonActionPerformed(evt);
                }
            });

            javax.swing.Box vbox = javax.swing.Box.createVerticalBox(); //VerticalBox to hold the pictureLabel and the buttons

            vbox.add(javax.swing.Box.createVerticalStrut(30));
            vbox.add(picLabel);
            vbox.add(javax.swing.Box.createVerticalStrut(50));

            javax.swing.JPanel prev_next_pane = new javax.swing.JPanel(); //Panel to hold the Previous and Next buttons.

            java.awt.FlowLayout flow = new java.awt.FlowLayout(java.awt.FlowLayout.CENTER);
            flow.setHgap(30);
            prev_next_pane.setLayout(flow);

            prev_next_pane.add(PreviousButton);
            prev_next_pane.add(NextButton);
            prev_next_pane.setOpaque(false);

            vbox.add(prev_next_pane); //Add the panel to the verticalBox
            add(vbox);

        java.awt.Toolkit theKit = getToolkit();
        java.awt.Dimension size = theKit.getScreenSize();

        setLocation(size.width/5,size.height/10);
        setMinimumSize(new java.awt.Dimension(900,600));
        //setMaximumSize(new Dimension(size.width/4 +  50,size.height/4));

          //pack();
        }//END:initComponents

        /**
         *Handler for previous button
         */
        private …
JamesCherrill commented: Good example of Java perogramming. Well done +15
Begginnerdev commented: Nice post! +9
Neon Tetras 24 Newbie Poster

I'm working on a Grade Point Average Calculator.

The user just have to Select the number of courses offered, then select the grade obtain in the different courses by choosing the appropriate grade from the Choice Box.

The problem with my application is that, if the user mistakenly selects "A" instead of "B", then he corrects his mistake by selecting "B", the program sums up all the selections, including the wrong selection. So the calculation ends up being wrong.

Another proble with my application is that, u can't select an item twice. i.e if a user, selects "A" in the first Choice box, he can't select "A" again in the same Choice box, in case he wants to do another calculation.

This is the source code for the gradeChoice class.....

import java.awt.*;

import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;

import javax.swing.*;
/*
 *
 *@author Anokam Kingsley
 */

    GradeChoice(){
        super();

            final String[] Grades = {"Grades","A","A-","B+","B","B-","C+","C","C-","D","F"};

            for(String grades : Grades){
                add(grades);
                }

            addItemListener(new ItemListener(){

                             public void itemStateChanged(ItemEvent e){

                                    String gradeString = getSelectedItem();
                                     switch(gradeString){
                                     case "A" :
                                     gradeMark = 4.00;
                                     break;
                                     case "A-":
                                     gradeMark = 3.67;
                                     break;
                                     case "B+":
                                     gradeMark = 3.34;
                                     break;
                                     case "B":
                                     gradeMark = 3.00;
                                     break;
                                     case "B-":
                                     gradeMark = 2.67;
                                     break;
                                     case "C+":
                                      gradeMark = 2.34;
                                     break;
                                     case "C":
                                      gradeMark = 2.00;
                                     break;
                                     case "C-": 
                                      gradeMark = 1.67;
                                     break;
                                     case "D":
                                      gradeMark = 1.00;
                                     break;
                                     case "F":
                                      gradeMark = 0.00;
                                     break;
                                     default:
                                     System.out.println("Error!!");                         
                                     } 

                                    Scores += gradeMark;

                                }}); //End of addItemListener

                         }//End of GradeChoice constructor

                                 static double gradeMark,Scores;;

    }// End of …