Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4115213

Dialog.setResizable(false) does not work.

XMLWordPrintable

    • 1.2.2
    • generic, x86, sparc
    • solaris_2.4, solaris_2.5.1, windows_nt

      Dialog.setResizable(false) does not work. User will be able to resize dialog
      no matter what the setting is.

      error message from test program:
      ** FAILURE **
      Dialog.setResizable(false) Failed. Should not be able to resize dialog.
      User was able to resize dialog.
      isResizable is set to: false

      The following is a test case for described poblem.

      import java.awt.*;
      import java.awt.event.*;

      public class Login extends Frame implements ActionListener{
        public Login() {
          setTitle("Login Frame");
          Panel ButtonPanel = new Panel();
          ButtonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
          Button LoginButton = new Button("Create Login Dialog");
          ButtonPanel.add(LoginButton);
          add(ButtonPanel, "Center");
          LoginButton.addActionListener(this);
        }
        
        public static void main(String args[]) {
          Frame f = new Login();
          f.setSize(250,100);
          f.setResizable(false);
          f.setVisible(true);
        }
        
        public void actionPerformed(ActionEvent event) {
          if (event.getActionCommand().equals("Create Login Dialog")) {

            this.setVisible(false);
            //this.dispose();
            LoginDialog ld = new LoginDialog(this);
            ld.setSize(250,150);
            ld.setResizable(false);
            ld.setVisible(true);
            
          
          }
        }
        
      }
      // Build the Login Dialog when called for.
      class LoginDialog extends Dialog implements ActionListener,ComponentListener{
        boolean pass = true;
        private boolean resize = false;
        public LoginDialog(Login parent) {

          super(parent, "Login Dialog", true);
          this.addComponentListener(this);
          Panel TextPanel = new Panel();
          TextPanel.setLayout(new FlowLayout());
          TextPanel.add(new Label("Try to resize dialog.", Label.CENTER));

          add("North",TextPanel);
         
          Panel UserPanel = new Panel();
          UserPanel.setLayout(new GridLayout(2,2));
          UserPanel.add(new Label("User Name:"));
          UserPanel.add(username = new TextField("fooyou", 8));
          UserPanel.add(new Label("Password:"));
          password = new TextField("", 8);
          char c = '*'; //sets the echo character for password textfield
          password.setEchoChar(c);
          UserPanel.add(password);

          add("Center", UserPanel);
          
          Panel QuitPanel = new Panel();
          Button QuitButton = new Button("Quit");
          QuitPanel.add(QuitButton);
          add("South",QuitPanel);
          QuitButton.addActionListener(this);
        }
        public void actionPerformed(ActionEvent event) {
          if (event.getActionCommand().equals("Pass")) {
            this.setVisible(false);
            System.exit(0);
          }
        }
        public void componentResized(ComponentEvent e) {
          System.out.println("** FAILURE **");
          System.out.println("Dialog.setResizable(false) Failed. Should not be able to resize dialog. ");
          System.out.println("User was able to resize dialog.");
          System.out.println("isResizable is set to: " + this.isResizable());
          System.exit(1);
        }
        
        public void componentMoved(ComponentEvent e) {
          //System.out.println("componentMoved event occured. Test Failed.");
        }
        
        public void componentShown(ComponentEvent e) {
          //System.out.println("componentShown event occured. Test Failed.");
        }
        
        public void componentHidden(ComponentEvent e) {
          // System.out.println("componentHidden event occured. Test Failed.");
        }

        private TextField username;
        private TextField password;
      }

            bklocksunw Brian Klock (Inactive)
            collins Gary Collins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: