0

This action listener is part of my code.

I want to prevent the user to change the jLabel1 ISBN when save button is pressed by generating a JOPTIONPANE DIALOG.

how can I do that?

   jLabel1.setText("ISBN:");

    jLabel2.setText("Title:");

    jLabel3.setText("Year:");

    jLabel4.setText("Author:");

    title.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            titleActionPerformed(evt);
        }
    });

    save.setText("Save");
    save.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {



             try
           {

              Integer.parseInt( jLabel3.getText());
           }
           catch( Exception e)
           {
                JOptionPane.showMessageDialog(null, "You have to input a valid year!");
           }





            saveActionPerformed(evt);
        }
    });
kamwo
  • 1,980
  • 1
  • 23
  • 32
Abdulla
  • 39
  • 1
  • 2
  • 6

0 Answers0