i m creating a JFrame with four buttons in its titleBar.
JFrame frame=new JFrame("custom JFrame with 4 buttons in title");
frame.setUndecorated(true);
JPanel button_panel=new JPanel(new FlowLayout(FlowLayout.LEFT));
JButton button_1=new JButton("+");
JButton button_2=new JButton("↑");
JButton button_3=new JButton("-");
JButton button_4=new JButton("system tray");
button_panel.add(button_1);
button_panel.add(button_2);
button_panel.add(button_3);
button_panel.add(button_4);
frame.getContentPane().add(button_panel,BorderLayout.NORTH);
now, i have a JFrame with four buttons in its titlebar.
but, how to give drag functionality to this custom JFrame?
is it the only solution?
Well, the only solution that I know of is to use MouseListeners.
For a more general solution you can check out Moving Windows which allows you to make any Swing component dragable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With