Displaying one JDialog window at a time

Hi,
I'm having some trouble trying to write a code where only one JDialog window appears at one time.
-so when one jdialog box appears, no other jdialog can appear
-I was thinking about using a boolean but it didn't work at all
Here's my code:
iimport javax.swing.*;
import java.awt.event.*;
public class Data extends JFrame
     JMenuItem existingRental;
     JMenuItem newRental;
     boolean one = true;
     public Data(){
          createMainMenu();
          setSize(350, 100);
          setVisible(true);
          setLocationRelativeTo(null);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     public static void main(String[] args){
          new Data();
     private void createMainMenu(){
          JMenuBar mainMenuBar = new JMenuBar();  //notice - used JMenuBar
          setJMenuBar(mainMenuBar);
          JMenu windowMenu = new JMenu("Window");
          windowMenu.setMnemonic('w');
          mainMenuBar.add(windowMenu);
          newRental = new JMenuItem("New Rental");
          newRental.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
          newRental.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e){
                    new Rental();
                    one = true;
                    if(!one)
                         new ExistingRentals();
          existingRental = new JMenuItem("Existing Rentals");
          existingRental.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
          existingRental.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e){
                    new ExistingRentals();
                    one = true;
                    if(!one)
                         new Rental();
          windowMenu.add(newRental);
          windowMenu.add(existingRental);
}JDialog two
import javax.swing.*;]
import java.awt.*;
public class ExistingRentals extends JDialog
     private JList list;
     private JScrollBar scrollHorizontal;
     public ExistingRentals()
          existingRentalAgreement();
          setTitle("Rental List");
          setSize(200, 500);
          setVisible(true);
          setLocationRelativeTo(null);
     public void existingRentalAgreement()
          Container container = getContentPane();
          container.setLayout(new BorderLayout());
          list = new JList();
          scrollHorizontal = new JScrollBar(JScrollBar.HORIZONTAL);
          add(scrollHorizontal, BorderLayout.SOUTH);
          scrollHorizontal.add(list);
}

What if you made your jdialog modal. this can be done by passing a boolean parameter set to "true" to the JDialog super constructor. Here is what I mean with some other minor changes:
ExistingRentals class ----------------------------------------
import javax.swing.*;
import java.awt.*;
public class ExistingRentals extends JDialog
    private JList list;
    private JScrollBar scrollHorizontal;
    public ExistingRentals(JFrame parent, String title)
        super(parent, true); // true here makes dialog modal.[captain.obvious]false does the opposite[/captain.obvious]
        existingRentalAgreement();
        setTitle(title);
        setSize(200, 500);
        setVisible(true);
        setLocationRelativeTo(null);
    public void existingRentalAgreement()
        Container container = getContentPane();
        container.setLayout(new BorderLayout());
        list = new JList();
        scrollHorizontal = new JScrollBar(JScrollBar.HORIZONTAL);
        add(scrollHorizontal, BorderLayout.SOUTH);
        scrollHorizontal.add(list);
import javax.swing.*;
import java.awt.event.*;
public class Data extends JFrame
    JMenuItem existingRental;
    JMenuItem newRental;
    boolean one = true;
    public Data() {
        createMainMenu();
        setSize(350, 100);
        setVisible(true);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public static void main(String[] args)
        new Data();
    private void createMainMenu()
        JMenuBar mainMenuBar = new JMenuBar(); // notice - used JMenuBar
        setJMenuBar(mainMenuBar);
        JMenu windowMenu = new JMenu("Window");
        windowMenu.setMnemonic('w');
        mainMenuBar.add(windowMenu);
        newRental = new JMenuItem("New Rental");
        newRental.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
                ActionEvent.CTRL_MASK));
        newRental.addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
                newRentalAction(e);
        existingRental = new JMenuItem("Existing Rentals");
        existingRental.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
                ActionEvent.CTRL_MASK));
        existingRental.addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
                existingRentalAction(e);
        windowMenu.add(newRental);
        windowMenu.add(existingRental);
    private void existingRentalAction(ActionEvent e)
        new ExistingRentals(this, "Existing Rental List");
        // one = true;
        // if (!one) new Rental();
    private void newRentalAction(ActionEvent e)
        // one = true;
        // if (!one)
        new ExistingRentals(this, "New Rental List");
        // new Rental();
}

Similar Messages

  • Suddenly I can open only one Firefox window at a time. I can have multiple tabs in that window, but I can suddenly no longer open another window. What happened?

    Suddenly I can open only one Firefox window at a time. I can have multiple tabs in that window, but I can suddenly no longer open another window. What happened?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Is it possible to open more than one safari window at a time

    Hi
    Help appreciated?
    Thanks
    Paul

    Greetings,
    Yes, you can open more than one window at a time, but that would just clutter your screen and make it more difficult for you. Use File > New Window, or Command-N. It's better to use tabs in one window; that way everything is in front of you and you don't have other windows hidden behind each other. You can find that in Preferences > Tabs.

  • SINCE YOUR LATEST UPDATE, I AM NOW ONLY ABLE TO OPEN ONE FIREFOX WINDOW AT A TIME, I ALSO LOST MY YAHOO SEARCH BAR TOOL.

    I have had Firefox for a few years and have been very satisfied with all of it's features and qualities. I work a great deal from home and have always enjoyed the convenience of being able to work off of 3 or 4 Firefox screens at one time. By pulling up one screen over the other and then go back and forth (as I still am able to do with Internet Explorer), saves a lot of time and NEEDLESS effort.
    Since your latest update the other day, I am now only able to get that 1 screen and no matter how many times I click on the Firefox Icon on my icon screen, no other Firefox screens will come up. I am stuck with that 1 screen...
    PLEASE HELP!!!! I have also lost my Yahoo search tool bar due to your upgrade, as well as several others which I cannot seem to retrieve.
    Thank you so Very much in advance for addressing and correcting this error.

    Since I upgraded to Firefox 19 from 18.0.2, on my Windows XP (SP3) laptop, I, too, can no longer open a new window. File-->New Window does nothing; also can no longer tear off a tab and open it in a new window (it stays where it is). Also, if I right-click on a tab and select Move to New Window, nothing happens. All of these worked fine in FF 18.0.2. All of these work fine with FF 19 on Windows 7. Only an issue on my XP laptop.
    After trying to open a new window, and not seeing the new window come up (and yes, I waited a long time), I decided to close my current window, which had multiple tabs open. Instead of just closing, it pops up the message reminding me that I'm about to close all those tabs. If I say close, and then go into the Task Manager, the Firefox application has disappeared (as expected), but the firefox (and plug-in container) processes are still running. So I have to manually kill the Firefox process to get it to quit. it's as if it thinks there is another Window open (the one I tried to open but never appeared). This happens every single time! I've restarted my laptop, and that does not resolve the problem.
    Is there a way to downgrade back to v 18.0.2 until this is fixed?

  • Can only see one document window at a time

    I am using Illustrator CS3. My document window is always full screen and lies behind the app bar so therefore I am unable to change it's size, see other windows, move it to my other screen etc etc, very annoying! I don't seem to have any cascade or tile options under the window menu either, is this something wrong with my application? Seems so to me. Any ideas much appreciated.

    You are welcome, CC.
    There are different ways of doing almost anything in Illy, even getting rid of preferences.
    However it may make a significant difference which way is chosen.
    The simple deletion through Ctrl/Cmd+Alt/Option+Shift at startup may solve some issues, as may the corresponding simple deletion of the aiprefs file in different other ways, but it is irreversible. This means that if deleting it does not solve your issue, you have lost your preference settings in vain, and you have to recreate them, just as you have to recreate lost artwork.
    The moving of the folder solves a wider range of issues, and it is reversible; similarly, files/subfolders therein may be moved. This means that you may just restore your preference settings if the issue is not solved, with nothing lost in vain.
    I made the Move the folder hint as an easy reference in the days of the fair forums, because the FAQ only mentioned the simple deletion, and because users had to spend a considerable amount of time recreating aiprefs file preference settings, sometimes lost in vain.
    Since then, in newer versions, some of the preferences were moved to other files.
    This means that the newer the version, the less is lost by the simple aiprefs deletion. On the other hand fewer issues are solved.
    Moving the folder, or files therein, was and is still superior to deletion in terms of avoiding loss and solving issues.
    Usually, I mention both ways, unless deletion has already been tried in vain.

  • How can I use two screens to display one window

    Before Mavericks, MAC OS allowed you to use two screens (next to each other) in order to display one (big) window of one application.
    That would mean that a window would start on your left screen en would continue on the right screen.
    With Mavericks, however, this not possible any more. The window of the application can only be seen on ONE of the screens (i.e. the left one).
    Can any one tell me whether I've missed certain options or how to adjust my settings in order to get this feature back?

    Hey CGNL,
    First, if you haven't already, set up the displays as an extended desktop:
    Choose Apple menu > System Preferences, click Displays, then click Arrangement.
    Follow the onscreen instructions.
    Then, use Mission Control preferences to uncheck/turn off the option for "Displays have separate Spaces":
    Choose Apple menu > System Preferences, click Mission Control
    Uncheck "Displays have separate Spaces"
    That should enable you to stretch whatever window you want across multiple displays.
    via: OS X Mavericks: Connect multiple displays to your Mac
    http://support.apple.com/kb/PH13814
    and
    OS X Mavericks: Mission Control preferences
    http://support.apple.com/kb/PH13925
    Welcome to Apple Support Communities!
    Have a good one,
    Delgadoh

  • Displaying one page at a time in a form

    I have a bunch of different single-page forms for people to fill out but they only will be filling out one of them at a time. I want to create one pdf document that contains all the different forms available (about 50 different pages) but only displays one of them at a time. I was wondering if there was a way to have someone chose what form they wanted to fill out when they opened the pdf and then only allow them to view that one page. Any thoughts on how to do this would be a great help!

    Thanks for the help so far. I think the solution that I am going to try to go with is creating a file that has all the forms in it and setting it so that all the visibility is off for all layers and fields when it opens. A pop up comes up and prompts the user to chose several options which are necessary to determine the form they should fill out. Then I will extract that page from the main document into a new pdf and turn on the visibility of that page. I've read conflicting things online about extracting a page to create a new pdf. If I don't specify a path to save the new pdf to will it just allow the user to save it on their own or will this solution not work?

  • Force oraclexe to only display one page at all times

    <pre>Hallo everyone. In oracleXE,when logged in , if you have the same page open in two or more browser windows . the pages change session state.
    This is normal behaviour but for my requirements this could be dangerous (a user thinking he has submitted some information when actually he has submitted the information set in session state by the other page).
    How can you restrict/force OracleXE to show only one page at all times?.
    Or, how can you restrict Oraclxe so that certain pages can be shown in only one browser window at a time</pre>

    Hallo Dietmar,
    The page that i use,uses a view with instead of triggers to update the underlying tables.
    I do use dml for updating the view, but I use an application item to store the
    number of the current form accessed. ( a form that is used in the process that i
    have to automate) .
    If two browser windows are open and the application item is changed, it will be set
    to the value in the window that updated the item last.
    When i open the first browser window and save the form, the value of the
    application item used will be the value set by the window that updated the form
    last.
    How can I make it possible for a user to open two browser windows in one
    session, without this problem, or if that isn't possible, how can i restrict the user
    from opening more than one application page in the same session?
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Is it possible to prevent the See Also function from displaying the topic window when only one "see also" topic exists?

    When you have several topics assigned to a see also button,
    the see also button displays several topics within the pop-up
    window in the compiled help. However, if you have only one see also
    topic assigned to the button, the button automatically displays the
    topic window for that topic. The first time I saw this, I thought
    it was a bug. When I've asked other people to test my help
    projects, they also think this is a bug.
    Is it possible to "make" the see also function display the
    pop-up window, regardless of how many topics are assigned to the
    button?
    thanks in advance,
    ChristyG

    Are you sure that you can change the permissions of symlinks themselves? I think I've tried to make files read-only via symlinks on a local server but ended up using bindfs because it wasn't possible. Even if you can, symlinking everything that might be necessary for a given environment would not be ideal, plus I don't think symlinks can be used across different filesystems.
    If a real-life human can figure out if it's he/she is in a chroot and break out of it, then he/she can write a script to do the same. I want a sandbox that could run malicious code with no effect on the system (if that's possible). Also, I think if the chroot idea were truly feasible, makepkg would have been using it for years already to simply install packages in the chroot as you normally would and then package them. There would also be several sandbox applications that could run applications safely. So far I have yet to find any.
    I admit that I haven't looked into using a chroot in detail though and of course I may have missed some application which creates such a setup. Right now I think using per-application namespaces with fuse seems the most promising but I won't know until I've finished implementing a test application. If it turns out that it's a dead end I'll take harder look at chroot but it really doesn't seem to be able to do what I want.

  • Displaying one record at a time

    Is any body able to help me? I need to display one record at a time from a Select statement.
    Could I copy the results of the Select query from a table into an array for later display or is there a better alternative.
    Please, any part knowledge with regard to the above would be usefull.
    Regards
    Eddie

    What application do you want to use to display the data?
    You can use "rownum" in your SQL statement to ensure that you only get record N of a query. Asktom has a good article on this sort of windowing
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:127412348064
    More commonly, however, you'll write a SQL query that returns all the rows, fetch a small number, display those to the user, and then fetch more records.
    Justin

  • View more than one audio instrument midi window at same time Logic 7

    Hello,
    Is it possible to open up more than one audio inst midi window at the same time?
    It would save me so much time if I could view what is going on ie on the guitar & piano tracks on 2 separate tracks at the same time.
    I know it is possible to double click on the grid of an audio inst midi window to view all midi in one song at the same time but because I have a lot of audio insts in my songs it gets really confusing. It would be ideal if I could pick and choose specifically which audio inst tracks are displayed within the same window when doing the double click thing or be able to view 2 tracks at once.
    Thanks in advance.

    Are you refering on how to be able to view the Matrix Editor/Piano roll of 2 Audio instrument tracks in one window?
    A

  • Hi gurus in scripts i want to display more then one main window on the page

    hi gurus in scripts i want to display more then one main window on the page how it is to follow any body explain to me plz.

    Hi all,
        I am printing check printing from F110 with Z-form and it has been assigne to FBZP also..
        My client need to print the check information twise that means main window data two times.
        like this: 
           First main window.  :      invice#       amt            amt
                                               9002          4000          4000
                                               9005          5000          4000
    Al so they want like to print same in down part of the main window.
           First main window.  :      invice#       amt            amt
                                               9002          4000          4000
                                               9005          5000          4000
    For this i  have created instance main window of main window like MAIN    01,  but it is not displaying the data in instnce window data
    in the instance main window. 
    Question: Could you please let me know abt the same or good solution. How to cal main window instance , i tried with  
    /:   NEW-WINDOW      in instance main window part but it also appering in main windoe also.
    could you please let me know how to call instance main window or any other solution to get teh data like my example above.
    thx

  • Firefox won't let me open more than one window at a time. how do i fix the problem

    Firefox won't let me open more than one window at a time. It use to allow me to open multiple windows before but for no apparent reason it stopped. I uninstalled it and re-installed but I'm having the same problem. How do I fix the problem
    == This happened ==
    Every time Firefox opened
    == several days ago

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    You have to close and restart Firefox after each change via "File > Exit" (on Mac: "Firefox > Quit")

  • I lost my only navigation tool bar, so I can only open one window at a time, and can't use google. Help.

    I'm not sure what I did, but I right clicked on my google tool bar (which I use since I can't find the Firefox navigation toolbar) and I somehow disabled it. Now I can only use one window at a time, and if I go to a website, I can't go to another without closing my current one so I can go to my homepage, which is google.

    If the Menu Bar is hidden then press F10 or press and hold the Alt key down to bring up the "Menu Bar" temporarily.
    Go to "View > Toolbars" or right-click the "Menu Bar" or press Alt+V T to select which toolbars to show or hide (click on an entry to toggle the state).
    See also [[Menu bar is missing]] and http://kb.mozillazine.org/Toolbar_customization

  • Can the iphone maps display more than one pin at the same time?

    For example, on a recent trip to New York I preloaded bookmarks of all the places I wanted to visit into the iPhone Maps. I then wanted to see where they all were in relation to one another so I could decide which one to go to next (MOMA, Guggenheim, Metroplitan Museum of Art for example). Is it possible to have the map display them all at the same time?

    DaVBMan wrote:
    Are you sure about that Andrew. I see no option to toggle on all my bookmarked pins. I can pick one to show and it shows up. But if I pick another, the previous one will go away. Only doing a search for stuff in an area will Google Maps show multiple pins, but I see no way of making all your saved bookmarks show up.
    Did it on mine just now but I also did a very small location here in Sacramento. Dropped a pin in 1 city, Bookmarked, Dropped a few others and bookmarked at least 6 cities in the general Sacramento area, zoomed out just a bit and saw 6 red Pins. Which are all bookmarked.
    If I could snap a photo of my screen I would post it.

Maybe you are looking for

  • Error Message in a view

    Hi , I have a view, where I add entries using table maintenance generator. I have certain checks to be performed, those checks I have done in a subroutine which gets called in the event '01' before saving. Now if I get some error messages, the error

  • Ipod to Itunes reload after hard drive crash

    My hard drive crashed and now my ipod is correct and the backup I reloaded onto itunes does not match.  How do I get itunes to match my ipod?  I do not really want to recreate all the playlists as that would take a great deal of time.Thanks

  • Pi 7.1 ehp1 log-configuration.xml, howto create/edit in NWDS?

    Hello, In NWDS 2.0 You have a special mode in NWDS  to edit the file. You get tabs with Log Formatter, Log Destination, Log Controller and Source. How does it work in NWDS 7.1 EHP1? The log-configuration shipped with the example module is packed insi

  • Pro*C /AIX /11.1.0.X :demo programs return "duplicate symbol" warnings

    this problem has been raised in SR 7229372.994. Working in 11.1.0.6 or 11.1.0.7 on AIX , compilation of the proc*C "sample1" demo program returns various duplicate symbol warnings: ld: 0711-224 WARNING: Duplicate symbol: p_xargc ld: 0711-224 WARNING:

  • Hi, everyone, a question about sapscript?

    Hi, everyone, My sapscript have one page and next page is the same as the first page, the page have two window, a var window and a main window, in the main window there is a command at the top that is "/: BOX FRAME 10 TW". and when I preview the form