943,712 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1592
  • Java RSS
Jan 20th, 2009
0

setUndecorated/Dragging

Expand Post »
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);??


java Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 0
Light Poster
rude04 is offline Offline
26 posts
since Jun 2008
Jan 20th, 2009
0

Re: setUndecorated/Dragging

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.
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Problem inserting IF" statements
Next Thread in Java Forum Timeline: Writing to a file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC