| | |
setUndecorated/Dragging
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2008
Posts: 23
Reputation:
Solved Threads: 0
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);??
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)
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class emptyframe extends JFrame implements ActionListener{ private JButton JB = new JButton("button"); public emptyframe() { frameformat(); add(JB); JB.setBounds(100,50,200,50); } public void actionPerformed(ActionEvent e) { } private void frameformat() { setPreferredSize (new Dimension (582, 336)); setLayout (null); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); setLocation(300,250); setBackground(Color.black); setResizable(false); setUndecorated(true); pack(); } public static void main (String[] args) { new emptyframe().setVisible(true); } }
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. ![]() |
Other Threads in the Java Forum
- Previous Thread: Problem inserting IF" statements
- Next Thread: Writing to a file
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class classes client code component database derby design draw eclipse encryption error event exception fractal game givemetehcodez graphics gui homework html ide if_statement image inheritance input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception open-source oracle print printing problem program programming project property recursion reference ria scanner screen search server set size sms sort sourcelabs splash sql sqlite stop string swing testautomation threads time tree ui unicode validation windows





