Gridbaglayout:- middling the elusive OK CANCEL buttons

Hey guys,
I constantly use Gridbaglayout in all my windows. But what constantly evades me is how to get the "ok " and "cancel" button to middle in the window at the bottom.
What is the trick? I try various settings that should apparently work but they don't. I have gotton it right once but am unable to figure out why it works (but it only works on windows, on linux the layout is messed up again).
Regards.

There is some sort of misbelief that you can only use a single panel when laying out a GUI. I can't even guess how much extra work and frustration this has caused. Swing containers are designed ot be nested to create GUIs.
Here's my suggest:
Create a main JPanel and set its layout to BorderLayout.
Creat another JPanel with your other components, less Ok and canel Button. Add this panel to the main panel using BorderLayout.CENTER.
create a third panel and add the Ok and cancel buttons to it. Add this panel to main panel using BorderLayout.SOUTH.
To give your gui a really professional look I would even create a fourth panel set to gridlayout e.g new GridLayout(1,0,5,5). add your buttons to this panel and add this panel to the one in SOUTH. This will center the buttons and make them equal size with a small gap between them.
Cheers
DB

Similar Messages

  • Using Tiscali Webmail with Firefox 6. If I try and delete an email the Ok and Cancel buttons are disabled and nothing happens, have to use F5 to take me back. IE8 works so is this a compatibility issue?

    Using Tiscali Webmail with Firefox 6. If I try and delete an email the Ok and Cancel buttons are disabled and nothing happens, have to use F5 to take me back. IE8 works so is this a compatibility issue?

    It appears OP solved the problem: [/questions/874744]

  • Would like to change my home page. I click on options and my general tab is blank with only the ok and cancel buttons showing. How do I fix this?

    In options, under the general tab, it is blank all except the ok and cancel buttons. I can't change my home page. Please help.

    Hi cor-el,
    Thank you for your reply. Before I had seen your reply. I went into options and under general, all of a sudden it showed what should be there. I closed browser and did it again and it didn't show. It has been blank for roughly two months. Just seems funny that I ask a question and after all this time of not showing what it should, it does, to only be blank again.
    I have also been trying to update the flash player. That comes up completely blank as well with nothing showing at all. I did this several times the day before I posted my question. That same day I also hit the reset button for firefox when I was having trouble trying to update the flash player.
    I did as you said to do. Nothing has changed. Is there something else that I could try?

  • Popups how top program the ok and cancel button

    How do I program the ok and cancel button in the popups. I want to add functionality to the existing ok and cancel buttons in the popup
    Thanks,
    Veena

    You can ise a dialog inside the popup and use a dialogListener to check how hte dialog has been closed
    public void handleDialog(DialogEvent event)
      if (event.getOutcome().equals(DialogEvent.Outcome.no))
        setGender(getOldGender());
        // reference to the gender component is from component binding
        // see selectOneRadio above - binding="#{sharedPopup.genderComponent}
        RequestContext.getCurrentInstance().addPartialTarget(getGenderComponent());
    }{code}
    Timo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Lost my iPad and when I attempt to use the "LOST" feature in icloud, the NEXT and CANCEL buttons are not responding.  I have tried this on 3 different windows based computers.  Any ideas???

    When using icloud because I lost my ipad...when i attempt to use the "LOST" feature the "next" and "cancel" buttons do not respond.  I have attempted this on 3 different windows based computers on 3 different networks.  Any ideas? 

    Report to police along with serial number. Change all your passwords.
    These links may be helpful.
    How to Track and Report Stolen iPad
    http://www.ipadastic.com/tutorials/how-to-track-and-report-stolen-ipad
    Reporting a lost or stolen Apple product
    http://support.apple.com/kb/ht2526
    Report Stolen iPad Tips and iPad Theft Prevention
    http://www.stolen-property.com/report-stolen-ipad.php
    How to recover a lost or stolen iPad
    http://ipadhelp.com/ipad-help/how-to-recover-a-lost-or-stolen-ipad/
    How to Find a Stolen iPad
    http://www.ehow.com/how_7586429_stolen-ipad.html
    Apple Product Lost or Stolen
    http://sites.google.com/site/appleclubfhs/support/advice-and-articles/lost-or-st olen
    Oops! iForgot My New iPad On the Plane; Now What?
    http://online.wsj.com/article/SB10001424052702303459004577362194012634000.html
    If you don't know your lost/stolen iPad's serial number, use the instructions below. The S/N is also on the iPad's box.
    How to Find Your iPad Serial Number
    http://www.ipadastic.com/tutorials/how-to-find-your-ipad-serial-number
     Cheers, Tom

  • Why did adobe switch the OK and cancel buttons for Place?

    I keep hitting Cancel and it's driving me nuts. Seems like a bonehead move. Can you change it back in a future update?

    Mouse wheel up or down, zooms in or out. Mouse wheel with shift pressed at the same time, scrolls the timeline at a speed that actually is useful.
    That should be reversed, where the wheel alone will scroll at a usable speed and the modifier plus wheel will zoom.
    Of course, that's how it used to work.  Adobe 'fixed' this, too.

  • How to handle the "cancel" button and "close" icon of a popup ?

    Hi,
    I have a popup with "cancel button" and "close icon"(on the top right corner of the popup), I want the same operations to be performed on clicking of any of these two components.
    Is there a way to handle such situation ?
    I read about 2 cases to look into this but they didn't work too well for me.
    1. I read about the "popcancellistener" but that listener is called whenever the popup closes, so suppose I have an "ok button" on the popup to create a record, after the record is created, the popup closes and goes into the "popcancellistener", now the question is "how do we know if it came there because of the 'ok button' or 'some other event'".
    2. I even checked the "DialogListener", now I'm able to distinguish between the 'OK' and 'CANCEL' button in the dialoglistener using the "Dialog.Outcome.ok/cancel", but when a user clicks on the close icon, we do not enter the "DialogListener" at all, so in this case "how do we handle the close icon click event"
    Do let me know if you need any more information from my side.
    Thanks for the help in advance.

    The following mechanism responds to any of the following events: <Esc> key, Close icon ('x'), Cancel button
    JavaScript part:
    function popupClosedListener(event){
                  var source = event.getSource();
                  var popupId = source.getClientId();
                  var params = {};
                  params['popupId'] = popupId;
                  var type = "serverPopupClosed";
                  var immediate = true;
                  AdfCustomEvent.queue(source, type, params, immediate);
    }JSF part:
             <af:popup ....>
                  <af:clientListener method="popupClosedListener"
                                           type="popupClosed"/>
                  <af:serverListener type="serverPopupClosed"
                                          method="#{myBean.serverPopupClosedMetod}"/>
            </af:popup>Finally, Java part:
    public void serverPopupClosedMetod(ClientEvent event){
    }

  • Af:dialog model-restore / cancel-button processing best practice ?

    Using JDev 11.1.1.3; if I have an af:dialog running in an af:popup which contains auto-submit components (for cross-component enablement, validation etc.). My question is what are the preferred ways of discarding the model submitted changes made through popup processing if/when the af:dialog cancel button is pressed by user ? Figured that using a task flow for the content that is the popup could be an option, and using the task flow savepoint restore feature, but that looks more like database restore than model restore. I want to be able to restore the model content to the way it looked before the popup executed, without necessitating a submit to the database. How is this most commonly and best achieved ?
    Thanks,

    Taskflow savepoints are not database savepoints. Transactional BTF can be configured to issue automatic savepoints at TF entry and eventually to "rollback" to them at the TF exit. The internal implementation uses the ApplicationModule's passivation/activation mechanism to passivate the AM state at the TF entry and eventually to activate the AM state at the TF exit back to the passivated state at the entry. In this way it is simulated that you have not made any modifications in ADF BC, so your model layer will be restored to the state before TF entry. (Of course, you must not perform any DB commits durring the lifetime of this TF). I have used successfully this mechanism for the same goal you are asking about.
    Also there are savepoints managed by the ADF Controller, but I could be of little help here because I have never used them. I suspect that this mechanism could be what you need, so you may have a look here for more details:
    Adding Save Points to a Task Flow
    and in this thread:
    {thread:id=2128956}
    Dimitar

  • Moving ok and cancel buttons

    Hi,
    When I do JOptionPane.showOptionDialog(...);
    Can anyone tell me how to make the ok and cancel buttons appear at the bottom right of the dialog instead of the bottom center.
    Thanks,
    Jim

    Sure, use another panel as a spacer thusly:
    | |
    | Other Panels |
    | |
    | Spacer | OK Can|<-position panel contains both panels
    Use BorderLayout for the entire dialog and set a position panel to be SOUTH (If you are using someother layout, add a full panel as a backdrop and move your Other panels into it using NORTH). Add the Spacer panel and 'OK/Cancel' panel to this using GridLayout (2 columns, 1 row).
    There is no restriction, other than memory size, to how many panels you use and their hierarchy.
    Robert Templeton

  • Customize CANCEL button on ESS WD-ABAP

    Hi,
    Currently clicking the EXIT or CANCEL button on all ESS applications is opening a new window. We want the user to go back to initial screen while staying on the same window within the portal. Could anyone pls advise how to do this? I dont want to use the Workprotect mode as it is user specific.
    Please advise.
    Thanks.
    Aditya.

    Hi Aditya,
    Currently all the ESS/ MSS  applications are FPM based web dynpro applications . So if you need to to modify any of the functionality, even button actions, you need to modify the FPM based web dynpro code. Most of the buttons(like review/ Exit, etc) have the standard FPM based events triggered when ever they are clicked.
    One has to dig into the code and understand the flow of control in FPM. You can try to find out which event is being triggered when user clicks on the exit button, and  modify code accordingly.
    Thanks,
    Sonali.

  • ListOfValues Cancel button creates memory leak

    I believe one nuance of the listOfValues element (in an LOV page) gives rise to a memory leak. The examples and listOfValues documentation shows storing data needed by listOfValues events in the session. This is all fine and good if the user clicks on the "Select" button, as you get both a lovSelect and lovUpdate event to work with and clean out session data. But in the case of a user clicking the "Cancel" button, no event is fired, nor is a forward to another DataAction done. The window is simply closed. This strands all the data for the LOV (which could be quite sizable) in the user's session. You can't send this data on the request, because the LOV data must exist across several requests.
    Am I completely missing something? How does one clean out a user's session when the Cancel button is clicked on a listOfValues component?
    Brad

    I am using JDeveloper 9.0.5.2. The restrictions of the project prevent using a newer version of JDeveloper. I am using ADF/Struts, and pure UIX (no JSPS).
    The functionality I am speaking of is the standard behavior of the <listOfValues> component (lov for short). The lov component generates events for various behaviors (lovFilter, lovUpdate, loveSelect, etc.). It also completely encapsulates the Cancel and Select buttons, so you have no direct access to those. In order to manage an lov web page (presumably launched from an <lovInput> component on a previous page), the events need access to a certain collection of data (data for the table, max size, starting row, selection, validity, etc.). Because use of the lov page will result in potentially multiple submits, the request is not a good place to store this data, as the data needs to persist for the life of the lov page.
    If you look at some of the lovInput/listOfValues examples on the OTN, you'll see that this data is persisted in the user's session. In and of itself, this is fine.
    The problem is introduced by the fact that the lov's Cancel button (or window close) does not generate any events, and you don't have direct access to those controls to add an event of your own. When the cancel button is clicked, the window just closes, and in the words of the lov documentation "no other events occur."
    This is very problematic -- your session is still stuffed full of data to support the lov. I am looking for a way to remove that data.
    Frank -- in your post, you say:
    "why can't you add an event to clean the session from the data?"
    If you know how to add such an event -- one that fires when the Cancel button is clicked, please enlighten me. I would greatly appreciate it!
    Thanks,
    Brad

  • CANCEL button processing

    hi all,
           what is the code for cancel button meance without process of current screen leave to another transaction.
    thanx in advance.

    Define functional type = E for this 'CANCEL' button in gui status.
    In the PAI of the screen add MODULE EXIT_SCREEN at EXIT_COMMAND.
    Inside this module you should enter the following code:
    case sy-ucomm.
      when ''CANC'.
       If you want you can add a warning  here
         set screen 0. " This will take you back to the calling screen
         leave screen.
      when others.
    endcase.
    if you overwrote old values (from previous screen) in the current screen (that you are exiting) then make sure these changes are reverted. I am guessing this happends automatically, its been a while since I worked on screen ...
    Raj

  • JDialog Ok/Cancel button events

    Dear Java gurus,
    I have something that's been bugging me for days. Now, maybe it's really obvious but my cold has bunged up my head too much to think clearly. Anyway, I thought I'd pass it this way for expert opinion..
    I have a class that extends JDialog, with various textboxes, comboboxes etc. It also has the usual OK + Cancel buttons. The only thing left to implement is something like this:
    MyCustomDialog d = new MyCustomDialog();
    int returnVal = d.showDialog();
    This is similar to most of the dialogs provided with Swing, where the return value is a static field something along the lines of 0 == OK button pressed, 1 == Cancel.
    This allows me to only start "getting" the values from the dialog only if the user selects ok. The problem is, I can't see how to accomplish this. I've been looking at the source for JFileChooser and JColorChooser, but they are more complicated than I can follow. (I am relatively novice when it comes to Swing) I promise, I have been looking on the net for examples, but I've had no luck. Maybe because any searching for JDialog tends to bring back simple examples of the supplied Swing dialogs.
    So, any suggestions?
    TIA

    arooaroo wrote: Shame, because I thought you were on to something.
    I was. Trust me.
    Look at the signature for JOptionPane.showConfirmDialog(). This is the simplest version, but the others look like this and then some:
    static int showConfirmDialog(Component parentComponent, Object message)
    Note that the message parameter is of type  object. This means you can theoretically pass any type of object. A component is an object. Therefore, you can pass a JPanel as the message parameter.
    Look at this quote from the JOptionPane description in the API:
    message
        A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:
        Object[]
            An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
        Component
            The Component is displayed in the dialog.
        Icon
            The Icon is wrapped in a JLabel and displayed in the dialog.
        others
            The object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed.
    I was going to suggest the modal option on JDialog, but for some reason I thought it wouldn't work.  I still think using JOptionPane would be easier; that's what it was designed for.
    Dusty

  • Cancel button doesn't always cancel

    Sometimes, when I hit the red X cancel button in PL/SQL Developer it doesn't cancel the process.
    The DBA is getting tired of me asking for the process to be stopped.
    How can I avoid causing this problem and how can I cancel the process without involving my DBA?
    It seems to happen in a procedure loop.
    I'm a PL/SQL newbie.
    Thanks, bobh

    The command to use it
    alter system kill session 'session-id,session-serial'But first check if you have the rights to do that.

  • Js Confirm function : possible to change default [cancel] button

    Hi,
    Confirm function of java Script:
    Since we know that the confirm function was foucs on the OK button. can we change the focus to Cancel button after popup?
    Appreciate your help if this is possible by java script ...
    Thx...

    Can you suggest how to acheive this by minimum code.
    Coz I want to display the pop-up same as confirm function. The only difference is it should be focus on Cancel button instead.

Maybe you are looking for

  • Balance carried forward

    Dear Team, I would like to know implications if balance carry forward is run every Quarter instead of Year in quarterly consolidation ? Thanks and Regards, Mandar Jetly

  • Internal Order Error

    Dear friends I am getting an error while making down payment against the purchase order. The order of my entries or steps are as follows: Created one internal order for Capital WIP with budget and availability control activation. Created one purchase

  • How to open PDF with proper orientation

    A client is sending me 65 graphs for a book. When I open his PDF, each chart is in landscape mode, but when I open the PDF with Illustrator or place the chart in Indesign it's rotated 90 degrees. Is there a way to tell Illustrator to open each chart

  • Problem with fireworks images

    Sometimes when look at my site from different computers my fireworks image looks different. It sometimes has a colored background and when it was created in fireworks it has a transparent background. I am really frustrated as to why this is. Can anyo

  • Won't update 4.6 PPC to my HD-Going Krazy!

    Using my slow dialup I downloaded the PPC update so I can 'update' my FCP software package. Currently have 4.3. After lengthy download (IP shuts down after a couple of hours) I tried to install the update and it would not allow it to go to my hard dr