How to stop the Dialog from being dragged

I was hoping that someone could tell me when calling a Dialog from Jframe, a how to stop the Dialog from being dragged
while a dialog is showing.
When it is visible I can still click and drag the Dialog
I want to set it so you can not drag it until the dialog has be closed.

If you don't have access to the parent frame, a "hack" that usually works:
Frame frame = Frame.getFrames()[0];
if (null != frame && frame instanceof JFrame){
JFrame jf = (JFrame)frame;
JDialog jd = new JDialog(jf, "title");
... code here ...
As each JFrame (or Frame) is opened, its stored in the array of Frames that you can get. Same thing with Dialog.getDialogs(). Almost always, at least so far for me I've never had this problem, the [0] index is the main window opened, or the parent/top frame. I'd put the check in there to be safe and make sure its a JFrame and usually you'll only have the one JFrame.

Similar Messages

  • How can I stop the cursor from being dragged outside the bounds of an intensity graph in LV 7.1?

    Currently, an intensity graph cursor can be dragged outside the graph bounds, and the cursor position continues to change as if the graph had no bounds.

    You can maintain the cursor (and the graph scales...) between defined boundaries programmatically, using an attribute node. Not a very elegant solution, since there is some quivering. See the example.vi.
    Of course, if the user need to modify the scales (zoom in/out...), there will be some additional work ! :-)
    Hope this help.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Bound_cursor.vi ‏51 KB

  • Stop the Frame from being able to be dragged

    Hi all
    I was hoping that someone could tell me how to stop the frame from being dragged
    while a dialog is showing.
    I am using this code to call the dialog.
    When is is visible I can still click and drag the frame behind it.
    I want to set it so you can not drag it until the dialog has be closed.
        public void runStartup() {
            Login dlg = new Login(this, "Login", true);
            Dimension dlgSize = dlg.getPreferredSize();
            Dimension frmSize = getSize();
            Point loc = getLocation();
            dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                            (loc.y + 22));
            dlg.setModal(true);
            dlg.pack();
            dlg.show();
        }

    here is the Login Class
    package build0_0_1.dialogs;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    import java.awt.*;
    import com.borland.jbcl.layout.XYLayout;
    import com.borland.jbcl.layout.*;
    import javax.swing.JLabel;
    import javax.swing.JComboBox;
    import javax.swing.JPasswordField;
    import javax.swing.JButton;
    import javax.swing.ImageIcon;
    import build0_0_1.images.image_pics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusAdapter;
    import build0_0_1.mysql.MYSQLDAO;
    import build0_0_1.Command;
    import javax.swing.*;
    import java.sql.SQLException;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Login extends JDialog {
        ImageIcon back;
        MYSQLDAO mysqlDAO;
        Command command;
        JPanel panel1 = new JPanel();
        XYLayout xYLayout1 = new XYLayout();
        JLabel loginLabel = new JLabel();
        JLabel nameLabel = new JLabel();
        JLabel passwordLabel = new JLabel();
        JComboBox jComboBox1 = new JComboBox();
        JPasswordField passwordField = new JPasswordField();
        JButton loginButton = new JButton();
        JButton cancelButton = new JButton();
        JLabel backLabel = new JLabel();
        JLabel logoLabel = new JLabel();
        JComboBox locationComboBox = new JComboBox();
        JLabel locationLabel = new JLabel();
        public Login(Frame frame, String string, boolean _boolean) {
            super(frame, string, _boolean);
            try {
                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                jbInit();
                pack();
            } catch (Exception exception) {
                exception.printStackTrace();
        public Login() {
            this(new Frame(), "Login", false);
        private void jbInit() throws Exception {
            this.setResizable(false);
            this.setUndecorated(true);
            this.setSize(new Dimension(450, 220));
            back = new ImageIcon(image_pics.LOGIN_BACK);
            logoLabel.setIcon(new ImageIcon(image_pics.SMALL_LOGO));
            panel1.setLayout(xYLayout1);
            panel1.setMinimumSize(new Dimension(450, 220));
            panel1.setPreferredSize(new Dimension(450, 220));
            loginLabel.setText("Login");
            nameLabel.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            nameLabel.setText("User Name");
            passwordLabel.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            passwordLabel.setText("Password");
            backLabel.setIcon(back);
            passwordField.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            passwordField.setText("Enter Password");
            passwordField.addFocusListener(new
                                           Login_passwordField_focusAdapter(this));
            loginButton.setBackground(new Color(231, 231, 231));
            loginButton.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            loginButton.setText("Login");
            loginButton.addActionListener(new Login_loginButton_actionAdapter(this));
            cancelButton.setBackground(new Color(231, 231, 231));
            cancelButton.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            cancelButton.setActionCommand("cancelButton");
            cancelButton.setSelected(true);
            cancelButton.setText("Cancel");
            cancelButton.addActionListener(new Login_cancelButton_actionAdapter(this));
            jComboBox1.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            jComboBox1.setEditable(true);
            logoLabel.setBorder(null);
            logoLabel.setHorizontalAlignment(SwingConstants.CENTER);
            logoLabel.setHorizontalTextPosition(SwingConstants.CENTER);
            logoLabel.setText("");
            locationLabel.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN, 11));
            locationLabel.setText("Location");
            locationComboBox.setFont(new java.awt.Font("Lucida Grande", Font.PLAIN,
                    11));
            panel1.add(cancelButton, new XYConstraints(337, 170, -1, -1));
            panel1.add(loginButton, new XYConstraints(245, 170, -1, -1));
            panel1.add(loginLabel, new XYConstraints(208, 21, -1, -1));
            panel1.add(logoLabel, new XYConstraints(21, 20, 57, 54));
            panel1.add(passwordLabel, new XYConstraints(99, 141, -1, -1));
            panel1.add(locationLabel, new XYConstraints(104, 72, -1, -1));
            panel1.add(nameLabel, new XYConstraints(90, 106, -1, -1));
            panel1.add(passwordField, new XYConstraints(185, 138, 219, -1));
            panel1.add(jComboBox1, new XYConstraints(183, 103, 219, -1));
            panel1.add(locationComboBox, new XYConstraints(183, 67, 219, -1));
            panel1.add(backLabel, new XYConstraints(0, 0, 451, 223));
            getContentPane().add(panel1);
            panel1.grabFocus();
         * Exit action performed.
         * @param actionEvent ActionEvent
        public void cancelButton_actionPerformed(ActionEvent actionEvent) {
            System.exit(0);
         * Login to MySQL Server. Using User ame and Password
         * This pass into MYSQLDAO user Name and Password
         * @param actionEvent ActionEvent
        //This pass into MYSQLDAO user Name and Password
        public void loginButton_actionPerformed(ActionEvent actionEvent) {
            String pass = new String(passwordField.getPassword());
            if (!pass.equals("Enter Password")) {
                System.out.println("This the username   " +
                                   (String) jComboBox1.getSelectedItem() + "\n" +
                                   "Password is     " + pass);
                try {
                    mysqlDAO = new MYSQLDAO();
                    mysqlDAO.setUserName((String) jComboBox1.getSelectedItem().
                                         toString().
                                         trim());
                    mysqlDAO.setPassword(new String(passwordField.getPassword()));
                } catch (SQLException ex) {
                    // handle the error
                    System.out.println("SQLException: " + ex.getMessage());
                    System.out.println("SQLState: " + ex.getSQLState());
                    System.out.println("VendorError: " + ex.getErrorCode());
                } catch (Exception ex) {
                    // handle the error
                    System.out.println("Erro no registro do Driver Mysql!!!!");
                hide();
         * Password field select all.
         * Feild is select. The user can just start typing
         * and overright the password feild
         * @param focusGained FocusEvent
        public void passwordField_focusGained(FocusEvent focusEvent) {
            passwordField.selectAll();
    class Login_loginButton_actionAdapter implements ActionListener {
        private Login adaptee;
        Login_loginButton_actionAdapter(Login adaptee) {
            this.adaptee = adaptee;
        public void actionPerformed(ActionEvent actionEvent) {
            adaptee.loginButton_actionPerformed(actionEvent);
    class Login_passwordField_focusAdapter extends FocusAdapter {
        private Login adaptee;
        Login_passwordField_focusAdapter(Login adaptee) {
            this.adaptee = adaptee;
        public void focusGained(FocusEvent focusEvent) {
            adaptee.passwordField_focusGained(focusEvent);
    class Login_cancelButton_actionAdapter implements ActionListener {
        private Login adaptee;
        Login_cancelButton_actionAdapter(Login adaptee) {
            this.adaptee = adaptee;
        public void actionPerformed(ActionEvent actionEvent) {
            adaptee.cancelButton_actionPerformed(actionEvent);
    }

  • I downloaded a movie to my ipad, when synced with computer, the computer is now also downloading the movie. why? and how do i stop the movie from being downloaded again

    i downloaded a movie to my ipad, when synced with computer, the computer is now also downloading the movie. why? and how do i stop the movie from being downloaded again

    Do you not want a backup of the iTunes content on your computer in the event the iPad is lost, stolen, or simply fails?

  • How to stop the Calendar from editing your input?

    How to stop the Calendar from editing your input?

    I am constantly finding that Calendar Version 8.0 thinks it knows what I want to type but it incorrectly takes numbers and days and times out of my input and changes my appointments. I hate this new supposedly "smart" feature. Even when I edit my event correctly a second or third time it rewrites my input incorrectly again. I have to use my iPhone to override the annoying editing on my mac. I am ready to find a new calendar program unless Apple allows users to input what they want without their information being incorrectly edited.

  • How to stop an idoc from being processed further

    Hi Experts,
    I have a requirement where i have to stop the idoc from being processed in an user exit.
    I have to stop the idoc and give a suitable status message over there.
    It would be highly helpful if anybody tells me how to stop the idoc abruptly and giv the status messsage.
    Thanks in advance.
    Praveen.

    Hi,
    Check the below link
    https://forums.sdn.sap.com/click.jspa?searchID=11810720&messageID=3032674
    You need to find aproper EXIT.
    The avaliable options for you in the exit is
    IDOC_DATA
    Now if i pick the segment having shiped qty from the data record and check the same with the delivery qty your objective is half done.
    When the condition fails you need to update the IDOC with Error 51 saying that this is not possible .
    for that you need to bring your logic as
    LOOP AT IDOC_CONTROL.
    PERFORM LOGIC...
    ENDLOOP.
    FOR LOGIC .
    All the criteria and then update the status of the IDOC then error is generated and updated to the IDOc.
    PERFORM updatestatusidoc.
    endform logic.
    like this in
    form updatestatusidoc.
    IF subrc = 0 .
    t_idoc_status-docnum = f_idoc_contrl-docnum.
    t_idoc_status-status = c_idoc_status_ok.
    t_idoc_status-msgty = 'S'. -
    >denotes success
    t_idoc_status-msgid = 'ZXXX'.
    t_idoc_status-msgno = '000'. "
    t_idoc_status-msgv1 = itab-field.
    APPEND t_idoc_status.
    ELSEIF subrc = 1.
    t_idoc_status-docnum = f_idoc_contrl-docnum.
    t_idoc_status-status = c_idoc_status_error.
    t_idoc_status-msgty = 'E'. "denotes --->error
    t_idoc_status-msgid = 'ZXXX'.
    t_idoc_status-msgno = '001'. "
    t_idoc_status-msgv1 = itab-field.
    APPEND t_idoc_status.
    endif.
    endform.
    this has to be done to make the idoc to trigger error mode.
    Regards,
    Raj.

  • How to stop volume icon from being displayed randomly

    How to stop volume icon from being displayed randomly

    Thanks for the quick response.
    I have a number of slides which act as a training module. The quiz follows this. All the answers to the quiz are in the module slides. I'd like the user to be able to see which questions they're failing on, but not be shown the answers, as, if they are failing the quiz, the whole module needs to be reviewed and the test retaken.
    If this isn't possible, I'll probably just remove the review option, thereby meaning my retake button can stay, and the user can just go back and re-read the module slides to learn the answers.
    Thanks

  • How to stop the Browser from caching my web pages

    Hi There
    Can anyone tell how to stop the browser from caching my jsp pages
    I am using
    <%response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", 0);
    %>
    but this does not work anduser is able to go back to the previous page
    which i dont want and i want the browser to display the message the page has expired
    Help appreciated
    Thanks
    Mumtaz

    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("max-age", 0);
    response.setDateHeader("Expires", 0);
    I have cut paste the code from my jsp which is working. There is one additional line. I do not know if that is the cause but there is no harm in trying that out.
    Srinivasan Ranganathan

  • How to stop  the users from changing the Decimal in SAP

    How  to stop  the users from changing User Profile

    Hai,
    It is not possible to restrict SU3 to display, because it has only S_TCODE has the authorization object.
    If you really want to restrict users from changing their profile you have to remove the SU3 access and give SU1 or SU2 which gives access only to Personnel details and Parameters.
    Hope this helps.
    Regards,
    Yoganand.V

  • How to stop the dock from showing all hidden images when hiding then showing applications

    How to stop the dock from showing all hidden images when hiding then showing applications

    It's not really something to snap a screen shot of. I believe it would need to be a video clip. For instance, when I am working on multiple images in Photoshop, I often need many images open at the same time, but I only have one image viewable and active. The hero image is active on screen while I hide the other images in the dock by hitting the yellow - button on the images. Then I "Hide" Photoshop to do something in the Finder. When I go back to Photoshop, every image that is hidden in the dock will pop open again in the active window, not just the image I was currently working on. I want these images to stay in the dock until I need them, no matter how many times I Hide the Show Photoshop.

  • HT2188 How to stop the battery from draining

    How to stop the battery from draining

    I tried everything to stop my battery from draining on my iPad 2 since I have downloaded IOS 7.... Without success. Very disappointed with IOS 7 so far. Apple please release a patch to stop the battery from draining. It is urgent. My iPad is now useless, it is always drained to 0% everytime I open my iPad!?!?!

  • How to stop an email from being sent after I hit send?

    How can I immediately stop an email from being sent after clicking "send"?
    I can't seem to find any info on this. I am assuming that it is impossible. Correct?

    When sending the emails with larger attachments that take a little time to actually upload and get out, you can open the activity viewer by pressing command-0 (or is it command-o?--)--it may also be under the window menu at the top--I'm not at my Mac right now to check. The activity viewer has a stop button on it. After you stop it, you should be able to either delete the email from the outgoing mail folder or drag that email to another folder, such as the drafts folder. I've done this a few times without a problem.

  • How to stop the report from Web!

    hi,all!
    Now I can start a report from Web with schedule parameter!Can you tell me how to stop the report via the Web server?Or tell me with which patameter.Thank a lot.

    hello,
    there is a CGI/Servlet command called killjob which you pass the job-id of the job you want to kill.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                           

  • Anyone know how to stop the slideshow from looping?

    Does anyone know which file to edit in order to stop the slideshow from looping? Where the code would be or, what code to add.
    I am not aware of a setting from within iweb itself.
    I assumed it was the slideshow.js file but I didn't find anything in there.
    Such as a loop "true"
    HELP

    That worked great.
    I assume what we are doing is copying and editing the
    .mac slideshow file,
    and then pointing to it's location in the folder. How
    Yes, that's exactly it.
    did you know what the code would be? I guess you must
    be very Java savy, because it definetly wasn't an
    obvious one.
    It took me two days to reverse engineered dot mac slideshow
    Is there a way to get the slideshow window to close
    after it's finished? What I get is a freeze frame on
    the last photo of the show.
    I know you gonna ask that yes, change the added line in slideshow.js to this:
    if (count == ((imgs.length) - 1)) { this.pause(); setTimeout("window.close()", 5000); }; // close window after 5 sec, change 5000 to whatever you like.

  • [SOLVED]How to stop the screen from shutting it self off?

    First of all, spare me the "search/man/wiki-first"-talk becouse I have already done that as far as my knowledge of the subject reach. If you think you seen a thread like this with a solution, please link to it without any retarded comments.
    Now to my question: How do I , from the commandline, stop the display from shutting it self off automatically after awhile?
    Last edited by whacath (2010-02-19 11:27:12)

    To disable DPMS and screen blanking:
    xset -dpms s off

Maybe you are looking for