import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ImageWindow extends JFrame implements ActionListener {
//Buttons
JButton al = new JButton("Align Left");
JButton ac = new JButton("Align Center");
JButton ar = new JButton("Align Right");
JButton res = new JButton("Resize");

//Resizing Form
JLabel txt2 = new JLabel("Height: ", SwingConstants.LEFT);
JLabel txt1 = new JLabel("Width: ", SwingConstants.LEFT);

JTextField tt1 = new JTextField(1);
JTextField tt2 = new JTextField(1);

//MENU
JMenuItem j1 = new JMenuItem("Reset");
JMenuItem j2 = new JMenuItem("Exit");
JMenuBar b = new JMenuBar();
JMenu m1 = new JMenu("Options");

//PANELS
JPanel pNorth = new JPanel();
JPanel pEast= new JPanel();
JPanel pWest = new JPanel();
JPanel pSouth = new JPanel();
//JPanel pCent = new JPanel();
//image settings
ImageIcon img = new ImageIcon("adabyron.jpg");
Image originalImage = img.getImage();
JLabel label = new JLabel(img);

//CONSTRUCTOR

public ImageWindow() {
super("Image Application");
 

Container pMain = this.getContentPane();
setSize(450,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pMain.setLayout( new BorderLayout());

//image
label.setIcon(img);


//Menu 
m1.add(j1);
m1.addSeparator();
m1.add(j2);
b.add(m1);

pNorth.add(al);
pNorth.add(ac);
pNorth.add(ar);

pMain.add(pNorth, BorderLayout.NORTH);
//pMain.add(pEast, BorderLayout.EAST);
//pMain.add(pWest, BorderLayout.WEST);

pMain.add(label, BorderLayout.CENTER);

pSouth.setLayout( new GridLayout(3,2,15,1));
pSouth.add(txt1);
pSouth.add(tt1);
pSouth.add(txt2);
pSouth.add(tt2);
pSouth.add(res);

pMain.add(pSouth, BorderLayout.SOUTH);

//Listeners- Buttons
j1.addActionListener(this);
j2.addActionListener(this);
al.addActionListener(this);
ac.addActionListener(this);
ar.addActionListener(this);

res.addActionListener(this);

setJMenuBar(b);

setVisible(true);
}

//edo dino actions se ola ta buttons pou exo

public void actionPerformed(ActionEvent evt) {

Object s = evt.getSource();

if( s == j2 )    System.exit(0); 
if( s == j1 )       repaint();

if( s == al ) {     label.setHorizontalAlignment(JLabel.LEFT);      }
if( s == ac ) {     label.setHorizontalAlignment(JLabel.CENTER);      }
if( s == ar ) {     label.setHorizontalAlignment(JLabel.RIGHT);      }

if( s == res ) {    //img.getImage().getScaledInstance(1000,1000, 1);   
                    //ImageIcon img = new ImageIcon("img.jpg");
                   //Image originalImage =

                    img.getImage().getScaledInstance(1000, 1000, 2); // tou dino 1000,1000 gia test arxika

  
 }


}
public static void main() {

  ImageWindow mainW = new ImageWindow(); 
  
}

}