setUndecorated/Dragging

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2008
Posts: 23
Reputation: rude04 is an unknown quantity at this point 
Solved Threads: 0
rude04 rude04 is offline Offline
Newbie Poster

setUndecorated/Dragging

 
0
  #1
Jan 20th, 2009
i used setundecorated(true); to remove the buttons and border of the window,,the problem is the frame only stays where it is, because the title bar is removed i cant drag it around the screen anymore..

what code should i add to be able to drag it anywhere in the scree without removing the setundecorated(true);??


  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import javax.swing.event.*;
  5.  
  6.  
  7.  
  8. public class emptyframe extends JFrame implements ActionListener{
  9.  
  10.  
  11. private JButton JB = new JButton("button");
  12.  
  13. public emptyframe()
  14. {
  15.  
  16. frameformat();
  17.  
  18.  
  19. add(JB);
  20.  
  21.  
  22. JB.setBounds(100,50,200,50);
  23.  
  24. }
  25.  
  26. public void actionPerformed(ActionEvent e)
  27. {
  28.  
  29. }
  30.  
  31. private void frameformat()
  32. {
  33. setPreferredSize (new Dimension (582, 336));
  34. setLayout (null);
  35. setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
  36. setLocation(300,250);
  37. setBackground(Color.black);
  38. setResizable(false);
  39. setUndecorated(true);
  40. pack();
  41.  
  42.  
  43. }
  44.  
  45. public static void main (String[] args) {
  46.  
  47. new emptyframe().setVisible(true);
  48.  
  49.  
  50. }
  51. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 796
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 110
darkagn's Avatar
darkagn darkagn is offline Offline
Master Poster

Re: setUndecorated/Dragging

 
0
  #2
Jan 20th, 2009
What are you trying to achieve by making your JFrame undecorated? If you wish to remove the user's ability to resize the window, you can use the setResizable() method to stop them from doing this (which you have done). If you want to stop the user from closing the window, you can use the setDefaultCloseOperation() method to set the window to DO_NOTHING_ON_CLOSE. If you really want to remove the border, then I don't think you will be able to move the window, at least without some serious manipulation of the look and feel of your window.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC