Own JDialog - works with java5, doesn't work with java6

Hello,
I'm working on map editor for a bigger project and I'm stuck with displaying my own JDialog (grrr...). I found out that problem occurs only with java6. See the screenshots below:
java5
http://student.agh.edu.pl/~kdzwinel/Projects/TrafficSim/MapEditor/good.jpg
java6
http://student.agh.edu.pl/~kdzwinel/Projects/TrafficSim/MapEditor/wrong.jpg
And some implementation details:
how do I create new dialog:
NewMapDialog dialog = new NewMapDialog(this);
dialog.setVisible(true);how dialog class looks like:
public class NewMapDialog extends JDialog implements ActionListener, ChangeListener
     NewMapDialog(Main owner)
          super(owner,"New map",true);
          this.setAlwaysOnTop(true);
          this.setSize(200, 280);
          this.setResizable(false);
          this.setLocationRelativeTo(owner);
          makeLayout();
     private void makeLayout()     
          Container content = getContentPane();
          content.setLayout(new FlowLayout());
//(...) <- add stuff
}That is so simple that I'm really confused. I will appreciate some help.
Regards,
Konrad
Edited by: kdzwinel on Feb 5, 2008 6:23 PM

kdzwinel wrote:
Hm, creating my applications I extend JFrame, JPanel, JLabel all the time, what is wrong with extending JDialog?In this case your class contained two methods that were already defined to mean something completely different in the class you derived from. That's just one example of what can go wrong when you use inheritance. Had you used composition rather than inheritance (i.e. your class contained a JDialog rather than being a JDialog) this problem would never have happened.
Such an extension was quite natural for me to use because I was looking for this dialog to be modal. And I guess making JFrame modal is not so trivial.
You can make a modal JDialog without extending JDialog, so that's not a problem.
BTW, funny thing is that this 'mistaken' code worked just fine with java5 - I was confused by this fact so my first guess was that I messed something up with panes/layouts.Another reason you should be careful with inheritance: your program may break from implementation changes in the library code you are using and extending. Maybe Java 5 does not use those two methods when it "draws the dialog". Again, had you been using composition your program would not have been affected.
If you can, get your hands on a copy of "Effective Java" by Joshua Bloch, and read chapter 14 "Favor composition over inheritance". He explains this much better than I can.

Similar Messages

  • Can I add my own art work to my albums in iTunes and/or share them with the Apple Store for downloading?

    Can I add my own art work to my albums in iTunes and/or share them with the Apple Store for others to download?

    Thanks Brij011
    I thought that there was a way to do this. However, it would be neat to be able to upload correct Art Work for album covers so that other could share instead of having to scan / take picture and then import. I guess Apple would be inodated with incorrect pictures if we could upload to them.
    Oh well... thanks again !

  • I own and work on two Mac computers.. a MacBook Pro and an iMac. Am I required to "purchase" the one-time in-App purchase of $4.99 TWICE, one for each computer..??

    I own and work on two Mac computers.. a MacBook Pro (dual core, 3.06GHz, 8 GBs RAM) and an iMac ((dual core, 3.06GHz, 4 GBs RAM). Am I required to "purchase" the Garageband one-time in-App purchase of $4.99 TWICE, one for each computer..??

    The answer to your question is not about the GarageBand content but the concept of downloading any apps (or in-apps purchases) from the app store. The Key is your Apple ID.
    Whenever you download an app (it doesn't matter if you pay for the app or if it is free) you have to to be logged in to the App Store with a valid Apple ID. That becomes your "Online License". Whenever you are logged in to the App Store with that Apple ID you will see your Purchase History, what apps you downloaded and also what apps have updates available. As you see, this procedure is independent from your actual computer. The App Store is only interested in your Apple ID for verification.
    To download an app or content on a different computer, just make sure you are logged in to the App Store with the same Apple ID you did for the initial purchase.
    The button will now display (instead of Free or the price tag) "Install" because the App Store knows that you purchased the item before (with that Apple ID) and that you computer you are on at the moment oesn't have th app installed. Just click the "Install" button to download the app.
    Here is how the Button looks like depending on the condition.
    The same principle applies to in-app purchases. With GarageBand, when you try to restore Purchases, make sure you are logged in in the Apple Store with the Apple ID you made the original purchase.
    One more thing: You don't need to be logged in to actually run an app, only for online activities (downloads, updates)
    Hope that helps
    Edgar Rothermich
    http://DingDingMusic.com/Manuals/
    'I may receive some form of compensation, financial or otherwise, from my recommendation or link.'

  • JDialog works strange.

    Thank you for interesting this thread.
    I found JDialog works strange in the code below.
    child1 appears strangely.
    It might be a bug ??
    or any way to avoid this ?
    I'm using...
    Windows' 64bit.
    JDK 1.6.0_24 64bit.
    import java.awt.Dialog.ModalityType;
    import javax.swing.JDialog;
    import javax.swing.SwingUtilities;
    public class Test {
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        JDialog root = new JDialog();
                        root.setBounds(0, 0, 100, 100);
                        root.setVisible(true);
                        JDialog child1 = new JDialog(root);
                        child1.setSize(200, 200);
                        child1.setLocationRelativeTo(null);
                        child1.setVisible(true);                    
                        JDialog child2 = new JDialog(child1);
                        child2.setModalityType(ModalityType.DOCUMENT_MODAL);
                        child2.getContentPane().setBackground(Color.RED);
                        child2.setUndecorated(true);
                        child2.setSize(100, 100);
                        child2.setLocationRelativeTo(null);
                        child2.setVisible(true);
    }Edited by: user7028083 on 2011/06/15 4:29
    Edited by: Darryl Burke -- fixed the code tags

    Thank you for your explain !!
    I always want to be able to create better English sentence like you.
    well, I create a class, which is named MySwingWoker and is extend SwingWorker.
    And I want to show loading message while the background job is running with MySwingWorker class.
    Why loading message is setUndecorated(true) is I think it looks better.
    (Actually, it's not important for anything, but my sense of accomplishment.)
    While testing, I found that dialog is appearing strangely some cases.
    So I started to search what is wrong, as other programmer do.
    While searching, I created the example I wrote above,
    and found that if I remove "child2.setUndecorated(null)" or "child1.setLocationRelativeTo(null)", it works normally.
    I wondered this is a bug or spesification or something else.
    I don't know if asking here is right way, or not.
    But I thought someone, knows Java very well, would give me a advice.
    thanks.

  • How do i use my own domain name with creative cloud?

    how do i use my own domain name with creative cloud?
    i don't want to post web pages from behance.net. i want to use the domain name i have for my material. is there a hosting service for this? if not, can someone give me some pointers so I can publish?
    thanks!!
    Lori

    http://forums.adobe.com/community/behance is where you would ask about publishing to "something else" from that program
    I use OLD Dreamweaver, and upload my HTML with an FTP program to my own web site... I will GUESS you can do that, if you can save HTML to your hard drive to then be able to upload to your web site

  • IPad 1 Safari crashes frequently. I went to many Apple stores in different countries and each Apple staff member had their own different opinions with no help. I had upgraded my iOS to 5.1.1 and the Safari crashing started about one year

    IPad 1 Safari crashes frequently. I went to many Apple stores in different countries and each Apple staff member had their own different opinions with no help. I had upgraded my iOS to 5.1.1 and the Safari crashing started about one year after the upgrade and some Apple staff blame this- but this started one year later after the iOS upgrade. Recently at the Apple Store in Vancouver an Apple staff reset my computer (erased everything and sent to iCloud to reset the iPad) and I hoped this would fix the problem. IPad Safari still crashes. Short of booking an appointment for taking it for repair to Apple technicians which will cost me money can anyone help me to fix this Safari crashing.

    Hi,
    You might have a 3rd party plugin that isn't compatible with Safari 4.0.4. Go here for help...
    Safari add-ons can cause performance issues or other situations
    If you are using a USB hub, try disconnecting and restarting with just your keyboard and mouse connected.
    From the Safari Menu Bar, click Safari / Empty Cache. When you are done with that...
    from the Safari Menu Bar, click Safari / Reset Safari. Select the top 5 buttons and click Reset.
    Mac OS: Web Browser Quits Unexpectedly or Stops Responding
    Also, you could download and install the 10.5.8 combo update (PowerPC) available here.
    http://support.apple.com/downloads/MacOS_X_10_5_8_ComboUpdate
    It contains fixes that might help. Then repair disk permissions.
    Quit any open applications/programs. Launch Disk Utility. (Applications/Utilities) Select MacintoshHD in the panel on the left, select the FirstAid tab. Click: Repair Disk Permissions. When it's finished from the Menu Bar, Quit Disk Utility and restart your Mac. If you see a long list of "messages" in the permissions window, it's ok. That can be ignored. As long as you see, "Permissions Repair Complete" when it's finished... you're done. Quit Disk Utility and restart your Mac.
    Carolyn

  • Owning 2 iphones with one Apple account has = Sync Problems.

    Owning 2 iphones with one Apple account has = Sync Problems.  iTunes is thinking my old iphone 4 is the same phone as my iphone 5C.  When I plugged in my iphone 5C it auto synced my 5C to iTunes and it wiped my 5C and restored it to the same content as is on my iPhone 4.  This is a big problem since my 5 year old has been using the iPhone 4.  It's all Mickey Mouse and Backyardigans.  (Total photo/app/contacts loss)
    I was able to update the 5C and restore from a 3 month old backup that is actually the content from the 5C but now when I plug in my 5C it wants to "setup as new phone" or "restore from backup"  What's going on?  I'm afraid to choose either option.
    How can I get iTunes to see these devices as 2 and not one?
    Can I use my Apple ID on both phones still or is this the problem?

    They were both displaying the same name in iTunes.  I changed the name of the iPhone 4 before the 5C was plugged in but it still went ahead with syncing it to the 4's data.

  • How do i set up my pre owned iphone 4 with my giffgaff sim card that was used in my iphone 3gs

    how do i set up my pre owned iphone 4 with my giffgaff sim card that i have been using in my iphone 3gs
    My 3Gs is on its last legs.... I've just bought a second hand iphone 4 which is unlocked......I put my giffgaff sim card in the new phone and it says activation required ......then it asks me for a passcode???  PLEASE HELP!!!! I have no idea what to do xx

    You need to connect the phone to iTunes and then try activating it from there and restoring it as new.
    If you have further problems and especially as the iPhone you have bought is second hand, it could be that it is not unlocked.  Are you sure that it is?  If not, then you'll need to speak to the person that you purchased it from.

  • Opposite side is hearing his own voice along with mine in iphone 4.

    I have an iphone 4. Software version is 4.3.5. I am having a problem while calling. Call is okay; but opposite side is hearing his own voice along with my voice. Its like a repeat to him. He is also hearing me. From my side (iphone 4) its okay.
    Is this a network problem, Or for the top microphone? It does not happen all the time.

    It is normally a network problem.

  • I am unable to join my own wifi network with new iphone 5

    I am unable to join my own wifi network with new iphone 5.  It has the latest software downloaded too.  Keeps saying unable to join network after I type in the password.  All my other devices are able to join but just not the iphone.  I've called Verizon and my internet provider and they have been unable to help.  I had no problems with my iphone 4 with this very same issue.  Please help or I'll be forced to return this phone.  I have 13 days left.

    Try power-cycling your router (unplug for 15 seconds, then plug back in), then on your phone go to Settings>General>Reset and tap Reset Network Settings, and try joining your network again.  Note: resetting network settings will erase passwords for previously joined networks on your phone.

  • COPA user-defined charact. w. own value maint. with existing check-table

    Dear Experts,
    I need to create a user-defined characteristic with own value maintenance with the pecularity that it needs to refer to the same check table as another user-defined characteristic with own value maintenance.
    Could anybody explain me how I can do that?
    Thanks in advance for your kind support.
    Best Regards,
    Eric

    Hi Eric,
    Generally when you are creating user defined charachteristic with own value maintainance check table is created by the system. So you requirement is not possible to achieve. As a workaounr you can create two char as you want and then copy the content of the first check table to the second one. This will have the same impact as what you have described.
    Best Regards,
    Abhisek Patnaik

  • I am planning to buy an iMac and I already own an iPAD with keynote and pages in it.  Can I transfer them to my new iMac or do I have to buy them again?

    Hi, I am new to iMAC and I am planning to get one soon.  I own an iPAD with Keynote and Pagen in it among other  App and I was wondering if I can transfer those to my new iMac or do I have to buy them again for my new Mac
    Thanks

    christopher rigby1 wrote:
    It may be that if you already bought the iPad versions using your iTunes account, you get a discount on the Mac versions? (That's just a guess - it applies with FileMaker, but I don't know if it does with iWork).
    There is no discount for one version of the iWork apps due to owning the other version.
    Regards.

  • How link my own contact card with pages ?

    How link my own contact card with pages ? When i start with a new model i still have Urna Semper ...?
    I the old version of pages i can link them directly but now i really dont know what i have to do ...

    Susan:
    If you already have a hosting service you won't need a MobileMe account.
    There are two ways you can upload your web site to your server: 1 - click on the site icon in iWeb and enter the ftp address path for your server and account in the window.
    Click to view full size
    2 - publish to a folder on the Desktop (set the path in the same window above) and use a 3rd party ftp client like the free CyberDuck (highly regarded in this forum) to upload to your server.
    As far as the domain name, go to your domain name provider and setup domain name forwarding to the site on your host server. You'll need to know the URL to the index.html file that is created along with the site folder by iWeb.
    Here is some information regarding the domain name forwarding and masking (most applies to both Mac and non-Mac servers):
    http://iwebfaq.org/site/iWeb_Domains.html
    http://discussions.apple.com/thread.jspa?threadID=1164519&tstart=0
    OT

  • HT4436 can i use my own email address with iCloud?

    can i use my own email address with iCloud?

    Welcome to the Apple community.
    No, you cannot use your own email address with iCloud. However you can use your own email address as a separate account by entering the account details in the mail application.

  • Cannot access my own secure network with G4 iBook

    I set up a WPA secure network with a AirPort Extreme Base Station. No problem using it with my G4 iMac. However, when I try to access it with a second computer, a G4 iBook laptop, using the same WPA password I use to access it with my iMac, I get an error message.
    Using the Setup Assistant with the iBook gives me an "invalid password" message. I know it is the correct password. I set it up and I use it with the iMac!
    When the network is unsecured (no password needed) the iBook can access it, no problem.
    Please tell me what I need to do to be able to access my own secure network with my iBook. TIA!

    The only thing I can think of is the firmware for the AirPort card in the iBook, which is version 9.52. I could not find anywhere in Apple's website how to upgrade this. Does anybody know how to upgrade this firmware?
    If there is any firmware update to the card it is done automagically whenever the corresponding AirPort software update is applied. There is no user notification and no way for the user to make updates diretly.

Maybe you are looking for

  • Satellite p75-a7200 error on boot. Please help ASAP.

    Just bought this laptop for my daughter on Christmas. Here is the error information. When I power on the system I get a blue screen with this on it. Recovery Your PC Needs to be repaired The Boot Configuration Data file is missing some required infor

  • Error: cannot be resolved to type

    Hi Guys, I downloaded an application to launch an RTP client/server but I cannot compile it, yhe error message is below: vmplanet@vmplanet-desktop:~/JavaRTP/playerv1$ make javac Client.java 1. ERROR in Client.java (at line 306)      RTPpacket rtp_pac

  • How to dock scrollbars to window in Mountain Lion?

    The scrollbars now float over the window and only appear when necessary. However, I'd like the scrollbars to dock themselves to the window frames as they did before. Anyone know how to do this? The reason is because the bottom item in a list always g

  • Need to Display columns depending on the prompt selection

    I  need to show the only the columns as per the prompt selection given by the user. Suppose there are 5 prompts say (first name, last name, phone number, address, DOJ). All the prompts should be optional. If the user gave input for first name and las

  • Error Calling TaskQquery Service

    I have a BPEL service deployed on a weblogic server. I'm trying to use the weblogic server services to query the tasks (the idea is to query the tasks and check is a task for a payload already exists; so as not to create a duplicate task) I am trying