Need an hint on disposing a dialog.

Hi there,
Using: Netbeans 4.1 with the Sun JDK 1.5.0_06 on Linux.
I recently started to study Java and so far I love it. Last evening (after my "daily tutorial section") I tried setting up a very basic program only armed with the JDK 1.5 documentation provided by Sun. The task: a dialog with "Hello World".
Now.. I managed to come up with a very basic program using the JFrame class, and it works too:
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class HelloWorld extends JOptionPane {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        showMessageDialog(frame, "Hello World!");
        frame.dispose();
}And yes, for your fun and amusement I did make the mistake of forgetting all about dispose() when I first started the critter. So far, so good. Now I want more; I read about the method "setDefaultCloseOperation(int)" which allows the JFrame to determine what to do when a user closes the window. So, after some more reading, I came up with:
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
public class HelloWorld extends JOptionPane {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        showMessageDialog(frame, "Hello World!");
        // frame.dispose();
}The only problem here is that it doesn't do what I expected and so far I can't put my finger on it. The user clicks 'ok', the dialog disappears and the application continues to run. Just to be sure I tried replacing the "WindowConstants.DISPOSE_ON_CLOSE" with the value 2 (found on the constants list) and even the JFrame field "EXIT_ON_CLOSE" (so instead of the constant or '2' a mere "frame.EXIT_ON_CLOSE") but nothing! I then found on the Sun tutorial "how to make frames" the example "frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);" which I then tried but I got the same results.
So my questions are basicly:
Could anyone hint me where my thinking goes wrong ? I'm not looking for ready made solutions, but trying to understand whats up here.
Second: I read that this is an extension with JFrame and is not found on Frame. Would my conclusion be right (not only based on these experiments) that it would probably be best to keep using dispose() so that I'm not making myself dependend on specific extensions ?
Last, but not least, in my attempts I tried using "frame.EXIT_ON_CLOSE". Isn't that basicly equal to my "JFrame.EXIT_ON_CLOSE" ?
I am probably going to hate myself for that last question since I can't help feel having missed something obvious from the tutorials (which I'm going to re-read later on) but alas..
Thanks for any input.

if you do this
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);and you only have one frame, then when you close that frame it effectively is a System.exit(0); and a call to dispose() is unnecessary.
however, when a frame is created, there are listeners created(among other things) that hold a reference to the frame. if your application has multiple windows and you want to close one of them without exiting the application, then you need to call dispose(). this "disposes" of all the things in the background(trying not to be too technical) and allows the frame and all associated "stuff" to be garbage collected. In this case, you would want to add a window listener and call dispose() in the windowClosing() method.
this is a very simplistic explanation but I think it's appropriate not to get into too much detail at this point. you should be able to find some good reading material about this with a Google search.
kind regards
walken

Similar Messages

  • Need some hints on using dbms_crypto

    Hello,
    I need some hints on using the dbms_crypto package to generate some password for the OID userpassword attribute. The passwordstring is stored in a format {CRYPT}dasdasdawdww, {SHA}jfsklefjskldjkdlkldf, {MD4}dfdsfgsdgdfewwe or {MD5}fsdfsdadsgdfg where the keyword in the curly brackets describes the encryption methods. I think CRYPT means DES, SHA means SHA-1.
    The key for the DES encryption for UNIX password authentification is in the first 2 letters of the encrypted string. I wanna have an encryption function which encrypts the clear type passwords in the right format like this perl script:
    #!/bin/perl
    print crypt($ARGV[0],"HS");
    #: crypt.pl Test123 # program fetch
    HSF0Sx2zdrLoQ
    Regards
    Holger

    Hello,
    meanwhile I made some investigations on the Problem
    I tried this code:
    DECLARE
    input_string       VARCHAR2 (200) :=  'Test123';
    output_string      VARCHAR2 (200);
    encrypted_raw      RAW (2000);             -- stores encrypted binary text
    decrypted_raw      RAW (2000);             -- stores decrypted binary text
    num_key_bytes      NUMBER := 256/8;        -- key length 256 bits (32 bytes)
    key_bytes_raw      RAW (32);               -- stores 256-bit encryption key
    encryption_type    PLS_INTEGER :=          -- total encryption type
                             DBMS_CRYPTO.ENCRYPT_DES
                           + DBMS_CRYPTO.CHAIN_CBC
                           + DBMS_CRYPTO.PAD_PKCS5;
    BEGIN
            DBMS_OUTPUT.PUT_LINE ( 'Original string: ' || input_string);
            key_bytes_raw := UTL_I18N.STRING_TO_RAW ( 'HS' );
            encrypted_raw := DBMS_CRYPTO.ENCRYPT
                            src => UTL_I18N.STRING_TO_RAW (input_string,  'AL32UTF8'
                            typ => encryption_type,
                            key => key_bytes_raw
    -- The encrypted value "encrypted_raw" can be used here
            DBMS_OUTPUT.PUT_LINE ( 'Encrypted string: ' || encrypted_raw);
            decrypted_raw := DBMS_CRYPTO.DECRYPT
                            src => encrypted_raw,
                            typ => encryption_type,
                            key => key_bytes_raw
            DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || UTL_I18N.RAW_TO_CHAR (decr
    ypted_raw, 'AL32UTF8'));
            DBMS_OUTPUT.PUT_LINE ('Encrypted Char string: ' || UTL_I18N.RAW_TO_CHAR
    (encrypted_raw, 'AL32UTF8'));
    END;
    /and got these error messages:
    ERROR at line 1:
    ORA-28234: key length too short
    ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 3
    ORA-06512: at "SYS.DBMS_CRYPTO", line 10
    ORA-06512: at line 15In the next try:
    DECLARE
    input_string       VARCHAR2 (200) :=  'Test123';
    output_string      VARCHAR2 (200);
    encrypted_raw      RAW (2000);             -- stores encrypted binary text
    decrypted_raw      RAW (2000);             -- stores decrypted binary text
    num_key_bytes      NUMBER := 256/8;        -- key length 256 bits (32 bytes)
    key_bytes_raw      RAW (32);               -- stores 256-bit encryption key
    encryption_type    PLS_INTEGER :=          -- total encryption type
                             DBMS_CRYPTO.ENCRYPT_DES
                           + DBMS_CRYPTO.CHAIN_CBC
                           + DBMS_CRYPTO.PAD_PKCS5;
    BEGIN
            DBMS_OUTPUT.PUT_LINE ( 'Original string: ' || input_string);
            key_bytes_raw := UTL_I18N.STRING_TO_RAW ( 'HS12345678901234' );
            encrypted_raw := DBMS_CRYPTO.ENCRYPT
                            src => UTL_I18N.STRING_TO_RAW (input_string,  'AL32UTF8'
                            typ => encryption_type,
                            key => key_bytes_raw
    -- The encrypted value "encrypted_raw" can be used here
            DBMS_OUTPUT.PUT_LINE ( 'Encrypted string: ' || encrypted_raw);
            decrypted_raw := DBMS_CRYPTO.DECRYPT
                            src => encrypted_raw,
                            typ => encryption_type,
                            key => key_bytes_raw
            DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || UTL_I18N.RAW_TO_CHAR (decr
    ypted_raw, 'AL32UTF8'));
            DBMS_OUTPUT.PUT_LINE ('Encrypted Char string: ' || UTL_I18N.RAW_TO_CHAR
    (encrypted_raw, 'AL32UTF8'));
    END;
    /I got some results which have nothing in common with the perl script:
    Original string: Test123
    Encrypted string: DE5668CD7762074C
    Decrypted string: Test123
    Encrypted Char string: ?h?bL
    PL/SQL procedure successfully completed.Come to think of it I doubt if DBMS_CRYPTO is the right way to solve my problem. Any further hints?
    Regards Holger

  • Forgot my apple ID , and need a hint on my associated email so i can sent a reset password , and the worst thing in apple ID forgot password page that if you typed any apple id even if its wrong it gives you that email has been sent !! how come !

    forgot my apple ID , and need a hint on my associated email so i can sent a reset password , and the worst thing in apple ID forgot password page that if you typed any apple id even if its wrong it gives you that email has been sent !! how come !!
    so please if anyone got any idea of how to get the hint on the mail ( i used to remember there is a hint )

    If all you did was rename your ID, you can go to Settings>iCloud, tap Delete Account, choose Delete from My iPhone when prompted, then sign back in with your renamed ID.  Deleting the account only deletes the account and any data you are syncing with iCloud from your phone, not from iCloud.  Provided you are signing back into the same account and not changing accounts, your data will be synced back to your phone when you sign back in.
    If, however, you are changing to a new account with a new ID, choose Keep on My iPhone when prompted.  Then choose Merge when you sign into the new account and turn your iCloud syncing back on to upload your data to the new account.
    Before deleting the account, save you photo stream photos to your camera roll (tap Edit, tap all the photos, tap Share, tap Save to Camera Roll).

  • Need a hint for home office / 871 does not support port-security - FPM ?

    Hi,
    i want to realize the following setup:
    - Central Site 871 with Internet Connection and static IP
    - Home office 871 with Internet Connection and static IP. On that home office router, there should be 2 Vlans: 1 for the office work and one for the user's private PC. All Traffic from the "office" Vlan is being put into a VPN to the central site. All Traffic on the other interface is being natted and goes straight to the internet.
    To minimize security issues, i tried to configure port-security, so that the user cannot connect with his private PC to the office LAN ports and vice versa. Unfortunately, port-security seems not to be supported on the 871 (advanced ip services image).
    Now i looked for an alternative...and came over to FPM (flexible packet matching).
    If i understood right, you can classify packets for example by their source MAC address and if this field matches a specific value (the mac of the work pc), packets can be dropped by a policy.
    Of course i cannot avoid that the user connects the work pc together with his private pc (this is then related to the OS Security to keep out viruses, worms, trojans, etc). But i could/want to restrict the internet access with the work pc through "normal" Internet access - the users should not be able to do that (must use the company's proxy).
    I did the follwing config:
    class-map type access-control match-any c2
    match start l2-start offset 48 size 6 regex "0xabcd1234fedc"
    match field ETHER source-mac regex "abcd1234fedc"
    policy-map type access-control p2
    class c2
    drop
    interface Vlan1
    ip address 192.168.20.1 255.255.255.0
    ip nat inside
    ip virtual-reassembly
    service-policy type access-control input p2
    service-policy type access-control output p2
    As this feature is quite new, i'm not familiar with it's syntax.
    I also tried to use "string" instead of regexp, but i'm still able to connect the office pc to the private Lan and i am able to access the "Internet" (currently it's only setup in a lab).
    As i understood so far, the offset is the value in bits, and size is in bytes. is that correct?
    Has anyone yet some experience with FPM or maybe any hint for me how to realize the requested setup with the 871 routers?
    bets regards,
    Andy

    For the FPM feature to work you will need PHDF files for the protocols you want to scan for to be loaded on your routers. The files can be downloaded from cisco's website. In your case you will have to download ether.phdf file.

  • Can't dispose my dialog after moving it using swing timer.

    Hi all,
    I use the swing timer to move a dialog from one position to another. Here is the code I have use.
    // Set the main window display location
        public void setWindowLocation()
            int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
            int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
            int frameHeight = this.getHeight();
            int frameWidth = this.getWidth();
            int _xValue = (screenWidth - frameWidth);
            int _yValue = (screenHeight - getTrayheight() );
            int _yEnd = (screenHeight - frameHeight - getTrayheight() );
            //this.setLocation((screenWidth - frameWidth), (screenHeight - frameHeight - getTrayheight() - WINDOW_SPACE));
            this.setLocation(_xValue, _yValue);
            while(_yValue > _yEnd){
                dialogMotion(this, _xValue, _yValue);
                _yValue -= 1;
            // this.dispose();
    // Dialog motion
        private void dialogMotion(final MainDialog mainDialog, final int x, final int y){
            AbstractAction abAction = new AbstractAction() {
                public void actionPerformed(ActionEvent evnt) {
                    mainDialog.setLocation(x, y);
            Timer motionTimer = new Timer(300, abAction);
            motionTimer.setRepeats(false);
            motionTimer.start();
    // Find the taskbar height to place the main frame in lower-right corner
    // of the viewable area of the screen.
        private static int getTrayheight(){
            return (Toolkit.getDefaultToolkit().getScreenSize().height -
                     GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height);
        }I think my code is clear to you. After moving the dialog onto the task bar, I want to dispose it. You can see that at the end of the while loop I've try it.
    What happened there is, I can't see the dialog moving. it directly dispose. I add a breakpoint at the while loop and check, it iterate until condition is false. But I can't see the motion. If I comment the dispose code line as in my above code, I can see it moving.
    Why is that. Your comment really helpful to me.
    I'm worried is that debugging iterate that while loop but it is not visible. :( :(

    Thanks a lot. I got the point all of you said. But it is bit confusing how to do it.
    As i said in my first post, used slightly similar code to move down the dialog. Here what I have try. But the question is because of my thread used there, it wait little amount to scroll down.
        private void hideWindow(MainDialog mainGialog){
            try{
                int _xAbove = mainGialog.getLocation().x;
                int _yAbove = mainGialog.getLocation().y;
                int _yBelow = mainGialog.getLocation().y + mainGialog.getHeight() + getTrayheight();
                while(_yBelow > _yAbove){
                    dialogScrollingUpDown(this, _xAbove, _yAbove);
                    _yAbove += 1;
                Thread.sleep(1000);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        try {
                            Thread.sleep(1500);
                            dispose();
                        catch (InterruptedException e) {
                            e.printStackTrace();
            catch (Exception ex) {
                System.out.println(ex.getMessage());
        private void dialogScrollingUpDown(final MainDialog mainDialog, final int x, final int y){
            AbstractAction abAction = new AbstractAction() {
                public void actionPerformed(ActionEvent evnt) {
                    mainDialog.setLocation(x, y);
            Timer motionTimer = new Timer(400, abAction);
            motionTimer.setRepeats(false);
            motionTimer.start();
    // System tray height
        private static int getTrayheight(){
            return (Toolkit.getDefaultToolkit().getScreenSize().height -
                     GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height);
        }Actually I called the hideWindow method in a button clicked event. After clicked the button, it wait a time equal to the first thread sleep. I can't reduce the time, if so dialog dispose instant.
    Whay I can't do all those things is my IDE not allowed to use frequently changing values in dialogScrollingUpDown method. You can see that in my code.
    Any comments for that.

  • I need a control similar to instalation dialogs

    I write because I have a problem with an application that I�m making with LabView 6.1. I want make a control similar to installation dialogs where you can select or deselect part or all components of a program. That dialog has a tree structure. I attach an image of one of that dialogs.
    However I find no control that makes that and I try to make it with listboxes but it's quite difficult its use.
    I don�t know if I must create it or already exists.
    And how can I make a control with its own events handler.
    I thank your help.
    JL Guardiola
    Attachments:
    Dibujo.bmp ‏725 KB

    Hi,
    LabVIEW has several options that can fit your needs.
    The easier one is the Tree Control. This control was a LabVIEW 7 Express new feature, so you must update to LabVIEW 7.0 or higher to be able to use it.
    However, you have the option to use Microsoft TreeView Control through ActiveX. You are bound to deal with ActiveX methods and properties if you choose this option. This is not really easy so I suppose it is not interesting for you. If I am wrong please ask me for more help.
    The third option is to build your own control as a combination of checkboxes. The appearance to the end user would be just like the image you´ve attached.
    To build this control you can:
    1.-) Use decorations with Dialog Checkboxes inside.
    2.-) Use an array of Dialog Checkboxe
    s
    You can access the Dialog Checkbox on Controls Palette>>Classic Controls>>Classic Boolean.
    I am attaching a LabVIEW 6.1 example on how to implement this last option.
    Hope it helps.
    César Verdejo
    Training and Certification | National Instruments
    Attachments:
    Checkbox_control.vi ‏12 KB

  • How to show "An app on your PC needs the following Windows feature." dialog programmatically?

    When I try to run .NET 3.5 applications on Windows 8.1 which has not .NET 3.5 Framework, Windows will show the "An app on your PC needs the following Windows feature. .NET Framework 3.5 (includes .NET 2.0 and .NET 3.0)" dialog automatically.
    But I want to show this dialog programmatically. I think that the dialog is much more friendly than DISM command.
    Any help would be appreciated.

    Hello lzhangwdk,
    I'm thinking that the issue is more related to a Setup issue now.
    Anyway, may I ask one question, have you include the .NET 3.5 feature in your prerequisite list when creating a installer?
    To raise a dialog is possible but it still require you use a kind of depolyment technology then customize your installer. If you use the ClickOnce technology, you can consider use isFirstRun to customize something to run:
    https://social.msdn.microsoft.com/forums/windows/en-us/b3bca1fb-d2f3-417d-a7f9-e174e32ed3b0/clickonce-custom-actions
    In setup project you may consider use custom actions to raise a dialog.
    http://www.codeproject.com/Articles/335516/Custom-Action-in-Visual-Studio-setup-projects
    So in general I need more info from you to redirect you to the right direction. And actually in my mind, just use the prerequisite list is OK. It is better than try any dism command, it will ask your users to install or enable .NET 3.5 themself.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Need some hints for evaluating data from Central Performance History

    Hi Experts,
    I am pretty new to all the BI-stuff and hopefully someone can provide some hints. I got the requirement to read data (CPU usage/peaks) from central performance history of "system a" into "bi system" to generate overviews/charts/etc
    Now I guess there might be a standard report/info cubes and stuff which will help to solve this.
    I would really appreciate if someone could throw me a few keywords about this topic.
    Thanks in advance!

    Hi David,
    Thanks, I hadn't looked at the note.
    Section 2 - history of all connected systems showed me what to do to collect the data. I had seen that in the setup but not understood the implications of it fully. The note explained it much clearly than the SAP help.
    Thanks again,
    Gareth

  • Need to avoid Select Email Client dialog when submitting Acrobat X form

    We are using Windows 7 / Office 2010 32-bit with Adobe Pro X, and have found that when creating a PDF from a Word 2010 document (via either print or convert or Word PDF or XPS), then using Acrobat to create a form from it, when we apply the action Submit a Form, the finished product presents users with a Select Email Client dialog.  The choices within the dialog are Desktop or Internet email.  We are using a direct email address, not a server location.  This happens even when NOT using the Distribute wizard.  Outlook is confirmed as the email choice in Adobe Preferences Internet Settings.  Anyone encounter this issue and have a fix or workaround?  We want the email to auto-create as it does in our XP / Acrobat 8 Pro environment without a dialog presentation.
    Thanks for any and all thoughts!

    Yes, you are right that is the way to go.  Thank you!
    I have tested and am now using successfully:
    // Set email address
    var cToAddr = "%email.address%";
    // Set the subject and body text for the e-mail message
    var cSubLine = "Survey Response";
    var cBody = "Message body text";
    // Send the form data as a PDF attachment in an e-mail message
    this.mailDoc({bUI: false, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});

  • [Off topic] Need some hints where to start

    Hi,
    I've been out of C++ for around 9 years. (Doing java since then)
    For an upcoming project I have to get back into it.
    I've already done quite much execise with STL, boost and ICU.
    Now I'm looking for a solution for the following problem:
    I need some kind of RessourceManager, which is able to suspend
    some threads and dump their memory to disk. It must maintain
    dependencies between ressources and should be as transparanet
    as possible to the rest of the source code. It should have some config
    options like amount of memory to use, etc.
    I think a starting point would be an Allocator which is connected to
    a ResourceManager.
    Is there any standard way, which I haven't found, to do this?
    Greetings,
    Markus
    P.S.: Can someone point me which is the right mailing
    list for this kind of questions?

    A good resource for general C++ programming questions like yours is newsgroup
    comp.lang.c++.moderated

  • Difficulties to adjust touchpad, need some hints. [SOLVED]

    Hi,
    Thank you to the forum community and to the Arch community for giving a really good support and strenght to the Arch project.
    I am having difficulties to configure my touchpad, here are the hardware informations output from hwinfo :
    PS/2 00.0: 10500 PS/2 Mouse
      [Created at input.249]
      Unique ID: AH6Q.Y_f5kDtfqz2
      Hardware Class: mouse
      Model: "SynPS/2 Synaptics TouchPad"
      Vendor: 0x0002
      Device: 0x0007 "SynPS/2 Synaptics TouchPad"
      Compatible to: int 0x0210 0x0001
      Device File: /dev/input/mice (/dev/input/mouse0)
      Device Files: /dev/input/mice, /dev/input/mouse0, /dev/input/event6, /dev/input/by-path/platform-i8042-serio-1-event-mouse, /dev/input/by-path/platform-i8042-serio-1-mouse
      Device Number: char 13:63 (char 13:32)
      Driver Info #0:
        Buttons: 1
        Wheels: 0
        XFree86 Protocol: explorerps/2
        GPM Protocol: exps2
      Config Status: cfg=new, avail=yes, need=no, active=unknown
    I use synaptic driver because I had issues with the mtrack drivers from the AUR ( the mouse was stoping to work.). Now i configured this way my synaptic config :
    Section "InputClass"
            Identifier "touchpad"
            MatchProduct "SynPS/2 Synaptics TouchPad"
            Driver "synaptics"
            Option "TapButton1" "1"
            Option "TapButton2" "2"
            Option "TapButton3" "3"
            Option "VertEdgeScroll" "on"
            Option "VertTwoFingerScroll" "on"
            Option "HorizEdgeScroll" "on"
            Option "HorizTwoFingerScroll" "on"
    EndSection
    Section "InputClass"
            Identifier "touchpad ignore duplicates"
            MatchIsTouchpad "on"
            MatchOS "Linux"
            MatchDevicePath "/dev/input/mouse*"
            Option "Ignore" "on"
    EndSection
    I added the following code that i run at X startup also to avoid the mouse to move  when I use the tapping feature because it s too sensitive by default :
    xinput -set-prop "SynPS/2 Synaptics TouchPad" "Device Accel Constant Deceleration" 8
    Now the mouse is less sensitive and doesnt move when i want to use left click tapping feature. (click without pressing the touchpad buttons).
    But the problem is I need "move accross the touchpad" maybe 4 times in order to cover the entire screen. How can I have amore sensitive mouse but no change in the mouse position when I am tapping the touchpad to click.
    Thanks for your help.
    Last edited by maxarsys (2013-11-06 08:24:14)

    Here's what I use but I don't honestly think somebody else's config is likely to be much help:
    Section "InputClass"
    Identifier "touchpad catchall"
    Driver "synaptics"
    MatchIsTouchpad "on"
    Option "HorizTwoFingerScroll" "1"
    Option "LockedDrags" "1"
    Option "TapButton1" "3"
    Option "TapButton2" "1"
    Option "TapButton3" "2"
    Option "ClickFinger1" "3"
    Option "ClickFinger2" "1"
    Option "ClickFinger3" "2"
    Option "FingerLow" "20"
    Option "FingerHigh" "25"
    MatchDevicePath "/dev/input/event*"
    EndSection
    Section "InputClass"
    Identifier "touchpad ignore duplicates"
    MatchIsTouchpad "on"
    MatchOS "Linux"
    MatchDevicePath "/dev/input/mouse*"
    Option "Ignore" "on"
    EndSection
    Section "InputClass"
    Identifier "Disable clickpad buttons on Apple touchpads"
    MatchProduct "Apple|bcm5974"
    MatchDriver "synaptics"
    Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
    EndSection
    The last part doesn't apply - it must be from the default config.
    I would be astonished if this was at all helpful but you did ask!

  • Need design hints for Managed class

    I need help understanding the underlying LCDS mechanisms when a complex object hierarchy is managed in LCDS.  I have a custom Assembler because I have specialized persistence requirements.  My object hierarchy is basically the following:
    Document
        Chapter
            Page
                Text
    Document is the [Managed] class.  When a new Document is created, it is initialized with a Chapter.  Pages and Text are created when the document is edited.  I create new instance of Document and initialize it with an instance of Chapter.  On the client, I invoke the DataService using the createItem method.  My custom Assembler is called, I do the necessary persistence operation and return.  Back on the client I receive the ItemReference containing the AS Document.  This all works ok.  I am now faced with the runtime operations when the user starts creating Chapters, Pages and entering text.
    Given that I start the editing session with a single ItemReference, I don't understand how to handle the Document sub-tree.  The LCDS documentation says the purpose of the [Managed] class tag is so the entire object tree does not need to be transmitted when a property changes on a child object.  Its the responsibility of the sub class to keep the remote object in sync.  But, I don't know the best way to go about doing this.
    The [Managed] annotation makes the properties of the managed class bindable.  I can add an event listener to the ItemReference to handle property changes on the Document, but what about the rest of the object tree?    Do I explicitly make the properties of the child objects bindable?  Do I make each parent object an event listener for its child object properties and propagate the event up the tree?
    Any suggestions or patterns to make this a little more understandable would be greatly appreciated.

    If Hibernate cannot read/write your persistence layer (i.e. its not a database) then you probably wont be able to deploy a model and have the server side 'just work'.  You can specify the assembler class in the model annotations and we will configure a destination of that type for each entity (you can specify a custom assembler for each different entity).  This may not be a road that you want to go down, as manually configuring each assembler for each association will give you more transparency and control.
    But you can still use the model in FlashBuilder to generate all of your client side value objects and you may be able to use the generated service wrappers.
    Note that for each association, you will need an assembler.  So there is the Document assembler, the Chapter assembler and the Page assembler.  Each one is responsible for managing the persistence of each item type.  You would then define the <one-to-many> relationships in the destination config, along with the destination that manages that type of item:
    <destination id="DocumentAssembler">
      <metadata>
        <identity property="id">
        <one-to-many property="chapters" destination="ChapterAssembler" lazy="true" paged="true" page-size="10" />
      </metadata>
    </destination>
    <destination id="ChapterAssembler">
      <metadata>
        <identity property="id">
        <one-to-many property="pages" destination="PageAssembler" lazy="true"  paged="true" page-size="10" />
      </metadata>
    </destination>
    And so on for PageAssembler.  This is how the system can manage each item class.  I made the associations lazy and paged, but you don't have to do this if you don't need it.
    On the client, each of the managed collections (Documents, Chapters, Pages) is monitored for changes and the appropriate create/update/delete in the assembler is performed when a commit() is called.  You perform a DataService.fill() on the "DocumentAssembler" destination to start things off, you get back a managed collection and just go to town, modifying the whole object tree as you see fit, then calling DataService.commit() on the Document, and all of the nested 'stuff' that you did will be persisted to each assembler for each type of collection (documents, chapters, pages).  It is pretty powerfull.
    To help reduce the work, you can use a model to generate code, then never generate it again.  Or just define the AS value objects manually, using the generated code as a guide.  The trick is to make sure the collection properties like "chapters" and "pages" are labeled with the [Managed] metadata.
    There are plenty of 2 level association examples on the DevCenter and out in the web (check out Tour De LiveCycle for instance).  You are just going down one more level.
    All this being said, you can skip most of this and just have a single destination that does Documents and takes a full object graph of stuff each time.  This will be pretty 'blunt force' as the whole Document will be handed to the updateItem function and you have to figure out how to persist it and all its sub-properties.  I am not familiar with Jackrabbit, so I don't know how fine grained your persistence is.
    Anyway, let us know what you come up with!

  • Need help/hints/tips with a method for connect 4 game.

    Hi!
    I'm currently trying to get my "movepiece"-method to make it so that players can only drag a piece into the empty square at the bottom row, and if the square is not empty the method will move up one row and check if it's empty if not, repeat until
     6 are checked if no one is empty then move is invalid.
    I've been trying out while loops and for loops but i think i might set the wrong conditions for exiting the loop...
    Here the code for the method without any loops simply adds pieces.
            /// <summary>
            /// Method that performs the actual move.
            /// The old piece gets overrun by the attacking piece. 
            /// The attacking piece's position becomes null.
            /// </summary>public Piece[,] MoveAttackpiece(int[,] changearray)
    int origX = changearray[0, 0];
    int origY = changearray[0, 1];
    int targetX = changearray[1, 0];
    int targetY = changearray[1, 1];
    pieceArray[targetX, targetY] = pieceArray[origX, origY]; //swap
    return pieceArray;
    The game is using winforms and a 2D array(pieceArray)to draw the game board
    I'm using a Constants class for declaring the height and width of the board, which the pieceArray is based on, Namely const int BOARDESIZEx and BOARDERSIZEy.
    And while i'm at it when i did different loops for tryng to make the piece move down/up (based on if a square in bottom row was empty or not) the program crashes and i get the "Null Reference Exception unhandled"
    at this part in the game.CS (the earlier code reside in a class named Squares.cs)
    if (changearray != null)
    //Building string to print (split over several rows for readability but also to avoid calculations)
    Piece attackpiece = pieceArray[changearray[1, 0], changearray[1, 1]];
    string message = "";
    if (move % 2 == 1) message += "TURN " + move / 2 + ":\r\n"; //integer division, as there are two draws per turn
    message += attackpiece.Name + ": "; //Walker:
    message += IntegerToChar(changearray[0, 1]); //Walker: A
    message += (changearray[0, 0] + 1) + " - "; //Walker A1 -
    message += IntegerToChar(changearray[1, 1]); //Walker A1 - B
    message += (changearray[1, 0] + 1); //Walker A1 - B2
    if (move % 2 == 0) message += "\r\n"; //blank row inserted after each completed turn
    Board.PrintMove(message);
    I've tried making
    While(piecearray[targetX, targetY]!=null)
    pieceArray[targetX, targetY]==pieceArray[targetX, targetY +1];
    return array;
    but that didn't work and i don't really know how to make the game start at bottom row.
    I appreciate any help or tips on how to get this to work since it's the only thing left for making the game work as intended.
    Cheers and thanks for reading.
    PS: if there's anything you wonder just ask and i'll explain as much as i can.
    Regards Gabbelino
    Student at the University of Borås, Sweden

    Let's look at what's wrong with the following code.
    While(piecearray[targetX, targetY]!=null)
    pieceArray[targetX, targetY]=pieceArray[targetX, targetY +1]; // I assume the "==" in your post above was a typo.
    Suppose, for the sake of argument, that targetX is 2 and targetY is 3, and that pieceArray[2,3] is not null. The line inside the loop will then become...
    pieceArray[2,3] = pieceArray[2, 4];
    ...and this line will keep being executed as long as pieceArray[2,3] is not null, which if pieceArray[2,4] is not null will be forever (infinite loop).
    I suspect that your loop should look something like this...
    for(int i = 0; i < BOARDSIZEy; i++)
    // Look for the first available square in the target column.
    // When found, set the piece on that square then break out.
    if(pieceArray[targetX, i] == null)
    pieceArray[targetX, i] = pieceArray[origX, origY];
    break;

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

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

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

  • LMS3.2: need Topolology Map Layout hint for lines

    We want to give a more representive layout to our topology maps by manualy drag the devices over the drawing.
    OK, the devices are no problem,but the lines. We need a hint, how to can remove or influence the line bucklings - make the lines straight, see screenshot. Many thx in advance.
    Steffen

    For the FPM feature to work you will need PHDF files for the protocols you want to scan for to be loaded on your routers. The files can be downloaded from cisco's website. In your case you will have to download ether.phdf file.

Maybe you are looking for