Partial modality

Hi,
My project has a new requirement. We have two JFrames as part of the application, say Frame1 and Frame2. The requirement states that when any dialog is displayed via some interaction in Frame1, the dialog should be modal for Frame1, but not for Frame2. Therefore, while dialog 1 is displaying due to some click in Frame1, I should still be able to carry out some interactions in Frame2.
Is this even possible??? I have tried looking for modality on the site, but all I get is 'A modal dialog is one which blocks input to all other toplevel windows in the application, except for any windows created with the dialog as their owner'. Now does top level mean parent of dialog and all such ancestors, or all higher level windows, including all JFrames?
Any help in this matter appreciated.
Shefali.

Hi Tom,
You're welcome to the dukes!!! Anyways, a small problem. I used the code from one of the javatips, and implemented the following code. If you have the time, I'd really appreciate your helping me find out what's wrong...
The basic idea is that I have two frames, Frame1 and Frame2. Each has one button for launching a dialog, one checkbox, and one exit button. When a dialog is launched from one frame, all inputs to that frame should be blocked, but the other frame should stay unaffected. When the dialog is closed, the first frame also starts getting all inputs.
I am putting the following files below:
- Blocker.java: the class derived from EventQueue. This one basically maintains a vector of restricted components, and assumes that any component in this vector is not supposed to receive any inputs. It is the duty of the various dialogs to add its owner (and contained components) to this vector on show, and remove the owner from the vector on hide/dispose.
- Test2.java: the main; creates two frames, and adds the action listeners etc.
- MyDialog.java: the dialog to be launched on clicking the button in the frame (also supports same dialog launched on clicking button in dialog, as this is also a requirement, but does not currently pertain to my problem).
// Blocker.java
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Blocker extends EventQueue
    private Vector m_oVectRestrictedComponents;
    private EventQueue m_oSystemQ =
            Toolkit.getDefaultToolkit().getSystemEventQueue();
    private static Blocker m_oInstance = null;
    public static synchronized Blocker Instance()
        if(m_oInstance == null)
            m_oInstance = new Blocker();
        return m_oInstance;
    private Blocker()
        m_oVectRestrictedComponents = new Vector();
         m_oSystemQ.push(this);
    public void reset()
         m_oVectRestrictedComponents.removeAllElements();
    public void addRestrictedComponent(final Component oComp)
        if(oComp == null)
             return;
         addChildComponents(oComp);
     public void removeRestrictedComponent(final Component oComp)
          if(oComp == null || m_oVectRestrictedComponents.size() == 0)
               return;
          removeChildComponents(oComp);
      * Add component to list of restricted components. If a JComponent, set its
      * request focus enabled false, and if an abstract button, set its focus
      * painted false. If a container, do the same for all its contained
      * components.
      * @param oComp
    private void addChildComponents(final Component oComp)
        m_oVectRestrictedComponents.add(oComp);
         if(oComp instanceof JComponent)
             ((JComponent)oComp).setRequestFocusEnabled(false);
         if(oComp instanceof AbstractButton)
             ((AbstractButton)oComp).setFocusPainted(false);
        final int iCompCount = ((Container)oComp).getComponentCount();
        if(iCompCount != 0)
            for(int i = 0; i < iCompCount; i++)
                addChildComponents(((Container)oComp).getComponent(i));
      * Remove component from list of restricted components. If a Jcomponent, set
      * its request focus enabled true, and if an abstract button, its set focus
      * painted true. If component is a container, do the same for all its
      * contained components.
      * @param oComp
     private void removeChildComponents(final Component oComp)
         m_oVectRestrictedComponents.remove(oComp);
          if(oComp instanceof JComponent)
              ((JComponent)oComp).setRequestFocusEnabled(true);
          if(oComp instanceof AbstractButton)
              ((AbstractButton)oComp).setFocusPainted(true);
          final int iCompCount = ((Container)oComp).getComponentCount();
          if(iCompCount != 0)
              for(int i = 0; i < iCompCount; i++)
                  removeChildComponents(((Container)oComp).getComponent(i));
    private Component getSource(final AWTEvent event)
        Component source = null;
        // each of these five MouseEvents will still be valid (regardless
        // of their source), so we still want to process them.
        if((event instanceof MouseEvent) &&
                (event.getID() != MouseEvent.MOUSE_DRAGGED) &&
                (event.getID() != MouseEvent.MOUSE_ENTERED) &&
                (event.getID() != MouseEvent.MOUSE_EXITED) &&
                (event.getID() != MouseEvent.MOUSE_MOVED) &&
                (event.getID() != MouseEvent.MOUSE_RELEASED))
            final MouseEvent mouseEvent = (MouseEvent)event;
            source = SwingUtilities.getDeepestComponentAt(
                    mouseEvent.getComponent(),
                    mouseEvent.getX(),
                    mouseEvent.getY());
        else if(event instanceof KeyEvent &&
                event.getSource() instanceof Component)
            source = SwingUtilities.findFocusOwner(
                    (Component)(event.getSource()));
        return source;
    private boolean isSourceBlocked(final Component oSource)
        boolean blocked = false;
        if((m_oVectRestrictedComponents.size() != 0) && (oSource != null))
            final int iNumRestrictedComponents = m_oVectRestrictedComponents.size();
            int i = 0;
            while(i < iNumRestrictedComponents &&
                    (m_oVectRestrictedComponents.get(i).equals(oSource) == false))
                i++;
            blocked = i < iNumRestrictedComponents;
        return blocked;
    protected void dispatchEvent(final AWTEvent event)
         System.out.println();
         System.out.println(event);
         // getSource is a private helper method
         final boolean blocked = isSourceBlocked(getSource(event));
        if(blocked &&
                (event.getID() == MouseEvent.MOUSE_CLICKED ||
                event.getID() == MouseEvent.MOUSE_PRESSED))
            Toolkit.getDefaultToolkit().beep();
        else if(blocked &&
                event instanceof KeyEvent &&
                event.getSource() instanceof Component)
            final DefaultFocusManager dfm = new DefaultFocusManager();
            dfm.getCurrentManager();
            Component currentFocusOwner = getSource(event);
            boolean focusNotFound = true;
            do
                dfm.focusNextComponent(currentFocusOwner);
                currentFocusOwner = SwingUtilities.findFocusOwner(
                        (Component)event.getSource());
                if(currentFocusOwner instanceof JComponent)
                    focusNotFound =
                            (((JComponent)currentFocusOwner).isRequestFocusEnabled() == false);
            while(focusNotFound);
        else
            super.dispatchEvent(event);
// Test2.java
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
* This Test class demonstrates how the Blocker is used.
* The Test opens a new JFrame object containing five different
* components.  The button labeled "Block" will block "Button"
* and "CheckBox".  The button labeled "Unblock" will make "Button"
* and "CheckBox" accessible to the user.
* "Button" and "CheckBox" have no attached functionality.
public class Test2
     private JFrame m_oFrame1;
     private JFrame m_oFrame2;
     private JButton m_oDisplayDialog1;
     private JButton m_oDisplayDialog2;
     public Test2()
          final WindowClosingAdapter oWindowAdapter = new WindowClosingAdapter();
          final DisplayDialogActionListener oDisplayDialogActionListener =
                  new DisplayDialogActionListener();
          final ExitListener oExitListener = new ExitListener();
          m_oFrame1 = new JFrame();
          m_oFrame1.setTitle("Blocker Test1");
          m_oFrame1.addWindowListener(oWindowAdapter);
          m_oFrame1.setSize(400, 200);
          m_oDisplayDialog1 = new JButton("Button1");
          m_oDisplayDialog1.setMnemonic('1');
          m_oDisplayDialog1.addActionListener(oDisplayDialogActionListener);
          final JCheckBox checkBox = new JCheckBox("CheckBox1");
          final JButton exitButton = new JButton("Exit1");
          exitButton.addActionListener(oExitListener);
          Container contentPane = m_oFrame1.getContentPane();
          contentPane.setLayout(new FlowLayout());
          contentPane.add(m_oDisplayDialog1);
          contentPane.add(checkBox);
          contentPane.add(exitButton);
          m_oFrame1.setVisible(true);
          m_oFrame2 = new JFrame();
          m_oFrame2.setTitle("Blocker Test2");
          m_oFrame2.addWindowListener(oWindowAdapter);
          m_oFrame2.setSize(400, 200);
          m_oDisplayDialog2 = new JButton("Button2");
          m_oDisplayDialog2.setMnemonic('2');
          m_oDisplayDialog2.addActionListener(oDisplayDialogActionListener);
          final JCheckBox cb = new JCheckBox("CheckBox2");
          final JButton exitbutton2 = new JButton("Exit2");
          exitbutton2.addActionListener(oExitListener);
          contentPane = m_oFrame2.getContentPane();
          contentPane.setLayout(new FlowLayout());
          contentPane.add(m_oDisplayDialog2);
          contentPane.add(cb);
          contentPane.add(exitbutton2);
          m_oFrame2.setVisible(true);
    public static void main(String[] argv)
         new Test2();
         Blocker.Instance();
     private class DisplayDialogActionListener implements ActionListener
          public void actionPerformed(final ActionEvent e)
               final Object oSource = e.getSource();
               JFrame oParent = null;
               if(oSource.equals(m_oDisplayDialog1))
                    oParent = m_oFrame1;
               else if(oSource.equals(m_oDisplayDialog2))
                    oParent = m_oFrame2;
               if(oParent == null)
                    return;
               final MyDialog oDialog = new MyDialog(oParent);
               oDialog.show();
     private class WindowClosingAdapter extends WindowAdapter
           * Invoked when a window has been closed.
          public void windowClosed(WindowEvent e)
               System.exit(0);
     private class ExitListener implements ActionListener
          public void actionPerformed(final ActionEvent e)
               System.exit(0);
// MyDialog.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class MyDialog extends JDialog
     private static int INITIALIZER = 0;
     private final Blocker m_oBlocker = Blocker.Instance();
     public MyDialog(final Frame owner) throws HeadlessException
          super(owner, "Frame Parent" + INITIALIZER);
          INITIALIZER++;
          initializeDialog();
     public MyDialog(final Dialog owner) throws HeadlessException
          super(owner, "Dialog Parent" + INITIALIZER);
          INITIALIZER++;
          initializeDialog();
     private void initializeDialog()
          setSize(200, 100);
          final JButton oDoNothing = new JButton("Do Nothing");
          oDoNothing.addActionListener(new DisplayDialogActionListener());
          final JButton oCloseDialog = new JButton("Close");
          oCloseDialog.addActionListener(new ActionListener()
               public void actionPerformed(final ActionEvent e)
                    MyDialog.this.dispose();
          final Container oContentPane = getContentPane();
          oContentPane.setLayout(new FlowLayout());
          oContentPane.add(oDoNothing);
          oContentPane.add(oCloseDialog);
     public void show()
          System.out.println(getTitle() + " show called");
          super.show();
          System.out.println(getTitle() + " adding owner to restricted list");
          m_oBlocker.addRestrictedComponent(getOwner());
      * Hides the Dialog and then causes show() to return if it is currently
      * blocked.
     public void hide()
          System.out.println(getTitle() + " removing owner from restricted list");
          m_oBlocker.removeRestrictedComponent(getOwner());
          System.out.println(getTitle() + " hide called");
          super.hide();
      * Disposes the Dialog and then causes show() to return if it is currently
      * blocked.
     public void dispose()
          System.out.println(getTitle() + " removing owner from restricted list");
          m_oBlocker.removeRestrictedComponent(getOwner());
          System.out.println(getTitle() + " dispose called");
          super.dispose();
     private class DisplayDialogActionListener implements ActionListener
          public void actionPerformed(final ActionEvent e)
               final MyDialog oDialog = new MyDialog(MyDialog.this);
               oDialog.show();
}Now, my problem is that when i try to display the dialog using a mouse click on the button, there is never any problem, neither does there appear to be a problem if the focus is on the button and I press space/enter. But if there is a mnemonic set, and I use that (like Alt-1), then SOMETIMES, the entire application hangs. I am stumped as to why this is happening... Any help AT ALL is seriously appreciated.
Thanks,
Shefali.

Similar Messages

  • Effect of super() in JDialog constructor on focusability/modality

    Hello again,
    this is a JFrame which calls a JDialog which calls a JDialog.
    Using super(...) in the constructor of SecondDialog makes this dialog
    unfocusable as long as FirstDialog is shown. Without super(...) one can freely
    move between the dialogs.
    Can somebody exlain what "super" does to produce this difference?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SuperConstructor extends JFrame {
      public SuperConstructor() {
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(300,300);
        setTitle("Super constructor");
        Container cp= getContentPane();
        JButton b= new JButton("Show dialog");
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
         new FirstDialog(SuperConstructor.this);
        cp.add(b, BorderLayout.SOUTH);
        setVisible(true);
      public static void main(String args[]) {
        EventQueue.invokeLater(new Runnable() {
          public void run() {
         new SuperConstructor();
      class FirstDialog extends JDialog {
        public FirstDialog(final Frame parent) {
          super(parent, "FirstDialog");
          setSize(200,200);
          setLocationRelativeTo(parent);
          setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
          JButton bNext= new JButton("Show next dialog");
          bNext.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           new SecondDialog(parent, false);
          add(bNext, BorderLayout.SOUTH);
          setVisible(true);
      int i;
      class SecondDialog extends JDialog {
        public SecondDialog(Frame parent, boolean modal) {
          super(parent); // Makes this dialog unfocusable as long as FirstDialog is 
    shown
          setSize(200,200);
          setLocation(300,50);
          setModal(modal);
          setTitle("SecondDialog "+(++i));
          JButton bClose= new JButton("Close");
          bClose.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           dispose();
          add(bClose, BorderLayout.SOUTH);
          setVisible(true);
    }

    nice day,
    there are three areas of get potential problem
    1/ FirstDialog helt pernament MODALITY, SecondDialog to have to same ...
    2/ there isn't something about change Window focus (if Parent inside of EDT, then you alyway lost focus, meaning SecondDialog)
    3/ constructor super inside class doesn't works, block move focus to the SecondDialog (and nonModal)
    ... but
    4/ here is second coins_side [http://forums.sun.com/thread.jspa?messageID=11020377#11020377]
    5/ in this form is my example returns similair result, isn't possible setWindow focus for visible JDialog (sure, remove Extend JDialog and create separate constuctor for JDialog, solve that)
    6/ maybe I'm wrong
    package JDialog;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * Parent Modal Dialog. When in modal mode, this dialog
    * will block inputs to the "parent Window" but will
    * allow events to other components
    * @see javax.swing.JDialog
    public class PMDialog extends JDialog {
        private static final long serialVersionUID = 1L;
        private boolean modal = false;
        private WindowAdapter parentWindowListener;
        private Window owner;
        private JFrame blockedFrame = new JFrame("No blocked frame");
        private JFrame noBlockedFrame = new JFrame("Blocked Frame");
        public PMDialog() {
            noBlockedFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            noBlockedFrame.getContentPane().add(new JButton(new AbstractAction("Test button") {
                private static final long serialVersionUID = 1L;
                @Override
                public void actionPerformed(ActionEvent evt) {
                    System.out.println("Non blocked button pushed");
                    /*if (blockedFrame.isVisible()) {
                        noBlockedFrame.setVisible(false);
                    } else {
                        blockedFrame.setVisible(true);
                    noBlockedFrame.setVisible(true);
                    blockedFrame.setVisible(true);
            noBlockedFrame.setSize(200, 200);
            noBlockedFrame.setVisible(true);
            blockedFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            blockedFrame.getContentPane().add(new JButton(new AbstractAction("Test Button") {
                private static final long serialVersionUID = 1L;
                @Override
                public void actionPerformed(ActionEvent evt) {
                    final PMDialog pmd = new PMDialog(blockedFrame, "Partial Modal Dialog", true);
                    pmd.setSize(200, 100);
                    pmd.setLocationRelativeTo(blockedFrame);
                    pmd.getContentPane().add(new JButton(new AbstractAction("Test button") {
                        private static final long serialVersionUID = 1L;
                        @Override
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("Blocked button pushed");
                            pmd.setVisible(false);
                            blockedFrame.setVisible(false);
                            noBlockedFrame.setVisible(true);
                    pmd.setDefaultCloseOperation(PMDialog.DISPOSE_ON_CLOSE);
                    pmd.setVisible(true);
                    System.out.println("Returned from Dialog");
            blockedFrame.setSize(200, 200);
            blockedFrame.setLocation(300, 0);
            blockedFrame.setVisible(false);
        public PMDialog(JDialog parent, String title, boolean isModal) {
            super(parent, title, false);
            initDialog(parent, title, isModal);
        public PMDialog(JFrame parent, String title, boolean isModal) {
            super(parent, title, false);
            initDialog(parent, title, isModal);
        private void initDialog(Window parent, String title, boolean isModal) {
            owner = parent;
            modal = isModal;
            parentWindowListener = new WindowAdapter() {
                @Override
                public void windowActivated(WindowEvent e) {
                    if (isVisible()) {
                        System.out.println("Dialog.getFocusBack()");
                        getFocusBack();
        private void getFocusBack() {
            Toolkit.getDefaultToolkit().beep();
            super.setVisible(false);
            super.pack();
            super.setLocationRelativeTo(owner);
            super.setVisible(true);
            //super.toFront();
        @Override
        public void dispose() {
            owner.setEnabled(true);
            owner.setFocusableWindowState(true);
            super.dispose();
        @Override
        @SuppressWarnings("deprecation")
        public void hide() {
            owner.setEnabled(true);
            owner.setFocusableWindowState(true);
            super.hide();
        @Override
        public void setVisible(boolean visible) {
            boolean blockParent = (visible && modal);
            owner.setEnabled(!blockParent);
            owner.setFocusableWindowState(!blockParent);
            super.setVisible(visible);
            if (blockParent) {
                System.out.println("Adding listener to parent ...");
                owner.addWindowListener(parentWindowListener);
                try {
                    if (SwingUtilities.isEventDispatchThread()) {
                        System.out.println("EventDispatchThread");
                        EventQueue theQueue = getToolkit().getSystemEventQueue();
                        while (isVisible()) {
                            AWTEvent event = theQueue.getNextEvent();
                            Object src = event.getSource();
                            if (event instanceof ActiveEvent) {
                                ((ActiveEvent) event).dispatch();
                            } else if (src instanceof Component) {
                                ((Component) src).dispatchEvent(event);
                    } else {
                        System.out.println("OUTSIDE EventDispatchThread");
                        synchronized (getTreeLock()) {
                            while (isVisible()) {
                                try {
                                    getTreeLock().wait();
                                } catch (InterruptedException e) {
                                    break;
                } catch (Exception ex) {
                    ex.printStackTrace();
                    System.out.println("Error from EDT ... : " + ex);
            } else {
                System.out.println("Removing listener from parent ...");
                owner.removeWindowListener(parentWindowListener);
                owner.setEnabled(true);
                owner.setFocusableWindowState(true);
        @Override
        public void setModal(boolean modal) {
            this.modal = modal;
        public static void main(String args[]) {
            PMDialog pMDialog = new PMDialog();
    }

  • How to open a new window from the login window?

    hi,
    can someone tell me how to open a new window from an existing window, here by window i mean frame. The case is i hv two java files - oracle.java and FDoptions.java. The first frame is in the Login.java. The oracle.java file has a button "Login", when it is clicked, i want to open the next frame which is in the file FDoptions.java. Can some one help me with this? I m giving the code below -
    oracle.java
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import javax.swing.AbstractAction;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JTextField;
    * The application's main frame.
    public class oracle {
        private JFrame frame;
        private JPanel logInPanel;
        private JButton clearButton;
        private JButton logInButton;
        private JButton newuserButton;
        private JButton forgotpasswordButton;
        private JTextField userNameTextField;
        private JPasswordField passwordTextField;
        public oracle() {
            initComponents();
        private final void initComponents() {
            JLabel userNameLabel = new JLabel("User name: ");
            JLabel passwordLabel = new JLabel("Password: ");
            userNameTextField = new JTextField();
            passwordTextField = new JPasswordField();
            JPanel userInputPanel = new JPanel(new GridLayout(2, 2, 5, 5));
            userInputPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
            userInputPanel.add(userNameLabel);
            userInputPanel.add(userNameTextField);
            userInputPanel.add(passwordLabel);
            userInputPanel.add(passwordTextField);
            logInButton = new JButton(new LogInAction());
            clearButton = new JButton(new ClearAction());
            newuserButton = new JButton(new NewUserAction());
            forgotpasswordButton = new JButton(new ForgotPassword());
            JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
            JPanel buttonPanel1 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
            buttonPanel.add(logInButton);
            buttonPanel.add(clearButton);
            buttonPanel1.add(newuserButton);
            buttonPanel1.add(forgotpasswordButton);
            logInPanel = new JPanel(new BorderLayout());
            logInPanel.add(userInputPanel, BorderLayout.NORTH);
            logInPanel.add(buttonPanel, BorderLayout.CENTER);
            logInPanel.add(buttonPanel1,BorderLayout.SOUTH);
            frame = new JFrame("FD Tracker");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(500, 500);
            frame.setContentPane(logInPanel);
            frame.pack();
            frame.setVisible(true);
        private void performLogIn() {
            // Log in the user
            System.out.println("Username: " + userNameTextField.getText());
            char[] password = passwordTextField.getPassword();
            System.out.print("Password: ");
            for(char c : password) {
                System.out.print(c);
            System.out.println();
        private void performClear() {
            // Clear the panel
            System.out.println("Clearing the panel");
            userNameTextField.setText("");
            passwordTextField.setText("");
        private final class LogInAction extends AbstractAction {
            public LogInAction() {
                super("Log in");
            @Override
            public void actionPerformed(ActionEvent e) {
                performLogIn();
        private final class ClearAction extends AbstractAction {
            public ClearAction() {
                super("Clear");
            @Override
            public void actionPerformed(ActionEvent e) {
                performClear();
        private final class NewUserAction extends AbstractAction{
             public NewUserAction(){
                 super("New User");
             @Override
             public void actionPerformed(ActionEvent e){
                 JFrame newuser = new JFrame("NewUser");
        private final class ForgotPassword extends AbstractAction{
            public ForgotPassword(){
                super("Forgot Password");
            @Override
            public void actionPerformed(ActionEvent e){
                JFrame forgotpassword = new JFrame("Forgot Password");
        public static void main(String args[]) {
            new oracle();
         FDoptions.java
    import java.awt.FlowLayout;
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import javax.swing.AbstractAction;
    import javax.swing.BorderFactory;
    import javax.swing.JPanel;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class Fdoptions{
        private JFrame fdoptions;
        private JPanel fdoptpanel;
        private JButton enterfdbutton;
        private JButton viewfdbutton;
        public Fdoptions() {
            initComponents();
        private final void initComponents(){
            fdoptpanel = new JPanel(new BorderLayout());
            fdoptpanel.setBorder(BorderFactory.createEmptyBorder(80,50,80,50));
            enterfdbutton = new JButton(new EnterFDAction());
            viewfdbutton = new JButton(new ViewFDAction());
           JPanel enterbuttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
           JPanel viewbuttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
            enterbuttonpanel.add(enterfdbutton);
            viewbuttonpanel.add(viewfdbutton);
            fdoptpanel.add(enterbuttonpanel,BorderLayout.NORTH);
            fdoptpanel.add(viewbuttonpanel,BorderLayout.SOUTH);
            fdoptions = new JFrame("FD Options");
            fdoptions.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            fdoptions.setSize(1000,1000);
            fdoptions.setContentPane(fdoptpanel);
            fdoptions.pack();
            fdoptions.setVisible(true);
        private void performEnter(){
        private void performView(){
        private final class EnterFDAction extends AbstractAction{
            public EnterFDAction(){
                super("Enter new FD");
            public void actionPerformed(ActionEvent e){
                performEnter();
        private final class ViewFDAction extends AbstractAction{
            public ViewFDAction(){
                super("View an existing FD");
            public void actionPerformed(ActionEvent e){
                performView();
        public static void main(String args[]){
            new Fdoptions();
    }

    nice day,
    these lines..., despite the fact that this example is about something else, shows you two ways
    1/ modal JDialog
    2/ two JFrame
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * Parent Modal Dialog. When in modal mode, this dialog
    * will block inputs to the "parent Window" but will
    * allow events to other components
    * @see javax.swing.JDialog
    public class PMDialog extends JDialog {
        private static final long serialVersionUID = 1L;
        protected boolean modal = false;
        private WindowAdapter parentWindowListener;
        private Window owner;
        private JFrame blockedFrame = new JFrame("No blocked frame");
        private JFrame noBlockedFrame = new JFrame("Blocked Frame");
        public PMDialog() {
            noBlockedFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            noBlockedFrame.getContentPane().add(new JButton(new AbstractAction("Test button") {
                private static final long serialVersionUID = 1L;
                @Override
                public void actionPerformed(ActionEvent evt) {
                    System.out.println("Non blocked button pushed");
                    blockedFrame.setVisible(true);
                    noBlockedFrame.setVisible(false);
            noBlockedFrame.setSize(200, 200);
            noBlockedFrame.setVisible(true);
            blockedFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            blockedFrame.getContentPane().add(new JButton(new AbstractAction("Test Button") {
                private static final long serialVersionUID = 1L;
                @Override
                public void actionPerformed(ActionEvent evt) {
                    final PMDialog pmd = new PMDialog(blockedFrame, "Partial Modal Dialog", true);
                    pmd.setSize(200, 100);
                    pmd.setLocationRelativeTo(blockedFrame);
                    pmd.getContentPane().add(new JButton(new AbstractAction("Test button") {
                        private static final long serialVersionUID = 1L;
                        @Override
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("Blocked button pushed");
                            pmd.setVisible(false);
                            blockedFrame.setVisible(false);
                            noBlockedFrame.setVisible(true);
                    pmd.setVisible(true);
                    System.out.println("Returned from Dialog");
            blockedFrame.setSize(200, 200);
            blockedFrame.setLocation(300, 0);
            blockedFrame.setVisible(false);
        public PMDialog(Dialog parent, String title, boolean isModal) {
            super(parent, title, false);
            initDialog(parent, title, isModal);
        public PMDialog(Frame parent, String title, boolean isModal) {
            super(parent, title, false);
            initDialog(parent, title, isModal);
        private void initDialog(Window parent, String title, boolean isModal) {
            owner = parent;
            modal = isModal;
            parentWindowListener = new WindowAdapter() {
                @Override
                public void windowActivated(WindowEvent e) {
                    if (isVisible()) {
                        System.out.println("Dialog.getFocusBack()");
                        getFocusBack();
        private void getFocusBack() {
            Toolkit.getDefaultToolkit().beep();
            super.setVisible(false);
            super.pack();
            super.setLocationRelativeTo(owner);
            super.setVisible(true);
            //super.toFront();
        @Override
        public void dispose() {
            owner.setEnabled(true);
            owner.setFocusableWindowState(true);
            super.dispose();
        @Override
        @SuppressWarnings("deprecation")
        public void hide() {
            owner.setEnabled(true);
            owner.setFocusableWindowState(true);
            super.hide();
        @Override
        public void setVisible(boolean visible) {
            boolean blockParent = (visible && modal);
            owner.setEnabled(!blockParent);
            owner.setFocusableWindowState(!blockParent);
            super.setVisible(visible);
            if (blockParent) {
                System.out.println("Adding listener to parent ...");
                owner.addWindowListener(parentWindowListener);
                try {
                    if (SwingUtilities.isEventDispatchThread()) {
                        System.out.println("EventDispatchThread");
                        EventQueue theQueue = getToolkit().getSystemEventQueue();
                        while (isVisible()) {
                            AWTEvent event = theQueue.getNextEvent();
                            Object src = event.getSource();
                            if (event instanceof ActiveEvent) {
                                ((ActiveEvent) event).dispatch();
                            } else if (src instanceof Component) {
                                ((Component) src).dispatchEvent(event);
                    } else {
                        System.out.println("OUTSIDE EventDispatchThread");
                        synchronized (getTreeLock()) {
                            while (isVisible()) {
                                try {
                                    getTreeLock().wait();
                                } catch (InterruptedException e) {
                                    break;
                } catch (Exception ex) {
                    ex.printStackTrace();
                    System.out.println("Error from EDT ... : " + ex);
            } else {
                System.out.println("Removing listener from parent ...");
                owner.removeWindowListener(parentWindowListener);
                owner.setEnabled(true);
                owner.setFocusableWindowState(true);
        @Override
        public void setModal(boolean modal) {
            this.modal = modal;
        public static void main(String args[]) {
            new PMDialog();
    }

  • Partial page refresh is not working in APEX 4.0

    Hi All,
    I have a report region in my application,I have selected the following properties for the region,
    Pagination scheme - Row ranges X To Y (with next and previous links)
    Enable partial page refresh - yes
    Display position - bottom -right
    Their is an arrow mark link(next /previous) in the right bottom corner,when i click on that ,the region is displaying the next 15 rows, but the region is not getting refresh,the scroll bars are al went off if i click the previous/next link.
    After that i refreshed the page by clicking F5 ,scroll bar is appearing now.
    In the region header and footer i have added this code,
    <div style="overflow:auto;">
    </div>for scroll bar
    Please some body help me to fix this issue..
    Thanks & Regards,
    Ramya.
    Edited by: Ramya on Apr 15, 2012 10:42 PM

    Hi All,
    I fixed this issue.
    I used Skillbuilders modal popup plugin, to open the form page as popup when i edit the record.To implement this plugin i have already created dynamic action for edit ,create and autoclose the popup.
    In the dynamic action i changed the EVENT SCOPE from BINT To LIVE and tested the application.Now its working fine.
    I can able to edit the record after i hit the next/previous pagination link .
    Thanks ,
    Ramya.

  • How do you dispose a thread-handled modal dialog not thru some actions?

    The code almost looks like this:
    /* Thread that disposes the dialog when the time in seconds is "9" */
    class AboutThread extends Thread {
    private volatile Thread about;
    AboutDialog ad;
    AboutThread(AboutDialog ad) {
    this.ad = ad;
    public void stopped() {
    about = null;
    ad.dispose();
    ad = null;
    System.gc();
    public synchronized void run() {
    Thread thisThread = Thread.currentThread();
    about = thisThread;
    System.out.println("About thread is running!");
    ad.start();
    while (about == thisThread) {
    try {
    Thread.sleep(1000);
    } catch (InterruptedException ex) {
         System.err.println("Thread.sleep error: " + ex);
    String s = new String(getCurrentDateTime("s"));
    if (s.equals("9")) {
    ad.setVisible(false);
    ad.setModal(false);
    ad.setVisible(true);
    System.out.println(9);
    this.stop();
    /* Shows a dialog describing the User Log application */
    public class AboutDialog extends Dialog implements ActionListener {
    public AboutDialog(Frame parent, String title) {
         super(parent, title, false);
         Panel labelPanel = new Panel();
         labelPanel.setLayout(new BorderLayout());
         labelPanel.setBackground(Color.gray);
    JLabel jlab = new JLabel("User Log 1.0");
    jlab.setHorizontalAlignment(SwingConstants.CENTER);
    jlab.setFont(new Font("Monospaced", Font.BOLD, 28));
    JLabel jlab1 = new JLabel("Copyright(c) 2001 Soft Wares. All Rights Reserved.");
    jlab1.setHorizontalAlignment(SwingConstants.CENTER);
    labelPanel.add(jlab, "Center");
         labelPanel.add(jlab1, "South");
         add(labelPanel, "Center");
         Panel buttonPanel = new Panel();
    buttonPanel.setBackground(Color.gray);
         Button okButton = new Button("OK");
         okButton.addActionListener(this);
         buttonPanel.add(okButton);
         add(buttonPanel, "South");
         setSize(400, 130);
         setLocation(parent.getLocationOnScreen().x + 200,
              parent.getLocationOnScreen().y + 200);
    public void start() {
    show();
    public void actionPerformed(ActionEvent e) {
         setVisible(false);
         dispose();
    at.stopped();
    }

    ooops! i'm sorry. in the AboutDialog Class, it should be "super(parent, title, true)" for it to be modal.
    anyway, it seemed that posting the partial code above of the whole app is not so understandable.
    what i like to address here is that: how do i dispose or get rid of the thread-dispatched modal dialog by not making mouse clicks or any other user intervention? i wanted it to be disposed by the same thread, which dispatched it, when a certain variable value (global or local) is met. is this possible?

  • Partial page submit

    Hi,
    I have 2 HTML regions in my page. Region1 has its set of buttons like while region2 but when submit button in region 1 is clicked i want it to only refresh/submit that particular region not the entrire page, also when button in region2 is clicked it should submit only that region2.
    Any idea?
    thanks.

    Gor_Mahia wrote:
    Hi,
    I have 2 HTML regions in my page. Region1 has its set of buttons like while region2 but when submit button in region 1 is clicked i want it to only refresh/submit that particular region not the entrire page, also when button in region2 is clicked it should submit only that region2.
    Any idea?
    thanks.What version of Apex are you using? Not sure if you can partially submit a HTML region. I could think of 3 possible options:
    1. AJAX region pull as described here:
    http://apex.oracle.com/pls/otn/f?p=11933:48
    and here:
    Partial refreshing of pages in 2.0 ?
    So, in your case, you can have the Region 2 in a different page and use the technique described above to pull the region's HTML into your current page.
    2. Use the Skillbuilder's modal window plugin - http://apex-plugin.com/oracle-apex-plugins/dynamic-action-plugin/skillbuilders-modal-page_138.html
    You can have the Region 2 developed in a different page. You can then invoke it from your current page using a DA.
    3. Call a Javascript function from the "submit" button. Let the JS function call a AJAX on-demand application process to do the computation. Later, you can refresh the page items in the JS function, as described here:
    Set item value using AJAX
    Hope the above helps.
    Thanks,
    Rohit

  • I created a semi modal jwindow?!

    I have a jframe, which calls a modal jdialog.
    On that jdialog I use a custom control which creates a jwindow. My problem is that when the jdialog is modal all mouse events are blocked in the created jwindow and I can't figure out why. However, if the jdialog is created as modeless everything works fine.
    Anybody have any ideas?
    V

    Thank you,
    Now I have found that this is an issue that has not been solved for several years. Partial / Window / Parent modality is something, AFAIK, not supported currently in Java.
    There have been workarounds for it, like the one shown in thread [http://forums.sun.com/thread.jspa?forumID=257&threadID=215788] .
    Hope there will be a feature to do this in a future release.

  • Modal Picker Views? - iPhone

    I need to display several picker view (dates, colors, etc.) for data input and what I did previously was to just create a picker view and show and hide it. However, the picker view only covered half the screen so users could still tap on other areas of the app (causing problems) and there was no intuitive way to dismiss it.
    So, like in Safari, I want to display a modal picker view that animates from below that includes a toolbar above it with a Cancel and Done button to dismiss it and the parent view can be seen behind a grayed-out view above the picker but cannot be tapped.
    I put this all together with IB, got it all working, and I am using "presentModalViewController" and such to present and hide a picker view, a toolbar with Cancel and Done, all on top of a full-screen semi-transparent view (opacity 30% of the view background). It looks exactly like I want it in IB.
    However, when clicking a button in the main view to display this modal view, the parent view can be seen (with buttons and such) behind the semi-transparent top half of the picker view during the animations (presenting and hiding) but when the animations are finished, the area above the picker view and toolbar is now still semi-transparent but there is no parent view behind the view to see. (is the parent view pushed somewhere else?)
    So, does anyone know how to display picker views with a toolbar in a modal fashion in a view that shows a grayed-out parent view above the picker and toolbar? Thanks.

    Just create your own view, I recommend including a navigationItem so you can use it as a rootviewcontroller for the navigation controller's stack (and therefore show the buttons in the top bar). intially when you set up the view, position it outside of the screen then apply built-in animations that can be used for a view and slide it up have (if you need abackground too that is partially transparent, just make it a superview of the view that you want to slide
    about the user interactions.. just assign a tag to that view (for instance if its a tableview or a view) assign a tag, and right before you do your animation for your "modal" view, just call it from the UIApplication sharedApplcation keyWindow's method and disable user interactions

  • Open Discussion Thread in Modal Dialog

    Hi again,
    I am wondering if it possible to have SharePoint open a discussion thread in a modal dialog. To be clear, this happens when someone adds a new discussion thread (ie. creates a new one). However, when clicking on an existing one to provide a comment, this
    opens in a new page rather than in a modal dialog. I would prefer the modal approach as the user then doesn't leave the page when submitting a reply to a thread.
    Is this possible?
    thanks!

    I have a solution, but
    This will require the use of SharePoint Designer.
    It has not been heavily tested, and only tested in SP 2010.
    The reply counts will not be automatically updated in the base discussion page.
    The page will be "unghosted" (customized) and might not upgrade correctly to the next version of SharePoint.
    Use at your own risk, batteries not included.
    Steps:
    Launch SharePoint Designer and open the site with the discussion board.
    In Navigation pane click All Files. (If this is not displayed your administrators may have partially locked down Designer.) 
    Click Lists
    Click your discussion list
    Click Allitems.aspx
    In the Ribbon click Advanced Mode
    find the following lines:
    </ZoneTemplate></WebPartPages:WebPartZone>
    </asp:Content>
    In between these two lines insert a blank line and paste the JavaScript below.
    Save your changes, return to the discussion list and test.
    <script>
    function ttnGoToDiscussion(url)
    var options = SP.UI.$create_DialogOptions();
    options.url = url;
    options.width = 800;
    options.height = 500;
    SP.UI.ModalDialog.showModalDialog(options);
    function ChangeHowDiscussionsOpen()
    GoToDiscussion = ttnGoToDiscussion;
    ChangeHowDiscussionsOpen()
    </script>
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

  • Partial delivery per item in sales order and ATP - schedule lines

    Hi,
    I've problem regarding ATP- schedule lines and partial delivery flag.
    In sales order there is flag Partial delivery per item B / 1 . That means create only one delivery even with quant 0. That comes from customer master or customer info-record and it is OK.
    Please look at next example.
    Customer requires:
    10 PCS of materail A on date X. Only 5 PCS are available on date X.
    10 PCS of material B on date X 0 PCS are available on date X, 10 PCS are available on date Y.
    So if we create outbound delivery on date X it will contain only 5 PCS of material  A. No successive deliveries will be created for material A because of the flag B/1. That item is closed.
    Problem is with material B.
    The sales order will be open because of material B and on date Y we can easily create another delivery with 10 PCS of mat B.
    That is wrong. Agreement with customer is only one delivery for ALL items in sales order. If we create delivery on date X it should contain only materials which are available on date X and sales order should close.
    Do you know how to fix this problem?

    Hi,
    I've think you didn't understand my requirement. I allways get schedule lines but they are confirmed on different dates.
    Example in same sales order we have:
    Schedule line for item A:
    DATE X confirmed quantity 10
    Schedule line for an item B.
    DATE X confirmed quanitity 0 (zeroe)
    DATE Y confirmed quantity 10.
    I would like to create outbond delivery on date X with:
    item A quantity 10
    item B quantity 0.
    And if that hapens than B/0 rule will work or reference customzing that you suggested before. So order will be closed because all items are processed or referenced once.
    Do you know how to do that?
    Regards

  • Open Skillbuilders modal page from report

    I want to open the Skillbuilders modal page from within a report. The first column in a report represents the primary key of the table the report shows. What is the best way to do that?
    The idea is this: in the report region, there's a button CREATE that opens the modal dialog by Skillbuilders. A user can enter some data, clicks submit, modal dialog closes and report is refreshed. That's working now. Now I want to add a link to the first column in the report, that also opens the modal dialog, passing the value of the primary key of the row the user clicks on.
    I'm not that experienced with Javascript, I guess I'll have to create an dynamic action with a jquery selector, and as a true action, a javascript call to open the dialog. Can someone give me a start?
    Thanks in advance!

    You actually do not need that much javascript in this case. Simply design your column as you would normally do to create a link column.
    <ul>
    <li>Column Link: Provide a link text</li>
    <li>Link Attributes: onclick="return false;" class="show_modal"</li>
    <li>Set the target page and provide any items you want filled.</li>
    </ul>
    onclick="return false;" is to prevent the default behaviour of the anchor tag: navigate to the location specified in the href attribute. We want to open the modal page instead.
    Now to have the modal dialog open, create a dynamic action.
    <ul>
    <li>Event: Click</li>
    <li>Selection Type: jQuery Selector</li>
    <li>jQuery Selector: .show_modal</li>
    <li>Advanced > Event Scope: live (so the links will work after pagination)</li>
    </ul>
    For the true action, select the SkillBuilders Modal Page plugin, and make sure these are specified as following. This will take the location in the generated link columns and open a modal page for this location.
    So, this would open your edit page with the correct id (which you set up in the column link).
    </ul>
    <li>URL Location: Attribute of Triggering Element</li>
    <li>Attribute Name: href</li>
    </ul>
    If you set it up like this, you have the convenience of the standard column link definitions, no need for any javascript save onclick=false and no need to fill up page items and deal with submission to session state.

  • Not able to open Modal Page through a report attribute link

    Dear All,
         Not able to open Modal Page through a report attribute link, kindly help me...
      I am using skill builders modal page plugin ...
    Thanks and Regards,
    Madonna

    Here's what you have to do.
    You set up your column link like this:
    Link text: whatever you like
    Link attributes: onclick="return false;" class="open_modal"
    Target: Page in this application
    Page: number of the page you want to open in your modal window
    You set up your dynamic action like this:
    Event: Click
    Selection type: jQuery selector
    jQuery selector: .open_modal
    (notice the dot at the beginning!)
    Action: SkillBuilders Modal Page (2.0.0) [Plug-in]
    Event Scope: Dynamic
    And finally, in your True Action (SkillBuilders Modal Page (2.0.0)), URL Location should be set as Attribute of Triggering Element.
    And that's pretty much all it takes.
    Hope this helps.

  • Getting error in XMLP while compare a Tag value to partial value

    Hi All,
    We are working on 'AP Check Print Report' which is XML based Report and the output is in the PDF format.
    We are facing a problem when we are suppose to compare a Tag value (DocumentNumber/ReferenceNumber) to a partial value('%TDS-CM%') as below,
    <?if:DocumentNumber/ReferenceNumber NOT LIKE '%TDS-CM%'?>
    Can someone help me, how to achieve it as well as whether it can be done or not.
    Thanks in advance
    Abhishek

    Have a look at these threads:
    Re: Using Wild Card % in the IF condition of RTF templates
    Re: Syntax for IN / NOT IN Commands
    Thanks!

  • Partial Multibyte Character Error

    Hi All,
    I am getting following error while running a report in OBIEE 11 G.
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 17001] Oracle Error code: 29275, message: ORA-29275: partial multibyte character at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)
    NLS_LANG Paramters is set at the Oracle database 11.
    [NLS_LANGUAGE].[NLS_TERRITORY][NLS_CHARACTERSET]----------->AMERICAN.AMERICA.AL32UTF8
    Any help in this.

    Hi,
    It's seems are you using char function in your report?
    If yes, Change the char size .
    ex: cast(column name as char).
    A. Cast(column name as char(300)).
    I am not sure this is what your looking so far.
    Award points it is useful.
    Thanks,
    Satya

  • Modal Dialogs in Automation plugin?

    I seem to be unable to get my dialog window into a modal state when it's called as part of an Automation plugin on Windows. I've been using the very same code (wxWidgets based) from an Export plugin, and everything works fine there. Also on Mac everything is well.
    However, running that dialog from an Automation plugin, I can still interact with document windows behind my dialog. The dialog is always front, but not always the active window.
    Does anyone have any clues how event handling is different for Automation plugins, or how I could work around this?

    HI, I want create a dialog as your "wrong state", which i can still interact with the document when it show.
    How you create this dialog? Can you give me your code ?
    My hotmail is: [email protected]
    Thanks.

Maybe you are looking for