Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description



      Name: krT82822 Date: 03/24/99


      If you use JOptionPane with two JFrame or JApplet with one
      of the static methods like showMessageDialog you have the
      modal effect on all frames.

      This example create two JFrame with a JTextField and
      a JTextArea inside. I've attached also a listener to monitor
      the keyboard action. The effect is this:

      All frames appear. The first frame create an option message with
      its istance. But all seems modal. But if you press the icon "Frame2" on the
      window bar you can go inside the Frame2 and write all you want.

      So the wrong effect is: if you have a lot of opened frames all
      are in a modal form also if you create the option message with
      the istance of one only. But you can write inside the other
      frames using the window bar.

      This is the code:

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;
      import java.lang.*;

      public class prova
      {
      public prova ()
      {
      JFrame f = new JFrame("Frame");
      JFrame f1 = new JFrame("Frame2");
      JPanel p = new JPanel();
      p.setLayout(new GridLayout(3,0));
      JPanel p1 = new JPanel();
      p1.setLayout(new GridLayout(3,0));

      JTextField tx = new JTextField();
      listener l = new listener();

      JTextArea txa = new JTextArea();
      // txa.addFocusListener(l);
      txa.addKeyListener(l);
      tx.addKeyListener(l);

      JTextField tx1 = new JTextField();
      listener l1 = new listener();

      JTextArea txa1 = new JTextArea();
      // txa.addFocusListener(l);
      txa1.addKeyListener(l);
      tx1.addKeyListener(l);

      p.add(tx);
      p.add(txa);

      p1.add(tx1);
      p1.add(txa1);

      f.getContentPane().add(p);
      f.pack();
      f.setVisible(true);

      f1.getContentPane().add(p1);
      f1.pack();
      f1.setVisible(true);


      JOptionPane.showMessageDialog(f,"Try","Can you press the other frame?",JOptionPane.ERROR_MESSAGE);

      }

      public static void main(String args[])
      {
      prova prv = new prova();
      }

      class listener extends KeyAdapter implements FocusListener
      {
      public void keyPressed(KeyEvent e)
      {
      //Invoked when a key has been pressed.
      System.out.println("keyPressed");
      if (e.getKeyCode() == KeyEvent.VK_TAB)
      {
      System.out.println("TAB");
      e.setModifiers(InputEvent.CTRL_MASK);
      //e.consume();
      }
      }

      public void keyReleased(KeyEvent e)
      {
      //Invoked when a key has been released.
      System.out.println("keyReleased");
      }

      public void keyTyped(KeyEvent e)
      {
      //Invoked when a key has been typed.
      System.out.println("keyTyped");
      }

      public void focusGained(FocusEvent fe)
      {
      System.out.println("GAINED :"+fe);
      }

      public void focusLost(FocusEvent fe)
      {
      System.out.println("LOST :"+fe);
      }
      }
      }
      (Review ID: 56023)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                amfowler Anne Fowler (Inactive)
                Reporter:
                kryansunw Kevin Ryan (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: