Help how hide all system menu from JInternalFrame. (not super("title", false, false, false, false);) but completely remove button (in Numbs LookandFeel).
Try this:
JInternalFrame.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
Make sure that close button is invisible:
JInternalFrame.setClosable(false);
Related
I found on Stackoverflow something like that about checking when dialog is visible:
onView(withText("Yes"))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.perform(click());
Of course this works if Dialog with button 'yes' is visible, but in different scenario, if dialog will be invisible I got crash:
android.support.test.espresso.NoMatchingViewException: No views in
hierarchy found matching: with text: is "Yes"
So how to write that if the dialog exists, click yes, and if it does not exist, then nothing will be clicked?
You could try this:
onView(withText("Yes")).inRoot(isDialog()).withFailureHandler(new FailureHandler() {
#Override
public void handle(Throwable error, Matcher<View> viewMatcher){
}
}).check(matches(isDisplayed())).perform(customClick());
//if dialog is visible, perform click, otherwise do nothing.
I want to create a menu using TextButton. The menu should be accessible by mouse and keyboard. For the correct hovering behaviour, I set the style as usual:
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.up = skin.newDrawable("background", Color.GRAY);
textButtonStyle.down = skin.newDrawable("background", Color.DARK_GRAY);
textButtonStyle.checked = skin.newDrawable("background", Color.DARK_GRAY);
textButtonStyle.over = skin.newDrawable("background", Color.LIGHT_GRAY);
textButtonStyle.font = skin.getFont("default");
This works fine with mouse (the over style is toggled when the mouse is hovering). However, I want to be able to select a menu item by keyboard. The "currently selected" menu item should be selectable using the arrow keys and enter should confirm the item.
The keyboard interaction is not an issue here, but setting the "highlighted" mode on the button. I imagine selecting a button using the keyboard should behave the same as hovering over it with a mouse. But it looks like there is no way of "toggling" the state of the button using the API. There is an isOver() method, but no setOver() method.
Any ideas? Do I really have to create two styles and switch them out with setStyle()? I would consider that ugly..
Create a custom class for your actor and override your isOver method to return isFocused || super.isOver()
By the way, you might take a look at https://github.com/MrStahlfelge/gdx-controllerutils/wiki/Button-operable-Scene2d for not reinventing the wheel.
If you wish to programmatically make the button think that it has been hovered upon, send an InputEvent with type enter which signifies that the mouse has entered onto the button:
InputEvent event = new InputEvent();
event.setType(InputEvent.Type.enter);
event.setPointer(-1);
button.fire(event);
Use the exit InputEvent for defocusing it:
InputEvent event = new InputEvent();
event.setType(InputEvent.Type.exit);
event.setPointer(-1);
button.fire(event);
So basically, the easiest what you can do is just to retrieve the desired button style right from your skin and apply this to the button like this:
Skin skin = getYourSkin(); // or even button.getSkin() I believe should also work
button.setStyle(skin.get(styleName, ButtonStyle.class));
This way you don't need to create a style but you can just get it from your skin definition
I was having some problem when trying to check and uncheck radio button upon click.
What I am trying to do is, when the activity on load, the radio button is set to checked by default. When user pressed on the checked radio button, I set the radio button to uncheck and empty the textview. Then, when the user pressed on the radio button again, I set it to checked and set some text in textview. Here is my code:
#Click(R.id.radioButtonEmail)
void radioButtonEmailClicked(View v) {
if(radioButtonEmail.isChecked() == true){
radioButtonEmail.setChecked(false);
editTextEmail.setText("");
}else {
radioButtonEmail.setChecked(true);
editTextEmail.setText("TEST");
}
}
However, this only worked for the first time when I tried to uncheck the radio button. After I set it to false, when I try to check it again, it does not work. Any ideas? Thanks!
I don't have an exact explanation for the behavior you are seeing, but your logic looks off to me. I think you intend to do this:
#Click(R.id.radioButtonEmail)
void radioButtonEmailClicked(View v) {
if (radioButtonEmail.isChecked()) {
editTextEmail.setText("");
}
else {
editTextEmail.setText("TEST");
}
}
In other words, you don't manage whether the radio button is clicked from your event handler. Rather, you check for that state inside the handler, and then respond appropriately.
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'm making a program that requires this jdialog box to always be focused and on top, ie: make the ding sound when i click on the parent window. here's what i have so far:
JDialog dialog = new JDialog();
// dialog.setAlwaysOnTop(true);
dialog.setSize(400, 220);
dialog.setLocationRelativeTo(relativeTo); //relativeTo is the name of parent frame
dialog.setVisible(true);
// dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
// dialog.setModal(true);
(the commented things are those i have tried unsuccessfully...)
how would i make this dialog box ontop of the parent window? any help would be great! thanks
You need to set the dialog's owner and make the dialog modal:
JDialog dialog = new JDialog(parentFrame, true); // owner, modal