Stopping execution without modal Jdialog

Hi there,
I am writing a gui that needs to wait for a button click. I used to use a modal JDialog for this, which worked fine, but I have recently changed the GUI to a wizard style, and I would like to simply redraw a Card every time, rather than having a popup Dialog.
Basically the program will show info, but this info will change whenever the button is pressed.
How would I go about this without using a modal JDialog?, In other words, how can I make the program wait until button press? I am very confused about wait() and notify(), its not as simple as I thought, maybe someone can enlighten me.
Thanks for any help

Wow ok, I really screwed up on this one. Let me start again, For anyone still reading:
The program I am writing presents the User with a choice to which they must reply with using a button press. This is easily done using a JDialog that is Modal as the program waits until the JDialog is disposed.
My question is whether it is possible to achieve this effect without using a JDialog. I am doing it without a JDialog because I do not wish to have any pop ups, rather just a constantly refreshing JPanel.
To sum up: How do I achieve the modal effect of a JDialog using other Components?
I am unable to post any code right now, if anyone needs to see some I will gladly post it tommorow.
Thanks again!

Similar Messages

  • How to break execution when Modal SubVI opened?

    Colleagues,
    A very simple question: sometimes I have modal dialogs, which cannot be closed (this may happened during programming, when logic not completed, or if one of then modal dialogs was opened, and then main VI was started). So, when it happened, then the only way to break execution is killing LabVIEW from Task Manager. I remember that was a simple trick how to stop execution without killing LabVIEW, but can't remember. Can you please give me a hint - how to stop execution in such situation? Yes, I know about Ctrl+. combination, but this doesn't work in this case.
    See attachment for details.
    Andrey.
    Solved!
    Go to Solution.
    Attachments:
    Modal SubVI.zip ‏8 KB

    Try pressing "Ctrl + ." (period) to stop the VI.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How to stop execution in while loop without stopping execution of other loops in the same vi

    HI
    I am quite a novice in Labview.
    I have a problem in my project. I used a while loop inside my vi to build an array of ten values along with other loops. Then I used a stop button to stop manually the while loop. But it seems like the loop doesn't stop in the middle of the array building and so other loops in the vi doesn't work until the while loop finishes building the array and as soon as while loop execution is over, the complete vi stops. But all that I wanted was to build the array using the shift register along with the control to stop building array anytime. And not to stop execution of other structures when the while loop finishes.
    Can anyone help me?
    Rahul

    Hi Rahul,
    Modified ur Vi to work with single button.
    But the subtract case is not in any loop.
    So, once both the loops stop, the subtract case will execute only once. Depending on state of subtaract boolean at that time, corresponding case will be executed and the Vi will stop.
    so think of a logic where u can put this also in a new loop.
    Or you can also incorporate it in one of the two loops and pass the other loop's data to it.
    Let us know how you will proceed in this regard
    I am posting your VI as well a VI with my modifications VI in Labview 7.0 so that Thomas can give his suggestions too
    Plus, always keep a time delay in your while loops.
    Oh sorry, the "arrayinouttestnewfinal.vi" is the modified vi
    Regards
    Dev
    Message Edited by devchander on 01-10-2006 06:15 AM
    Message Edited by devchander on 01-10-2006 06:19 AM
    Attachments:
    arrayinouttestnewfinalnew4.vi ‏59 KB
    arrayinouttestnewfinal.vi ‏63 KB

  • Issues opening pdf in a modal jdialog

    Hi guys,
    I've a strange issue, I can't solve it.
    I'm newbie of java swing and this is a very difficult issue.
    I've a jdialog modal. In this jDialog I've a button, clicking on it a pdf is generated with itext.
    I observed that:
    -if I try to generate pdf from a frame, pdf is shown over the frame.
    -if I try to generate pdf from a jdialog swing(that's case I need) pdf is shown below jdialog...so I can't see pdf without closing jdialog and it's not good.
    How can I proceed in the second case?
    Thanks

    hi,
    thanks for your reply...I try to addo more detail.
    I have a modal jdialog.
    In it I have a button, clicking on it is called a method to create a pdf with itext.
    Here a snippet of code
    try {
                  Document document = new Document(PageSize.A4);
                   PdfWriter.getInstance(document, new FileOutputStream(FILE));
                   document.open();
                            create(document);
                   document.close();
                            String[] command = new String[3];
                   command [0] = "cmd.exe";
                   command [1] = "/C";
                   command [2] = "\"" + FILE+ "\"";
                            Runtime.getRuntime().exec(command );
              } catch (Exception e) {
                   e.printStackTrace();
                            JOptionPane.showMessageDialog(null, "Si è verificato il seguente errore: "+e.getMessage(), "Errore stampa pdf", JOptionPane.ERROR);
                            return;
              }Following this way pdf is opened but it's shown under the modal jdialog that called it.
    So for watching it I need to close modal jdialog.
    How can I run pdf to make it OVER a modal jdialog?
    Thanks,
    Regards

  • Problems with 'background' JFrame focus when adding a modal JDialog

    Hi all,
    I'm trying to add a modal JDialog to my JFrame (to be used for data entry), although I'm having issues with the JFrame 'focus'. Basically, at the moment my program launches the JFrame and JDialog (on program load) fine. But then - if I switch to another program (say, my browser) and then I try switching back to my program, it only shows the JDialog and the main JFrame is nowhere to be seen.
    In many ways the functionality I'm looking for is that of Notepad: when you open the Find/Replace box (albeit it isn't modal), you can switch to another program, and then when you switch back to Notepad both the main frame and 'JDialog'-esque box is still showing.
    I've been trying to get this to work for a couple of hours but can't seem to. The closest I have got is to add a WindowFocusListener to my JDialog and I hide it via setVisible(false) once windowLostFocus() is fired (then my plan was to implement a similar functionality in my JFrame class - albeit with windowGainedFocus - to show the JDialog again, i.e. once the user switches back to the program). Unfortunately this doesn't seem to work; I can't seem to get any window or window focus listeners to actually fire any methods, in fact?
    I hope that kind of makes sense lol. In short I'm looking for Notepad CTRL+R esque functionality, albeit with a modal box. As for a 'short' code listing:
    Main.java
    // Not all of these required for the code excerpt of course.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.GraphicsEnvironment;
    import java.awt.Rectangle;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowFocusListener;
    import java.awt.event.WindowListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import javax.swing.UIManager;
    import javax.swing.plaf.basic.BasicSplitPaneDivider;
    import javax.swing.plaf.basic.BasicSplitPaneUI;
    public class Main extends JFrame implements ActionListener, WindowFocusListener, WindowListener, FocusListener {
         static JFrame frame;
         private static int programWidth;
         private static int programHeight;
         private static int minimumProgramWidth = 700;
         private static int minimumProgramHeight = 550;
         public static SetupProject setupProjectDialog;
         public Main() {
              // Setup the overall GUI of the program
         private static void createSetupProjectDialog() {
              // Now open the 'Setup Your Project' dialog box
              // !!! Naturally this wouldn't auto-open on load if the user has already created a project
              setupProjectDialog = new SetupProject( frame, "Create Your Website Project", true );
              // Okay, for this we want it to be (say) 70% of the progamWidth/height, OR *slightly* (-25px) smaller than the minimum size of 700/550
              // Change (base on programWidth/Height) then setLocation
              int currProgramWidth = getProgramWidth();
              int currProgramHeight = getProgramHeight();
              int possibleWidth = (int) (currProgramWidth * 0.7);
              int possibleHeight = (int) (currProgramHeight * 0.7);
              // Set the size and location of the JDialog as needed
              if( (possibleWidth > (minimumProgramWidth-25)) && (possibleHeight > (minimumProgramHeight-25)) ) {
                   setupProjectDialog.setPreferredSize( new Dimension(possibleWidth,possibleHeight) );
                   setupProjectDialog.setLocation( ((currProgramWidth/2)-(possibleWidth/2)), ((currProgramHeight/2)-(possibleHeight/2)) );
               else {
                   setupProjectDialog.setPreferredSize( new Dimension( (minimumProgramWidth-25), (minimumProgramHeight-25)) );
                   setupProjectDialog.setLocation( ((currProgramWidth/2)-((minimumProgramWidth-25)/2)), ((currProgramHeight/2)-((minimumProgramHeight-25)/2)) );
              setupProjectDialog.setResizable(false);
              setupProjectDialog.toFront();
              setupProjectDialog.pack();
              setupProjectDialog.setVisible(true);
         public static void main ( String[] args ) {
              Main frame = new Main();
              frame.pack();
              frame.setVisible(true);
              createSetupProjectDialog();
            // None of these get fired when the Jframe is switched to. I also tried a ComponentListener, but had no joy there either.
         public void windowGainedFocus(WindowEvent e) {
              System.out.println("Gained");
              setupProjectDialog.setVisible(true);
         public void windowLostFocus(WindowEvent e) {
              System.out.println("GainedLost");
         public void windowOpened(WindowEvent e) {
              System.out.println("YAY1!");
         public void windowClosing(WindowEvent e) {
              System.out.println("YAY2!");
         public void windowClosed(WindowEvent e) {
              System.out.println("YAY3!");
         public void windowIconified(WindowEvent e) {
              System.out.println("YAY4!");
         public void windowDeiconified(WindowEvent e) {
              System.out.println("YAY5!");
         public void windowActivated(WindowEvent e) {
              System.out.println("YAY6!");
         public void windowDeactivated(WindowEvent e) {
              System.out.println("YAY7!");
         public void focusGained(FocusEvent e) {
              System.out.println("YAY8!");
         public void focusLost(FocusEvent e) {
              System.out.println("YAY9!");
    SetupProject.java
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowFocusListener;
    import java.awt.event.WindowListener;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class SetupProject extends JDialog implements ActionListener {
         public SetupProject( final JFrame frame, String title, boolean modal ) {
              // Setup the JDialog
              super( frame, title, modal );
              setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
              // Bad code. Is only temporary
              add( new JLabel("This is a test.") );
              // !!! TESTING
              addWindowFocusListener( new WindowFocusListener() {
                   public void windowGainedFocus(WindowEvent e) {
                        // Naturally this now doesn't get called after the setVisible(false) call below
                   public void windowLostFocus(WindowEvent e) {
                        System.out.println("Lost");
                        setVisible(false); // Doing this sort of thing since frame.someMethod() always fires a null pointer exception?!
    }Any help would be very much greatly appreciated.
    Thanks!
    Tristan

    Hi,
    Many thanks for the reply. Isn't that what I'm doing with the super() call though?
    As in, in Main.java I'm doing:
    setupProjectDialog = new SetupProject( frame, "Create Your Website Project", true );Then the constructor in SetupProject is:
    public SetupProject( final JFrame frame, String title, boolean modal ) {
              // Setup the JDialog
              super( frame, title, modal );
              And isn't the super call (since the class extends JDialog) essentially like doing new JDialog(frame,title,modal)?
    If not, that would make sense due to the null pointer exception errors I've been getting. Although I did think I'd done it right hence am confused as to the right way to handle this,if so.
    Thanks,
    Tristan
    Edited by: 802573 on 20-Oct-2010 08:27

  • Stop execution until GUI is completed

    I wrote a program to monitor a seniority list. If an odd last name, first name, etc is encountered, a gui opens to request the proper form of the name. The problem is that the program keeps running even though the gui has not yet been fililed out. How do I stop execution until the GUI is completed?
    Thanks
    Joe

        public static void readFile2(String lnames   [], String fnames[], String mnames[],
                                     String facs     [], String sdates[], String scores[],
                                     String scrambles[], String filename)
            String tempTitle = "JR";
            System.out.println("Inside ReadFile");
            try
                System.out.println("Inside Try");
                BufferedReader in = new BufferedReader(new FileReader( filename ));
                        //"C:/Documents and Settings/Joe/JavaApplication1/src/test.txt"));
                String tempElement  = "";
                //String tempElements[15];
                String tempElement1 = "";
                String tempElement2 = "";
                String tempElement3 = "";
                String tempElement4 = "";
                String tempElement5 = "";
                String tempElement6 = "";
                String tempElement7 = "";
                String tempElement8 = "";
                String tempElement9 = "";
                String tempElement10 = "";
                String tempElement11 = "";
                String tempElement12 = "";
                StringTokenizer data;
                String S;
                int numberOfTokens = 0;
                int numberOfWords  = 0;
                int numberOfLines  = 0;
                S = in.readLine();
                data = new StringTokenizer(S);
                numberOfTokens = data.countTokens();
                //System.out.println("Next Token " + data.nextToken());
                //System.out.println(data);
                //array[row][col]
                System.out.println("Ready to Tokenize");
                int i = 0;
                int q = 0;
                int lineCount = 0;
                while( ( ! S.equals("") ) && (data.hasMoreTokens() )
                                          && (S.trim().length() != 0))//in.readLine()
                    int col = 0;
                    int j = 0;
                    //while( i < SenListHelpers.getArrayLength(tempElements2) )
                        while( data.hasMoreTokens() )
                            tempElements1[i][j] = data.nextToken();    //get LName
                            System.out.println(" Getting tempElements1[ " + i + " ]" + "[ " + j + " ]" + tempElements1[i][j]);
                            //System.out.println("tempElements [" +  i  +  "] "    + tempElements1[i][j]);
                            j ++;
                        i ++;
                        System.out.println(" i = " + i );
                        int p = 0;
                        System.out.println("tempElements [" +  q  +  "] "    + tempElements1[q][p]
                                                                       + " " + tempElements1[q][p+1]
                                                                       + " " + tempElements1[q][p+2]
                                                                       + " " + tempElements1[q][p+3]
                                                                       + " " + tempElements1[q][p+4]
                                                                       + " " + tempElements1[q][p+5]
                                                                       + " " + tempElements1[q][p+6]);
                        q ++;    
                        //#2
                            ( compareStringByCase(tempElements1[lineCount][0], "DE"    ) ) ||
                            ( compareStringByCase(tempElements1[lineCount][0], "LE"    ) ) ||   
                            ( compareStringByCase(tempElements1[lineCount][0], "LA"    ) ) ||
                            ( compareStringByCase(tempElements1[lineCount][0], "MC"    ) ) ||  
                            ( compareStringByCase(tempElements1[lineCount][0], "ST"    ) ) ||
                            ( compareStringByCase(tempElements1[lineCount][0], "ST."   ) ) ||   
                            ( compareStringByCase(tempElements1[lineCount][0], "VAN"   ) ) ||    
                            ( compareStringByCase(tempElements1[lineCount][0], "EL"    ) )
                        if( ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "DE"    ) ) ||
                            ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "LE"    ) ) ||   
                            ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "LA"    ) ) ||
                            ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "MC"    ) ) ||  
                            ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "ST"    ) ) ||
                            ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "ST."   ) ) ||   
                            ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "VAN"   ) ) ||    
                            ( SenListHelpers.compareStringByCase(tempElements1[lineCount][0], "EL"    ) ) )
                            System.out.println("");
                            correctOfficerGUI test = new correctOfficerGUI(tempElements1, lineCount);
                            test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
                            return;// from this method;
    //Here is the GUI class
    public class correctOfficerGUI extends JFrame
            private final JTextField nameInfo, lname, fname, mname, sdate, score, scramble;
            private JPanel form;
            private final JFrame f;
            //EASTERN NY
            public static String nameInfoString   = new String();
            String facilities[] = {     
            "ADIRONDACK",     "ALBION",    "ALTONA", "ARTHUR KILL", "ATTICA",                         
         "AUBURN CORR",  "BARE HILL", "BAYVIEW",     "BEACON", "BEDFRD HILL",                    
            "BUFFALO",      "BUTLER",    "BUTLER ASAT", "GABRIELS",     "GEORGETOWN",                    
         "PHARSALIA",     "CAPE VINCEN", "CAYUGA", "CHATEAUGAY", "CLINTON COR",     
         "COLLINS",     "COXSACKIE", "DOWNSTATE", "EASTERN NY", "EDGECOMBE",                    
         "ELMIRA CNTR",  "FISHKILL",  "FIVE POINTS", "FRANKLIN", "FULTON FAC",                    
         "GOUVERNEUR",     "GOWANDA", "GREAT MEADW", "GREEN HAVEN", "GREENE",                         
         "GROVELAND",     "HALE CREEK", "HUDSON", "LAKEVIEW", "LAKEVIEW ASA",
         "LINCOLN FAC",     "LIVINGSTON", "LYON MTN", "MARCY", "MID-ORANGE",                    
         "MID STATE",     "MOHAWK",     "MONTEREY", "MORIAH SICF", "MT MCGREGOR",     
            "NYC CTL ADM",  "OGDENSBURG", "ONEIDA",  "ORLEANS", "OTISVILLE",                    
         "QUEENSBORO",     "RIVERVIEW",  "ROCHESTER", "SHAWANGUNK", "SING SING",                    
         "SOUTHPORT",     "SULLIVAN",   "SUMMIT",     "TACONIC C F", "ULSTER",                         
         "UPSTATE",     "WALLKILL",  "WASHINGTON", "WATERTOWN", "WENDE",                         
         "WILLARD",     "WOODBOURNE", "WYOMING"};
        public correctOfficerGUI(String[][] array, int lineCount)
            //JFrame
            f = new JFrame("Add Officer");
            // Make a panel to hold the demo �form", then
            // add it to the top of the frame�s content pane
            //JPanel
            form = new JPanel();
            f.getContentPane().setLayout(new BorderLayout());
            f.getContentPane().add(form, BorderLayout.NORTH);
            // Set the form panel�s layout to GridBagLayout
            // and create a FormUtility to add things to it.
            form.setLayout(new GridBagLayout());
            FormUtility formUtility = new FormUtility();
            // Add some sample fields
            System.out.println(array[lineCount][0] + " " + array[lineCount][1] + " " +
                               array[lineCount][2] + " " + array[lineCount][3] + " " +
                               array[lineCount][4] + " " + array[lineCount][5] + " " +
                               array[lineCount][6] + " " + array[lineCount][7] );
            formUtility.addLabel("Name Info: ", form);
            //JTextField
            nameInfo = new JTextField();
            Dimension nameInfoSize = nameInfo.getPreferredSize();
            nameInfoSize.width = 180;
            nameInfo.setPreferredSize(nameInfoSize);
            JPanel nameInfoPanel = new JPanel();
            nameInfoPanel.setLayout(new BorderLayout());
            nameInfoPanel.add(nameInfo, BorderLayout.WEST);
            formUtility.addLastField(nameInfoPanel, form);
            nameInfo.setText(getNameInfo(array, lineCount));
            formUtility.addLabel("Last Name: ", form);
            //JTextField
            lname = new JTextField();
            Dimension lnameSize = lname.getPreferredSize();
            lnameSize.width = 150;
            lname.setPreferredSize(lnameSize);
            JPanel lnamePanel = new JPanel();
            lnamePanel.setLayout(new BorderLayout());
            lnamePanel.add(lname, BorderLayout.WEST);
            formUtility.addLastField(lnamePanel, form);
            //lname.setText("xxx");
            formUtility.addLabel("First Name: ", form);
            //JTextField
            fname = new JTextField();
            Dimension fnameSize = lname.getPreferredSize();
            fnameSize.width = 150;
            fname.setPreferredSize(fnameSize);
            JPanel fnamePanel = new JPanel();
            fnamePanel.setLayout(new BorderLayout());
            fnamePanel.add(fname, BorderLayout.WEST);
            formUtility.addLastField(fnamePanel, form);       
            formUtility.addLabel("Middle Initial: ", form);
            //JTextField
            mname = new JTextField();
            Dimension mnameSize = mname.getPreferredSize();
            mnameSize.width = 20;
            mname.setPreferredSize(mnameSize);
            JPanel mnamePanel = new JPanel();
            mnamePanel.setLayout(new BorderLayout());
            mnamePanel.add(mname, BorderLayout.WEST);
            formUtility.addLastField(mnamePanel, form);   
            formUtility.addLabel("Facility: ", form);
            //JTextField spacer = new JTextField();
            //Dimension spacerSize = spacer.getPreferredSize();
            //spacerSize.width = 20;
            //spacer.setPreferredSize(spacerSize);
            JPanel spacerPanel = new JPanel();
            spacerPanel.setLayout(new BorderLayout());
            //spacerPanel.add(spacer, BorderLayout.WEST);
            formUtility.addLastField(spacerPanel, form);   
         //Container contentpane;
            //contentpane = getContentPane();
         //contentpane.setLayout(new FlowLayout());
            final JList list = new JList(SenListArraySetUp.facilities);
            /* getFacilityIndex( SenListHelpers.getFacility(array, lineCount), facilities ) */
            System.out.println("getFacility     " + SenListHelpers.getFacility(array, lineCount) );
            System.out.println("*******");
            //System.out.println("getFacility     " + getFacilityIndex( SenListHelpers.getFacility(array, lineCount), SenListArraySetUp.facilities ) );
            //getFacilityIndex( SenListHelpers.getFacility(array, lineCount), facilities );
            System.out.println(" ");
            int index = getFacilityIndex( SenListHelpers.getFacility(array, lineCount), SenListArraySetUp.facilities );
            System.out.println("Index    " + index);
         list.setSelectedIndex(0);
            list.setVisibleRowCount(1);
         list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
         //contentpane
            spacerPanel.add(new JScrollPane(list));
            formUtility.addLabel("Seniority Date: ", form);
            //JTextField
            sdate = new JTextField();
            Dimension sdateSize = sdate.getPreferredSize();
            sdateSize.width = 70;
            sdate.setPreferredSize(sdateSize);
            JPanel sdatePanel = new JPanel();
            sdatePanel.setLayout(new BorderLayout());
            sdatePanel.add(sdate, BorderLayout.WEST);
            formUtility.addLastField(sdatePanel, form); 
            sdate.setText(array[lineCount][SenListHelpers.getSenDateIndex(array, lineCount)]);
            formUtility.addLabel("Score: ", form);
            JTextField score = new JTextField();
            Dimension scoreSize = score.getPreferredSize();
            scoreSize.width = 20;
            score.setPreferredSize(scoreSize);
            JPanel scorePanel = new JPanel();
            scorePanel.setLayout(new BorderLayout());
            scorePanel.add(score, BorderLayout.WEST);
            formUtility.addLastField(scorePanel, form);       
            formUtility.addLabel("Score: ", form);
            //JTextField
            score = new JTextField();
            Dimension scoreSize = score.getPreferredSize();
            scoreSize.width = 30;
            score.setPreferredSize(scoreSize);
            JPanel scorePanel = new JPanel();
            scorePanel.setLayout(new BorderLayout());
            scorePanel.add(score, BorderLayout.WEST);
            formUtility.addLastField(scorePanel, form); 
            score.setText(array[lineCount][SenListHelpers.getArrayColLength(array, lineCount)]);
            formUtility.addLabel("Scramble: ", form);
            //JTextField
            scramble = new JTextField();
            Dimension scrambleSize = scramble.getPreferredSize();
            scrambleSize.width = 30;
            scramble.setPreferredSize(scrambleSize);
            JPanel scramblePanel = new JPanel();
            scramblePanel.setLayout(new BorderLayout());
            scramblePanel.add(scramble, BorderLayout.WEST);
            formUtility.addLastField(scramblePanel, form);       
            JButton addButton = new JButton("Add");
            form.add(addButton);
            //addButton.add(       
         addButton.addActionListener(
              new ActionListener()
              public void actionPerformed( ActionEvent actionEvent )//valueChanged(ListSelectionEvent e)
                        System.out.println("LName is:    " + lname.getText());
                        System.out.println("FName is:    " + fname.getText());
                        System.out.println("MName is:    " + mname.getText());
                        System.out.println("Facility is: " + SenListArraySetUp.facilities[list.getSelectedIndex()]);
                        System.out.println("SenDate is:  " + sdate.getText());
                        System.out.println("Score is:    " + score.getText(/*SenListHelpers.getArrayColLength(array, lineCount - 1)*/));
                        System.out.println("Scramble is: " + scramble.getText(/*SenListHelpers.getArrayColLength(array, lineCount)*/));
                        nameInfoString = lname.getText()    + " " + fname.getText() + " " + mname.getText() + " " +
                                         SenListArraySetUp.facilities[list.getSelectedIndex()]
                                                            + " " + sdate.getText() + " " + score.getText() + " " +
                                         scramble.getText();
                        //System.out.println("Size is: " + SenListHelpers.getArrayLength(SenListArraySetUp.NYSDOCS_Alpha_List_LastNames));
                        insertMethods.insertIntoNYSDOCSAlphaHelper(
                           lname.getText(), fname.getText(), mname.getText(),     
                          facilities[list.getSelectedIndex()],               
                          sdate.getText(), score.getText(), scramble.getText() );
                        //form.cl
                        f.dispose();
                        JOptionPane.showMessageDialog(null, "The Officer has been Added.");
                        //return;                   
                        //System.exit(0);
                        //System.out.println("Facility is:    " + facilities[list.getSelectedIndex()]);
                        /**/ //System.out.println("Facility is:    " + facilities[list.getSelectedIndex()]);
                  //contentpane.setBackground(listColorValues
                        //[list.getSelectedIndex()]);
            // Add an little padding around the form
            form.setBorder(new EmptyBorder(2, 2, 2, 2));
    //        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//original close operation
            // Note that we don�t use pack() here, since that
            // may shrink the �last" column more than we want.
            f.setSize(300, 300);//230);
            f.setVisible(true);
            //return;
        }

  • How to stop execution after generating error message in an error handler?

    I am working on ALSB 3.0.I have a proxy consisting of 2 stages in a pipeline pair. I have error handlers for each of the stages. The first stage contains schema validation action. Whenever the schema validation fails,control should transfer to error handler.
    The error handler has a publish action and in request action I am calling an xquery transformation to generate error message.Publish action should publish message to a jms based business service configured. My questions are:
    1. After getting into the error handler, the first alert msg configured inside request action (of publish action) is generated.Subsequent actions to generate error xml message and to replace the contents of errorXml in $body are not executed.And so no error message is generated or published.
    2. I have also configured a reply with failure. Inspite of that,the control shifts to next stage in request pipeline and execution continues.
    Can anyone tell me where I need to do the corrections.
    Cheers.
    Edited by: arrajago on Jun 15, 2009 11:55 PM

    Got the answer.Generate error xml outside publish action.Replace action has to placed inside Publish's request action.To stop execution,use Reply action after Publish.

  • Modal JDialog messing parent layout

    Hello!
    Why does a modal JDialog mess up the parent frame layout? Actually only one panel inside it and a few components but still. When setVisible(true) is called on the dialog, the parent layout gets screwed. And when the dialog is closed it stays screwed until something makes the panel/frame re-validate itself (like resize or call to validate()). Any ideas what might be causing this?
    The dialog is modal and the frame is set as the parent for the dialog.
    Thanks,
    -teka

    Well it's possible that I am. The code is a bit complex with lots of classes etc. (and not made by me originally). Didn't find any AWT components when I browsed through the code but maybe I missed something. Does mixing AWT and Swing cause layout problems like that?
    -teka

  • Modal JDialog needs disposing  TWICE!

    I have a simple JDialog that is modal over another JDialog. It has a cancel button whose action event simply calls dispose().
    However, on first invocation of cancel, the dispose() does not actually remove the dialog; it is only on a second click that dispose() actually does kill the dialog. I notice also that the first dispose() does not cause WindowClosed() to be called. I have verified that definitely only one instance of the dialog is being referenced (hashcode on each dispose is the same).
    The problem immediately goes away if I make the dialog non-modal, but I want it modal!!
    Any suggestions? Seems like a bug to me...(j2sdk1.4.1_01)

    By calling setVisible(false) the modal JDialog disappears and while it's invisible it's not modal (awt Dialogs do that, too). I was not able to reproduce your problem, but this piece of code may solve it:
    setVisible(false);
    dispose();

  • Change a modal JDialog to non-modal JDialog

    I created a modal JDialog initially, for some result i need change it to a non-modal JDialog, is there any set modal command can do it??

    Nope.
    The reason is because of program flow:
    System.out.println("first line");
    JDialog dialog = new JDialog(modal);
    dialog.setVisible(true); // blocks this flow if and only if modal is true
    System.out.println("second line");
    Try putting a button in the dialog which prints out "button pressed".
    If you press the button each time before closing the dialog you will get:
    when modal is true:
    first line
    button presed
    second line
    when modal is false:
    first line
    second line
    button prese

  • JButton on XP non-modal Jdialog doen't work.

    I recently upgraded from 1.3 to 1.4 while upgrading my OS from NT 4.0 to XP.
    In a stand-alone application I have non-modal JDialog's that are launched as threads so that I can have multiple instances of them running simultaneously. There are JButton's on the JDialog's which no longer respond to any mouse events even though I can execute them via the keyboard using the tab and enter keys. They work just fine under 1.3 or if I make them modal.
    Any thoughts?

    Hello,
    Issue is-
    There are JButton's on the JDialog's which no longer respond to any mouse events even though I can execute them via the keyboard using the tab and enter keys. They work just fine if I make them modal.
    Plz suggest

  • Non modal JDialog

    Hi All,
    I want a non modal JDialog which is used to show the message to the user that it is searching for the records, when a search is performed and records are retrieved from the database. When the search is going on user might hit cancel on the JDialog to cancel the search. My problem is, the cancel button on the Search dialog is not catching the event and user is not able to select the cancel option on the dialog.
    Here is my code :
    class SearchWindow extends JDialog {
    private JPanel btnPanel;
    private JLabel lblSearch;
    private JButton btnCancel;
    * Constructor
    public SearchWindow() {
    super((Frame)null, false);
    setTitle("Searching Shipment Legs");
    cancelled = false;
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent evt) {
    close();
    Container contentPane = getContentPane();
    contentPane.setLayout(null);
    addButtons();
    pack();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setSize(new Dimension(300, 100));
    setSize(300,100);
    setLocation((screenSize.width-700)/2,(screenSize.height-450)/2);
    private void addButtons() {
    btnPanel = new JPanel();
    btnPanel.setLayout(new BorderLayout());
    lblSearch = new JLabel("Searching..........");
    btnCancel = new JButton("Cancel");
    btnPanel.setBackground(Color.lightGray);
    lblSearch.setBackground(Color.lightGray);
    btnCancel.setBackground(Color.lightGray);
    btnPanel.add(lblSearch, BorderLayout.CENTER);
    btnPanel.add(btnCancel, BorderLayout.SOUTH);
    btnCancel.addMouseListener(new MouseAdapter() {
    public void mousePressed(MouseEvent evt) {
    System.out.println("cancel");
    cancelled = true;
    close();
    btnPanel.setBounds(0,0,200,50);
    this.getContentPane().add(btnPanel);
    lblSearch.setVisible(true);
    btnCancel.setVisible(true);
    this.getContentPane().validate();
    public void close() {
    this.setVisible(false);
    this.dispose();
    public void show() {
    super.show();
    paintComponents(getGraphics());
    this.setModal(false);
    Any help is greatly appreciated.
    Thanks,
    Bhaskar

    Hi Haroldsmith
    I am calling this search window in one of my programs where on button click it will fetch the records from the database. When this process is on, search dialog is shown up. Ths dialog is shown correctly and its getting closed as soon as the search is completed. But the probelm is its not allowing me to click on cancel button.
    Bhaskar

  • Stopping execution

    Is there a way to stop execution of a query after Nth
    record?

    This page,
    http://www.devx.com/gethelpon/10MinuteSolution/16608/0/page/3,
    has some examples of using rownum. I must be missing something
    because it appears to do what you want.
    Of course, if you want to include ties for nth place, the
    rank() is probably more appropriate. Examples are here:
    http://www.devx.com/gethelpon/10MinuteSolution/16608/0/page/5

  • Execute code after show() in a Modal JDialog

    Is there any way of executing a piece of code after a Modal JDialog's show() method ? I tried to run the code using SwingUtilities.invokeLater to no use. Any ideas ?
    Thanks !

    Thanks Jamie !
    Adding a new thread wasn't required. I found the solution in some forum. The main issue was to get focus to a textfield in JDialog along with displaying a JPopupMenu against it. I could get the focus in but the popup wasn't showing. In brief this is what solved it.
    Assuming JTextField is testField. I add this listener to the textField just before calling JDialog.show().
    <code>
         private FocusListener fListen = new FocusListener()
              public void focusGained(FocusEvent e)
                   // showPop() logic
              public void focusLost(FocusEvent e)
                   testField.removeFocusListener(fListen);
                   testField.requestFocus();
    </code>

  • Modal JDialog Issue

    Hello everyone!
    I have a problem regarding customized modal JDialog in an application I am working on. The problem goes like this, first I open the JDialog from my application which is supposedly the parent of this JDialog, when I switch to any application from the OS (making my application hidden or brought to the background) and then going back to my application the JDialog is no longer shown making my application lock up and not accept any input at all --- making it impossible to close unless killed explicitly from the task manager.
    What have I done wrong? And what should I do to get around it?

    @param owner the non-null <code>Dialog</code> from which the dialog is displayed
         * @param title  the <code>String</code> to display in the dialog's
         *               title bar
         * @param modal  true for a modal dialog, false for one that allows
         *               other windows to be active at the same time
    JDialog(Dialog owner, String title, boolean modal)pass true if you want to make dialog as model

Maybe you are looking for

  • Release status of a function module

    Hello, how can I find out (where) the release status of a function module (if a function module has a status "released for customer")? regards zeno

  • UD complete without valuation

    Hi All, I am having a unique problem with one of the Inspection lot created with 04 type using MFBF UD status shows UD   ICCO SPCO , but the Inspection lot valuation in the usage decision tab is blank Stock posting is not completed When i try to use

  • Audio fade in

    when I add audio it keeps putting about 30 secs. of silence at the beginning of the song. I have loaded different songs and opened new movies. How to I remove the fade in

  • Dba_segments view is gone

    I'm not sure how or when this occured. This is our test server and it is a "Bi-continuous Volumne" (bcv) of the production server. (EMC Clustered environment) The bcv is a disk-level copy of the production server. Basically it copies all clustered fi

  • Classic for a Macbook

    I recently bought a macbook and have a couple games I would like to run on it, but it seems every time I download one it says it's not supported on this system, or a program has not been assigned to open this file type. Do I need classic mode? If so,