Can you disable the cancel button in a jface wizard? - java

When the user presses the 'next' button in my jface wizard, it will be communicating with my server asynchronouly.
However this operation cannnot be cancelled, so I want to basically disable the 'Cancel' button temporarily in my jface wizard and also if possible the 'close' button in the title bar.
Is this possible?

pass your long-running code wrapped by IRunnableWithProgress into wizard.getContainer().run(true, false, rwp). Inside your code you will have access to IProgressMonitor, which basically controls the visual progress bar.

How are you communicating with the server? Are you running it inside IWizardContainer.run()? you can pass cancellable = false.

Related

Get user confirmation before closing a DialogFragment

I have a DialogFragment that allows a user to create a new record. I would like to intercept the close event to test whether they've started inputting any data, and if so prompt them that will lose unsaved changes. I would rather not add a close button, so the user can close the Dialog by clicking anywhere outside it in the screen.
So is there an event that will allow me to cancel the Dialog close action if the user selects not to?
You could do something similar to what is described in this answer -- make an activity that intercepts all touch events, both inside and outside its bounds, then checks for ACTION_OUTSIDE on captured touch events. Note that that's using a separate activity for the dialog, not a fragment, so if using the fragment is a strict requirement this method won't work for you.

equivalent of getch() for Android

Is there an equivalent for C's getch() in Android or Java? I want the execution to stop until the user does some action, like tap on the screen or maybe press one of the hardware buttons like volume control or whatever is available. Another option would be to show a modal message box window, which does not let the program continue until the user presses on OK. Is it possible to do this in a simple way in Android? What is the simplest way to get something equivalent to getch() function in android?
I need to be able to use this in a Thread as well
There's no getch() equivalent function/method in java.
You must event handlers to do that.
Like having click handler for button,Which let you to some stuff on onClick() method,Once you click the button.
This example might helpful:Button Click Listeners in Android
There's an event listener for android like onCLickListener. Then you can also used Jdialog then set its .isEditable value to false like dialog.isEditable(false);

How to implement cancel button in JConfirmDialog

I have a java swing application. This application contains a mainframe window.
When the user clicks the close (X button on top right of window), my application pops up a JOPtionPane Confirm dialog with yes, no and cancel operations. Clicking on yes saves some files and closes the application, No closes the application without saving the results. This all has been implemented and working fine.
Now i need to implement cancel operation which should typically do something like close the ConfirmDialog and keep the application still open (contrary to this yes and no option closes the application)". I need to implement the idea of "application should not be closed upon clicking the cancel button". For any existing example one can consider the closing of excel sheet (after you edit the excel and try closing without saving).
Set the default close operation for the frame to do nothing:
frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE )
Your windowClosing event handler can then literally just return if the user clicks cancel and the program will continue as if nothing has happened.
If the user clicks yes or no then your code will need to programmatically close the frame.

Disable JFace Wizard 'Cancel' button on last page of wizard

When the user reaches the very last page of my JFace Wizard, I want to disable the cancel button (since at that time you cannot really 'cancel').
How can that be done?
Update:
This does not relate to my previous question about the cancel button which was related to disabling the wizard dialog entirely while running an async operation and involved a different api.
What you are trying to do isn't good for the users :-) A user should be able to cancel the wizard at any given point of time.
There isn't a direct API. You need to extend WizardDialog for this. Use getButton(IDialogConstants.CANCEL_ID) to get the cancel button. You can do enable/disable on that button.

Event handling in modal windows (Java swing)

I'm developing the Java Swing application. I'm quite new to Java, so got some questions. I have a modal window with some set of controls (text fields, buttons etc).
I want to handle click on the button in the parent window. I think the most efficient and accurate way is first to handle it in modal window, then raise some another event from the model form and handle it in the parent form.
Is this approach right and what are the best practices on doing that?
Thanks for your help!
In general, the dialog that contains the button should handle the button click.
However, maybe you can use a JOptionPane. It is designed to return which button was clicked and then you can do custom processing based on the clicked button. Check out the section from the Swing tutorial on How to Make Dialogs for some examples. Also not that you can add a panel to an option pane. In this case you may find the Dialog Focus tip usefull.
I suppose what you want is for the action (or an action listener) of a button in the parent window to process a mouse click on a button (or anything) in the modal dialog.
There are infinite ways to do that. You can pass the action to the modal dialog, pass the button and call doClick(), pass an implementation of an interface that can redirect mouse click (or anything), etc.
Or if instead you want to click the actual button in the parent window when the modal dialog is up, look up the definition of modal.

Categories

Resources