I've been making an undecorated JFrame so far and I was wondering if it's possible to move the undecorated JFrame by holding click on a JPanel.
Here is the source code I'm working on.
private static void createFrame()
{
JFrame frame = new JFrame("Text Frame");
frame.setLayout(null);
frame.setSize(500,300);
frame.setUndecorated(true);
JPanel panel = new JPanel();
panel.setBounds(0, 2, 500, 50);
panel.setBackground(new Color(60, 65, 70));
frame.add(panel);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
What I want to do is: Click and hold my cursor at the JPanel area to be able to move the JFrame.
I did some research and came across to a similar question: Moving undecorated window by clicking on JPanel
I don't understand how to integrate the code provided (by user Sorter) on my code.
Or are there another solutions?
The solution provided can easily be integrated into your example.
Just add Sorter's example as a separate class.
Then change
JPanel panel = new JPanel();
to
JPanel panel = new MotionPanel(frame);
The panel should now be movable.