what's -Dcom.sun.javafx.virtualKeyboard=javafx other values - java

in JAVAFX i want to use windows virtual keyboard instead of JAVAFX virtual keyboard in touch screen whats the true setting or whats the true value to the property
-Dcom.sun.javafx.virtualKeyboard=javafx

If you want to open windows virtual keyboard when user focus on textfield ,you can do that by call osk.exe from the root:
userInputField.setOnMouseClicked(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
String sysroot = System.getenv("SystemRoot");
try {
Process proc = Runtime.getRuntime().exec(sysroot + "/system32/osk.exe");
} catch (IOException ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});

Related

Popup a compulsive window that the user can only interact with by Java Swing

So compulsive window here means like, I currently have interface(1) with a button, I click the button and it gives me a popup. I want this popup to be the only window that the user can interactive, so the user in this case cannot interact with interface(1). Think it like you are saving a Word doc, when you choose the file location to save this Word doc, you cannot modify the content of this Word doc. And that file saving window is what I want.
Currently I have a custom popup:
public class InputPopup {
private int closeflag;
private JFrame popup;
...
public int getCloseflag() {return closeflag;}
public void close(){
System.exit(0);
}
public void run() {
EventQueue.invokeLater(() -> {
try {
popup.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
And this is what I did in the button listener
InputPopup popup = new InputPopup(wordLabel.getText(), description.getText());
popup.run();
int flag = popup.getCloseflag();
while (flag != 1) {
flag = popup.getCloseflag();
}
popup.close();
Of course that does not work. Anyone has any idea on how to achieve that effect?

How do I avoid keypad during Scrolling?

I need to test the button which is below the text box and for that I need to scroll the screen as button is not visible. But when it starts Scrolling the screen,keypad appears (as the text box is editable) and hide the button and stop scrolling down. It happens on my Samsung S4 android phone (version 4.4.4) not on any other android device.
I am using appium (version 1.4.13.1) on my window machine.
try {
ClickShareViaEmailBtn();
if (panelShareObject.ShareTextBtn.isDisplayed()) {
MobileUtils.navigateBack(driver);
return true;
}
return false;
} catch (Throwable e) {
throw e;
}
public void ClickShareViaEmailBtn() throws Throwable {
try {
Thread.sleep(1000);
// Utils.sleep(ShareViaEmail, 20, driver);
// Thread.sleep(1000);
panelShareObject.ShareViaEmail.click();
MobileUtils.swipeDown(driver);
} catch (Throwable e) {
MobileUtils.navigateBack(driver);
throw e;
}
}
If the button is hidden by the keyboard, then you can first hide the keyboard and then click on the button.
Hide Keyboard -
driver.getKeyboard().sendKeys(Keys.RETURN);
or
driver.hideKeyboard();

simulate button click according to jtextfield's changes

I'm facing problem with the simulation of the button click. I have JTextField that takes data from scanner (like in grocery stores). After that i need to push enter button, to activate function jTextField1ActionPerformed. Is there any way to do it without producing any button actions?
Or i need tip how to jButton1.doClick() every time jTextField is changed. Please help!:)
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
AddEmployee.add(jTextField1.getText());
jLabel7.setText(AddEmployee.name);
jLabel12.setText(AddEmployee.dep);
jLabel10.setText(AddEmployee.pos);
jLabel11.setText(AddEmployee.time);
num++;
jName.append("\n"+Integer.toString(num)+". "+AddEmployee.name);
jTime.append("\n"+Integer.toString(num)+". "+AddEmployee.time);
jTextField1.setText("");
}
catch (ClassNotFoundException | SQLException | ParseException ex) {
Logger.getLogger(MainMenu.class.getName()).log(Level.SEVERE, null, ex);
}
}
If you want to simulate the button press, including in the UI, you can call the following method:
myButton.doClick();
This will act as the user physically pressed it. Otherwise, you can create an ActionEvent and pass it to the button's listeners:
// Does not appear in the UI
for(ActionListener a: mybutton.getActionListeners()) {
a.actionPerformed(yourActionEvent);
}
In your case though(considering the code posted) I suggest making a method out of the button's code, and just call it wherever you want:
public void showData(){
try {
AddEmployee.add(jTextField1.getText());
jLabel7.setText(AddEmployee.name);
jLabel12.setText(AddEmployee.dep);
jLabel10.setText(AddEmployee.pos);
jLabel11.setText(AddEmployee.time);
num++;
jName.append("\n"+Integer.toString(num)+". "+AddEmployee.name);
jTime.append("\n"+Integer.toString(num)+". "+AddEmployee.time);
jTextField1.setText("");
}
catch (ClassNotFoundException | SQLException | ParseException ex) {
Logger.getLogger(MainMenu.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void myButtonActionPerformed(java.awt.event.ActionEvent evt) {
showData();
}
private void myOtherComponentEventOcurred(java.awt.event.ActionEvent evt) {
showData();
}

How to programmatically simulate arrow key presses in Java FX

I want to make my JFX application simulate arrow key presses (when they are registered in a TextField), but I can't figure out how to send anything other than Strings or bytes.
I'm imagining something like this:
static EventHandler<KeyEvent> KEY() {
E = new EventHandler<KeyEvent>() {
#Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.UP)) {
try {
//someObject.SimulateKeyPress(KeyCode.UP);
//OR
//coolObject.SendKey((char)KEY_UPKEY));
} catch (Exception ex) {
//Teleport goats
}
}
}
};
return E;
}
Use the class Robot
try {
Robot r = new Robot();
//there are other methods such as positioning mouse and mouseclicks etc.
r.keyPress(java.awt.event.KeyEvent.VK_UP);
r.keyRelease(java.awt.event.KeyEvent.VK_UP);
} catch (AWTException e) {
//Teleport penguins
}
You cannot instantiate the type Robot.
You should rather do :
Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();

Codename One - Video Capture

Am using codename one to capture the video and upload it to Vimeo.
But I get errors when I click the button. What am I doing wrong ?
I get below error when the method is called.
I have a camera
java.lang.NullPointerException
at userclasses.StateMachine$1.actionPerformed(StateMachine.java:63)
protected void onMain_Button1Action(Component c, ActionEvent event) {
Capture.captureVideo(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if(Capture.hasCamera()){
System.out.println("I have a camera");
}else{
System.out.println("I don't have a camera");
}
try {
String path = (String) evt.getSource();
Log.p("Path->" + path);
Vimeo.MyVimeo(path);
is.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
}
The event can be null if the operation is canceled.
You are not meant to select a file, The capture class is for capturing media files from the device. It brings out FileChooser if you are using the emulator, therefore test it on a device and see how it works.

Categories

Resources