You might want to try this, but you need to add a functionality to close the window.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Map.Entry;
import javax.swing.*;
public class AppWindow extends JFrame {
Map<Boolean, String> mousePoint;
private String direction;
public AppWindow() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 570, 337);
setUndecorated(true);
getContentPane().setBackground(new Color(33, 115, 70));
getContentPane().setLayout(null);
setLocationRelativeTo(null);
setVisible(true);
setMinimumSize(new Dimension(100, 100));
getContentPane().addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
mousePoint = new HashMap<Boolean, String>();
mousePoint.put(e.getY() < 5, "N");
mousePoint.put(e.getX() > (getWidth() - 5), "E");
mousePoint.put(e.getY() > (getHeight() - 5), "S");
mousePoint.put(e.getX() < 5, "W");
mousePoint.put(e.getY() < 5 && e.getX() > (getWidth() - 5), "NE");
mousePoint.put(e.getY() > (getHeight() - 5) && e.getX() > (getWidth() - 5), "SE");
mousePoint.put(e.getY() > (getHeight() - 5) && e.getX() <= 5, "SW");
mousePoint.put(e.getY() < 5 && e.getX() < 5, "NW");
for (Entry<Boolean, String> item : mousePoint.entrySet()) {
if (item.getKey()) {
direction = item.getValue();
switch (item.getValue()) {
case "N":
setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
break;
case "E":
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
break;
case "S":
setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
break;
case "W":
setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
break;
case "NE":
setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
break;
case "SE":
setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
break;
case "SW":
setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
break;
case "NW":
setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
break;
}
} else {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
}
@Override
public void mouseDragged(MouseEvent e) {
if (!getCursor().equals(Cursor.getDefaultCursor())) {
switch (direction) {
case "N":
if (e.getYOnScreen() > getY()) {
setBounds(getX(), e.getYOnScreen(), getWidth(), getHeight() - (e.getYOnScreen() - getY()));
} else {
setBounds(getX(), e.getYOnScreen(), getWidth(), getHeight() + (getY() - e.getYOnScreen()));
}
break;
case "E":
setBounds(getX(), getY(), e.getX(), getHeight());
break;
case "S":
setBounds(getX(), getY(), getWidth(), e.getY());
break;
case "W":
if (e.getXOnScreen() > getX()) {
setBounds(e.getXOnScreen(), getY(), getWidth() - (e.getXOnScreen() - getX()), getHeight());
} else {
setBounds(e.getXOnScreen(), getY(), getWidth() + (getX() - e.getXOnScreen()), getHeight());
}
break;
case "NE":
setBounds(getX(), getY(), e.getX(), getHeight());
if (e.getYOnScreen() > getY()) {
setBounds(getX(), e.getYOnScreen(), getWidth(), getHeight() - (e.getYOnScreen() - getY()));
} else {
setBounds(getX(), e.getYOnScreen(), getWidth(), getHeight() + (getY() - e.getYOnScreen()));
}
break;
case "SE":
setBounds(getX(), getY(), e.getX(), e.getY());
break;
case "SW":
setBounds(getX(), getY(), getWidth(), e.getY());
if (e.getXOnScreen() > getX()) {
setBounds(e.getXOnScreen(), getY(), getWidth() - (e.getXOnScreen() - getX()), getHeight());
} else {
setBounds(e.getXOnScreen(), getY(), getWidth() + (getX() - e.getXOnScreen()), getHeight());
}
break;
case "NW":
if (e.getYOnScreen() > getY()) {
setBounds(getX(), e.getYOnScreen(), getWidth(), getHeight() - (e.getYOnScreen() - getY()));
} else {
setBounds(getX(), e.getYOnScreen(), getWidth(), getHeight() + (getY() - e.getYOnScreen()));
}
if (e.getXOnScreen() > getX()) {
setBounds(e.getXOnScreen(), getY(), getWidth() - (e.getXOnScreen() - getX()), getHeight());
} else {
setBounds(e.getXOnScreen(), getY(), getWidth() + (getX() - e.getXOnScreen()), getHeight());
}
break;
}
}
}
});
}
}