Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package uf.views.controll;
- import java.awt.Point;
- import java.awt.event.*;
- import javax.swing.JFrame;
- import uf.views.MainView;
- public class MainControll implements ActionListener {
- private MainView view;
- public MainControll() {}
- // construt.
- public MainControll(MainView view) {
- this.view = view;
- // listeners.
- view.getViewButtons().stream().forEach((b) -> {
- b.addActionListener(this);
- });
- // controle da janela undecorated.
- Point point = new Point();
- view.addMouseListener(new MouseAdapter(){
- @Override
- public void mousePressed(MouseEvent e) {
- point.x = e.getX();
- point.y = e.getY();
- }
- });
- // controle da janela undecorated.
- view.addMouseMotionListener(new MouseMotionAdapter(){
- @Override
- public void mouseDragged(MouseEvent e) {
- Point p = view.getFrame().getLocation();
- view.getFrame().setLocation(p.x + e.getX() - point.x, p.y + e.getY() - point.y);
- }
- });
- view.setVisible(true);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- switch(e.getActionCommand()){
- case "close": System.exit(0); break;
- case "min": view.setExtendedState(JFrame.ICONIFIED); break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement