Hello can you help me fixing this code? I want to create an archive of photos and I’ve done this code to arrange photos by seasons but the first part I think it’s ok but second no because in the moment that I press the button put in archive I want to show me a confirmation that my photo was put in archive and to ask me if I want to put other photos I’ve written that but that part doesn’t show …..I also wanted to add a part of code that I add 2 other buttons(I know this part) that in the moment that I press for ex “show” it shows me the information about the photo.’ve been struggling with this and I’ve just learnt GUI and I have to do this
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class photoarchive extends JFrame implements ActionListener{
static String[] archive1={"december","january","february"};
static String[] archive2={"photo in june ","july ","august"};
static String[] archive3={"photo in september ","in october","in november "};
static String[] archive4={"photo in march","april" ,"may"};
JLabel nrphoto=new JLabel("NR photo ");
JTextField inrfoto=new JTextField(7);
JPanel namePanel=new JPanel();
JPanel nrfotoPanel=new JPanel();
JRadioButton archiva1= new JRadioButton("winter archive ");
JRadioButton archiva2= new JRadioButton("summer archive ");
JRadioButton archiva3= new JRadioButton("autumn archive");
JRadioButton archiva4= new JRadioButton("spring archive");
JButton putinarchive = new JButton("put in archive");
public photoarchive ()
{super("photoarchive");
setSize(500,250);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel name =new JLabel("name of photo");
JTextField inname=new JTextField(100);
ButtonGroup fotoGroup=new ButtonGroup();
fotoGroup.add(archiva1);
fotoGroup.add(archiva2);
fotoGroup.add(archiva3);
fotoGroup.add(archiva4);
JPanel fotoPanel=new JPanel();
fotoPanel.setLayout(new BoxLayout(fotoPanel,BoxLayout.Y_AXIS));
fotoPanel.add(archiva1);
fotoPanel.add(archiva2);
fotoPanel.add(archiva3);
fotoPanel.add(archiva4);
Container content=getContentPane();
FlowLayout lay=new FlowLayout(FlowLayout.LEFT);
content.setLayout(lay);
inrfoto.addActionListener(this);
archiva1.addActionListener(this);
archiva2.addActionListener(this);
archiva3.addActionListener(this);
archiva4.addActionListener(this);
namePanel.add(name);
namePanel.add(inname);
nrfotoPanel.add(nrphoto);
nrfotoPanel.add(inrfoto);
content.add(namePanel);
content.add(nrfotoPanel);
content.add(putinarchive);
content.add(fotoPanel);
Component pergjigje = null;
content.add(pergjigje);
setContentPane(content);}
public void actionPerformed(ActionEvent event)
{String userln;
userln=nrphoto.getText();
JLabel pergjigje = null;
if(event.getSource()==archiva1)
{int i=0;
if(i<archive1.length){
pergjigje.setText("foto"+archive1[i]+"put on archive ");i++;}
int answer=JOptionPane.showConfirmDialog(null, "would you like to put another photo?");
if(answer==JOptionPane.YES_OPTION){actionPerformed (event);}
else
if(answer==JOptionPane.NO_OPTION){setDefaultCloseO peration(JFrame.EXIT_ON_CLOSE);}
}
else{JOptionPane.showMessageDialog(null,"thank you");}
if(event.getSource()==archiva2)
{int i=0;
if(i<archive2.length)
{archive2[i]=archive2[i+1];pergjigje.setText("foto"+archive2[i]+"put on archive ");i++;}
int answer=JOptionPane.showConfirmDialog(null,"would you like to put another photo?");
if(answer==JOptionPane.YES_OPTION){actionPerformed (event);}
else
if(answer==JOptionPane.NO_OPTION){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
}
else{JOptionPane.showMessageDialog(null,"thank you");}
if(event.getSource()==archiva3)
{int i=0;
if(i<archive3.length)
{archive3[i]=archive3[i+1];pergjigje.setText("foto"+archive3[i]+"put on archive");i++;}
int answer=JOptionPane.showConfirmDialog(null,"would you like to put another photo?");
if(answer==JOptionPane.YES_OPTION){actionPerformed (event);}
else
if(answer==JOptionPane.NO_OPTION){setDefaultCloseO peration(JFrame.EXIT_ON_CLOSE);}
else{JOptionPane.showMessageDialog(null,"thank you");}
{if(event.getSource()==archiva4)
{
if(i<archive4.length)
{archive4[i]=archive4[i+1];pergjigje.setText("foto"+archive4[i]+"u vendos ne arkiv");i++;}
int answer1 =JOptionPane.showConfirmDialog(null,"would you like to put another photo?");
if(answer1==JOptionPane.YES_OPTION){actionPerforme d(event);}
else
if(answer1==JOptionPane.NO_OPTION){setDefaultClose Operation(JFrame.EXIT_ON_CLOSE);}
}
else{JOptionPane.showMessageDialog(null,"thank you");}
}}}
public static void main(String[] args) {
// TODO Auto-generated method stub
photoarchive arkivim=new photoarchive();
}
}