JFrame with JDialog question

Hi
I have a JFrame that have a JButton on it. This button have an actionlistener which the inner class of JFrame. When user click on the button, it should pop up a JDialog with modal turn on. How can I pass the Frame to the JDialog so that I can set the modal??
Thanks..

Keep a reference of the frame in ur class and create the dialog with this reference

Similar Messages

  • Problem with jDialog in a JFrame

    Hello to everyone...i'm newby java GUI developer, and i've got a problem with a JDialog within a JFrame...
    I made a JFrame which creates a new customized JDialog in his contructor, like this:
    MioJdialog dlg = new MioJdialog(this, true);
    dlg.setVisible(true);
    ...The "MioJdialog" class store his JFrame parent under a private attribute, in this way:
    class MioJdialog {...
    private Frame parent;
    public MioJdialog (Frame parent, boolean modal){
        this.parent=parent;
    ....}and here's the problem: when i try to close the parent JFrame with a command like this:
    parent.dispose();
    ( in order to close the whole window), sometimes happens that the JFrame is still visible on the screen...and i don't know why...
    got some hints?
    thanks to everyone!
    Edited by: akyra on Jan 14, 2008 4:36 AM
    Edited by: akyra on Jan 14, 2008 4:37 AM
    Edited by: akyra on Jan 14, 2008 4:37 AM

    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
    http://homepage1.nifty.com/algafield/sscce.html
    Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Advice needed about JFrame and JDialog (moved from java programming)

    My main class in my application is a page where the user can choose to register or login. This class is a JFrame. If the user chooses to register, my register dialog is called up and the parent JFrame passed to the dialog:
    private void btnRegister_actionPerformed()
                    new Register(this);
              }Same happens for login. If the user chooses to login, my login dialog comes up and my main class JFrame is set as its parent. This is all fine because all the calling up is done in my main class, so i can just use 'this' to pass the JFrame.
    Now here is my problem. If the user successfully logs in, they should have access to control some events. Now i am not sure if it will be ok to make this new events class another JFrame, as it is practically the start of a new section in my application.
    Thats my first question. My second question is if i do make this events class a JDialog, is it bad coding not to give it a parent frame? Or would this be acceptable? My worries is passing the main class JFrame to a class which is only accessable by going through two other classes.
    Cheers for the advice

    It's Simple dude,
    Advice: Use JIternalFrame, for your purpose.
    And if u want to go with JDialog than u can do that in main method. Like when u call JDialog
    Register dialog = new Register(this);Check for login in Register class or what ever u want. Create new method like success
    private boolean isSuccess() {
    return success;
    } at Register Class. After Registeration change the variable boolean success value to true or false as per logic
    And add
    Register dialog = new Register(this);
    if(dialog.isSuccess()) {
    // Show loginDialg(this) or else
    }Regards,

  • Problem with JDialogs

    Hi All,
    I have a problem with JDialogs in my standalone application. This app pops-up multiple JDialogs, say a stack of JDialogs.
    I have a standalone application which runs as a JFrame, call it JFrame1, which is working fine. JFrame1 pops-up a JDialog, on some button click on JFrame1, call it JDialog1, which is also working fine. Now JDialog1 pops-up another JDialog, again on some button click on JDialog1, call it JDialog2, which is too working fine. But, after I finish with JDialog2 and dispose it my JDialog1 is not working fine, though that is the front dialog at present.
    Any ideas why JDialog1 is not working fine? Am I missing anything?
    Thanks,
    Srinivas.

    Hi,
    I have a component called DateComponent that works similar to a JComboBox. When you click a small button of DateComponent, it pops-up a Calendar similar to the drop down list of JComboBox and user can pick a date from it. It gets closed when it loses focus.
    I have this DateComponent on JFrame1, JDialog1 and JDialog2. The Calendar is not being diaplayed on JDialog1 upon clicking the small button of DateComponent after JDialog2 is disposed. But it is being diaplayed properly on JDialog1 before JDialog1 opens JDialog2. What could be wrong?
    I am using JDK1.3.1.
    Thanks,
    Srinivas.

  • Global KeyListener in JFrame with JDK 1.4

    Hi!
    I need to get some keyboard events in my JFrame or JDialog, no matter what subcomponent currently has the focus. I use this for example to display a help screen when the user hits F1.
    In JDK 1.3 I wrote in my constructor:
    this.addKeyListener(new java.awt.event.KeyAdapter() {
    public void keyPressed(KeyEvent e) {
    this_keyPressed(e);
    and then had a method
    void this_keyPressed(KeyEvent e) { ... }
    handling those events.
    In JDK 1.4 this code only works, if I call this.requestFocus(), but since the user should be able to TAB through the frame and hit F1 in every textfield, button etc., this is no solution --- as soon as "this" loses the focus, it won't work any more.
    I also tried using Key Bindings, but somehow I couldn't get it working.
    I need a solution for this problem that works with 1.3 as well as with 1.4!! Do you have any ideas of how to do this?
    Thanks for your help!!
    Nicolas Michael <[email protected]>

    looking at the source for Choice its not doing a great deal in add():
    pItems is a vector, so I guess if there is anything that could be slow its the native call, but again this seems unlikely?
    btw, if ur adding to the Choice box when its visible it will be a lot slower - is it possible to initialise before the applet is displayed?
    asjf
    ps. note the demo code above is adding numbers as strings, but I agree this shouldn't make any difference
    //from java/awt/Choice.java (same from 1.2.1 to 1.4.1 - have not checked 1.1)
    public void add(String item) {
       addItem(item);
    public void addItem(String item) {
       synchronized (this) {
          addItemNoInvalidate(item);
       if (valid)
       invalidate();
    private void addItemNoInvalidate(String item) {
       if (item == null) {
          throw new
          NullPointerException("cannot add null item to Choice");
       pItems.addElement(item);
       ChoicePeer peer = (ChoicePeer)this.peer;
       if (peer != null) {
          peer.addItem(item, pItems.size() - 1);
       if (selectedIndex < 0) {
          select(0);
    }

  • JFrames with only the close button

    I have been writing a notepad as my first java project and have done most things but cant seem to fix this: coding a JFrame with only the close button. Most of us know that when you click Help > About... a window pops up describing the company that wrote the software.
    Please help....

    I have been writing a notepad as my first java
    project and have done most things but cant seem to
    fix this: coding a JFrame with only the close button.
    Most of us know that when you click Help > About... a
    window pops up describing the company that wrote the
    software.
    Please help....so whats the problem? you're asking if a person clicks on help->about then a description dialog box should pop up describing the company right? you can use JDialog or a popupmenu. look at the swing tutorial at sun

  • What is the difference between JFrame and JDialog?

    Is there any difference between JFrame and JDialog except that the JDialog can be modal?
    Is there any reason to use JFrame at all if i can achive the exactly the same with a JDialog?

    API wise they are basically the same, but they are usually built on top of different heavyweight components. Some platforms treat frames quite a bit differently than they do dialogs.

  • I got a flashing folder with a question mark. I got a new hard drive and upgraded to 4 gigs and can't open anything or reload the operating system? Help?

    I got a flashing folder with a question mark. I got a new hard drive and upgraded to 4 gigs and can't open anything or reload the operating system? Help? FYI: I have been using boot camp with windows 7 and started getting a kernal_data_Page_error and it would reboot windows, i was trying to do a chkdsk on the next reboot, but thats when i started getting this issue. I have put in a new hard drive and went from 2 gigs to 4. I can not get the computer to do anything, even the monitor does not show anything now????

    Prep your new drive:
    Drive Preparation
    1. Boot from your OS X Installer Disc. After the installer loads select your language and click on the Continue button.  When the menu bar appears select Disk Utility from the Utilities menu.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  SMART info will not be reported  on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Click on the Options button, set the partition scheme to GUID (for Intel Macs) or APM (for PPC Macs,) then click on the OK button. Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Security button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    After formatting has completed quit DU and return to the installer. Install OS X.

  • White Macbook has folder with a question mark inside when powered on.

    My brother has a white macbook given to him from a friend and when it is powered on it shows a folder icon with a question mark in the inside flashing and it doesn't boot. He has sent me on a quest to get a power adapter and a new hard drive, He thinks the hard drive is fried. Does anyone know for sure if thats the case, I just don't want to buy all that stuff to figure out that the logic board is dead or something else irreplaceable. There is no backup disks, all I have is a replacement leopard disk from apple used for my mac mini.

    If it is a retail Leopard disc--black with a giant purple X on it--then yes, you could use them, with a couple of caveats. One, it would technically be a violation of the license to use that install of Leopard on more than one computer, and terms of use on this forum forbid me from encouraging such an action. And two, depending on how old this used MacBook is, your install of Leopard may pre-date manufacture of the MacBook and, as a result, not be able to boot the MacBook anyway. However, judging by the info in your signature, that is probably not a problem.
    If the disc for your Mini is gray and shipped with or was meant to ship with the Mini, then no, the disc will not work.
    I still encourage you to get the system discs that came with the MacBook originally, as they have the Apple Hardware Test included, and, as I suggested above, running any OS (or other Apple software) on a Mac without the discs means technically it's an unlicensed copy.

  • When I boot up my I get a grey screen with a flashing folder with a question mark

    I was trying to set up a bootable Linux flash drive for another computer using UNetbootin and I accidentally selected an empty partition on my hard drive instead of the USB I was trying to use. It went through the install process, and I didn't realize it was on my computer rather than the USB. The computer worked fine, so I thought nothing of it.
    Today, I go to mess with my computer and it is frozen at the login screen. I restart it, and now I just get a blinking folder with a question mark. I try to go into recovery, but it isn't there. Internet Recovery works fine, but when I go to use Disk Utility or to reinstall the OS it cannot find the internal Hard Disk.
    What am I supposed to do here? I don't want to lose all my data.

    greenbil1
    You can contact AppleCare to buy a replacement set of the oringinal Install discs for a nominal cost. You will need the serial number and a credit card to place the order.

  • So i have a 2011 MacBook Pro and when i turned it on this morning a flashing folder came on with a question mark in the middle of it and it keeps flashing. So i tried googling any solutions and up so far nothing has worked. Please Help ?

    I tried googling several solutions, but so far nothing seems to work. Everytime i start up my laptop i press CMND+R to make it go to the repair disk utility but instead it takes me as if i have to install lion when i had Snow Leopard 10.6.8. When i do go to the repair disk utility, on the eft hand side shows two hardrives one is Untitled and another is Hitachi, i tried downloading snow leopard 10.6.8 onto a Re-writable disc  using my windows computer. When i insterted it onto the disc drive it came out under SUPER DRIVE and everytime i double click on the CD it says something about attaching images/ I also forgot to mention that the MAC OSX 10.6.8 Update shows on the left hand side on the bottom in DMG format. I dont know what else to do, please help?

    DestroyGalaxies wrote:
    a flashing folder came on with a question mark in the middle of it
    This is the firmware telling you it can't find a bootable OS X volume.
    Usually to solve this all you do is hold the option key down on the built in keyboard while booting the computer, this enters Startup Manager and then you choose OS X to boot, then in System Preferences > Startup Disk you change it to the boot volume and it tells the firmware.
    Everytime i start up my laptop i press CMND+R to make it go to the repair disk utility but instead it takes me as if i have to install lion when i had Snow Leopard 10.6.8.
    What you have is a 10.7 or 10.8 Recovery HD from when 10.7 or 10. was on the machine previously.
    The Macintosh HD partition only was erased and 10.6 installed on it, without erasing the entire drive like what should have occured to remove the Recovery HD partition.
    So you have a mucked up machine.
    i tried downloading snow leopard 10.6.8 onto a Re-writable disc  using my windows computer.
    Well there goes your problem there, your downloading illegal copies of Snow Leopard from a untrusted location.
    10.6 is not available for download, except from pirate sites. You likely have malware or a compromised system.
    I dont know what else to do, please help?
    What you need to do is call Apple via phone, tell them the make of your machine and order the appropriate 10.6 disks, they are inexpensive now. Some machines that came with 10.6.3+ origianlly need machine specific disks, other wise pre-10.6.3 Intel Macs can use the 10.6.3 white retail disks.
    Once you have the disks, you need to backup your personal information off the computer to a external storage drive using the emergency quick copy method, then disconnect it to prevent mistakes.
    Most commonly used backup methods
    Next follow this proceedure and make sure to select the ENTIRE drive on the far left with the drive makers name and size, this will erase the entire drive, then install 10.6 from the disk
    How to erase and install Snow Leopard 10.6
    When finished setup the machine and log onto the Internet and use Software Update to get current on 10.6.8
    Don't use pirated software, it's likely been compromised in some fashion.

  • Since upgrading to Mavericks, 10.9.1, pictures that come attached to emails no longer display.  There is only a blank space that after about 1 minute, has a small box with a question mark.  How can I go back to attached images?

    Since upgrading to Mavericks, 10.9.1, pictures that come attached to emails no longer display.  There is only a blank space that after about 1 minute, has a small box with a question mark.  Double clicking on the box will open the image in a separate window.  It's very slow and tedious for multiple images.  How can I go back to attached and displayed  images?  If I click on "Forward", the images appear instantly in the email to be forwarded.

    Scott,
    My problem seemed to fix itself.  Or, by shutting down the computer one night, instead of putting it to sleep, may have reset something.  Since updating to Mavericks, I always (or usually) let the computer sleep overnight or anytime I'm walking away from it.  A few days ago, I was updating notes for my kids about how to find all my stuff and how to turn on my computer, so I wanted to rewrite the start-up procedures for the iMac, just in case they ever need to.  Well, I shut it down one night so the following morning, I could write down each step.  Lo and behold, the images, etc. are all there again!  Solved, but I'm not sure why.
    Tom

  • I keep getting the little blue box with the question mark

    Hi
    I have 10.6.7 system software and my safari is 5.0.4
    I have called apple twice with this problem already but nothing has helped except for short times.
    I have reset safari about one dozen times and when I do I reset the top 7 items and I've emptied the cache in addition just in case. I've also taken my safari preference plist out of my library and trashed it.
    And I've run disk utilities many times and restarted my computer. Each thing I do will solve the problem for a short time, even up to a day or more (or less) but then it comes back. For instance on Facebook maybe 1/8th of the thumbnail images have the little blue boxes with the question marks but most don't. I can't figure it out. Sometimes even the iPAD safari gets them too but my firefox doesn't show them and neither does Safari on my eMac.
    Yesterday the question marks even showed up in ONE mailing on all 3 computers with the question marks in the blue boxes (meaning my iMac, my eMac and my iPad) but then it just all resolved after a few hours. This does sound like possibly a server problem except today it's happening (in Safari again) only on this iMac in Safari (not firefox) and not on the other two devices.
    One more thing, since they changed my radio on the roof for my wireless internet, the 5.8 phone cuts out the internet when I use it. The problem has gotten worse since they changed the radio to the same frequency as the phone, it's a much faster service than the 2.4 radio. I don't know if this is related or not.
    Thank you,
    Martha

    <Contact your ISP.
    Is it possible, Carolyn, that this would mainly and almost always be only affecting the iMac and Safari in the iMac if it were a server issue? Right now Safari has more blue boxes with question marks than ever and the eMac and iPad have none. Firefox on the iMac has none also.
    I should try a direct connection and by pass the router and see if that makes a difference.
    I will contact them tomorrow but I want to get clear in my head first all the facts and possibilities.
    Thanks!
    Martha

  • HT204088 Dear sirs,  Could you please help me on my problem with my apple ID  I create new account with security questions, and when I try to purchase paid application,it ask me for answers the questions but it's not working,  My account have 50$ and stil

    Dear sirs,
    Could you please help me on my problem with my apple ID
    I create new account with security questions, and when I try to purchase paid application,it ask me for answers the questions but it's not working,
    My account have 50$ and still didn't buy anything

    You need to ask Apple to reset your security questions; ways of contacting them include clicking here and picking a method for your country, phoning AppleCare and asking for the Account Security team, and filling out and submitting this form.
    (100546)

  • How to fix a problem with my book pro that has a gray screen with a folder with a question mark on it

    does any one know how to fix a problem with my book pro that has a gray screen with a folder with a question mark on it?

    Hello Mokhtary123 and welcome to Apple Support Communities,
    It will help us diagnose your problem to know the exact model, size, year built, RAM installed and OS you're running.
    But basically your system can't find the boot disk. Usually this is a symptom of a dead/dying/corrupted hard drive;
    A flashing question mark or globe appears when you start your Mac - Apple Support
    OS X Recovery
    http://support.apple.com/en-us/HT4718

Maybe you are looking for