I am creating a JFace MessageDialog
MessageDialog md = new MessageDialog(null, "Title", null,
"Body message", SWT.YES | SWT.NO, new String[] { Messages.yes, Messages.no }, 0);
On one Windows 7 machine when this dialog is opened, it doesn't show its body/dialog area until user presses the Enter key and only title bar is displayed without body. Moreover its position is left bottom corner of the screen. While on pressing the Enter key it opens the dialog in a proper manner and user can see the "Body message" and Yes No buttons on it.
Is it related to some windows or java setting on that machine?
Related
I am making an android game and i set my SystemUiVisibility with the setSystemUiVisibility to not show the top bar and other system ui's, but now when u die in game i want to show an AlertDialog with the score you have. When i show the AlertDialog it brings the SystemUiVisibility back and i dont want to have that happen. Does someone know how to fix that. Here is the code i am using right now for the AlertDialog:
dlgAlert.setMessage("You lost, you hit the right color " + Points + " times");
dlgAlert.setTitle("You died");
dlgAlert.setPositiveButton("OK", null);
dlgAlert.create().show();
Make the Dialog non-focusable when we create it (so we don't trigger a user-interaction) and then make it focusable after it's displayed.
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
//Show the dialog!
dialog.show();
//Set the dialog to immersive
dialog.getWindow().getDecorView().setSystemUiVisibility(
context.getWindow().getDecorView().getSystemUiVisibility());
//Clear the not focusable flag from the window
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
My Code is like this
//Clicking on 'imageRepository' Button opens New Tab.
action.perform(imageRepository, Actions.Click, "",
"Click on Image repository button");
ElementsAction.callMeToWait(10000);
ArrayList<String> newTab = new ArrayList<String>(driver.getWindowHandles());
newTab.remove(oldTab);
// change focus to new tab
driver.switchTo().window(newTab.get(0));
selectImage(imageXml);
//After Selecting image Clicking on 'ImageRepositoryPageAddItemButton' closes the new opened tab and automatically gets back to old tab.
clickImageRepositoryPageAddItemButton();
//back to old tab
driver.switchTo().window(oldTab);
}
Now my the driver is not getting focused to old tab. It only waits and perform no action on old tab. How to make driver to focus on old tab?
How do you change the button text of FileDialog (not JFileChooser)? The two modes specify the button text:
FileDialog.LOAD -> "Open"
FileDialog.SAVE -> "Save"
But I want the button to say something else. Is it possible to change this text?
You cant change button text only with FileDialog methods, the only text you can edit in it is window's title which opens when you press for example "Open".
FileDialog fd = new FileDialog(FdExample.this, "select File", FileDialog.LOAD);
fd.setTitle("any new title");
If you want custom text in button, you can use JButton and ActionListener to activate FileDialog.
Probably this will be the best way.
FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(),SWT.SAVE);
I am showing a list with messages and each message's row has a comment button.When i click on comment button opens a comment box with edit text and button for submitting the comment.When comment box appears on screen keypad also appears for entering text.If i pressed home button before entering text then application goes background but keypad remains on screen.This is the thing irritating me.For custom list i am using a custom adapter and code for comment box is written in that adapter.I tried using
inputmgr.hideSoftInputFromWindow(txtComments.getWindowToken(), 0);
but it is not working. So how i can hide this keypad programmatically.
Try using the code in https://stackoverflow.com/a/1109108/1904479. Hope you are not testing it in Android version 4.1.
please use this method to hide soft keyboard.
public static void hideSoftKeyboard(Activity context) {
InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputManager != null)
inputManager.hideSoftInputFromWindow(context.getWindow().getDecorView().getApplicationWindowToken(), 0);
context.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
KeyEvent.KEYCODE_HOME can NOT be intercepted. You can hide the keypad inputmgr.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0); in onStop() method of your activity.
It does not require token from focused view editText.
In my app, I have a dialog with EditText. I have coded it in such a way that as soon as the dialog shows up,the soft keyboard shows up, the edit text will get focus , all the existing text in the editText is preselected. And user can start typing. This all works fine when I am holding my phone in portrait orientation. But the same thing does not work when I have phone in landscape orientation. Part of my code in my fragment is pasted below.
final EditText inputDeviceId = new EditText(getActivity());
inputDeviceId.setInputType(InputType.TYPE_CLASS_TEXT);
String savedDevId = getDeviceID();
inputDeviceId.setText(savedDevId);
inputDeviceId.setSelectAllOnFocus(true);
// some more code ... to create dialog , ok cancel buttons then,
final AlertDialog alertDialog = alertDialogBuilder.create();
inputDeviceId.setOnFocusChangeListener(new View.OnFocusChangeListener() {
if(hasFocus){
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
});
alertDialog.show();
Now this all works in portrait orientation and does not work in landscape.
In landscape mode the dialog with edittext shows up , it has focus and existing text is preselected but it does not show the keyboard. User has to click in the editText for keyboard to come up. Why? I am using nexus-5 to test.