Change or denie Cursor Style change of requestFocus in Textfields - java

From my understanding, the requestFocus Method from the component class, does set the Cursor Style while hovering over a TextItem. (The One looking like an I)
The application i am working with, does run in two different modes.
The first mode is the normal application mode, and the cursor is free to change.
The other on the help mode. It does contain a normal Cursor with a questionmark next to it.
In this mode the Cursor is not allowed to change when hovering over any textItem, since it wont create any input.
Is there any way to denie the Cursor change from happening, or to change the Default Cursor of a textitem temporarly?

Just set the Cursor of the TextField like this:
textField.setCursor(Cursor.getPredefinedCursor(Cursor.CUSTOM_CURSOR));

Related

JavaFX: Change cursor in Textarea

I have a Textarea which I use to output status logs. I dont want the user to be able to put text in it, so i set editable to false. I also want the cursor to be the normal arrow-cursor, but that doesnt work.
I tried to set the cursor of the textarea but this did not work.
textArea.setCursor(Cursor.DEFAULT);
It still shows the usual text area cursor when hovering the text area and not the standard arrow cursor. What am I missing?
The reason why the solution doesn't work is answered here.
If CSS is not the option for you try this approach:
textArea.setId("idTextArea");// you can set also control id in fxml file
textArea.getScene().lookup("#idTextArea .content").setCursor(Cursor.DEFAULT);
Make sure that Scene object is initialized before running the code.

Input Text fields don't move cursor on mouse click?

I have an issue with all of my Input Text fields, maybe someone has an idea:
I'm using GWT, and just discovered that the text in of my Input Fields cannot be selected using Mouse. Also clicking inside the text does not move the cursor.
But giving them Focus using the cursor works. Selecting all with CTRL+A as well as moving the cursor with Arrow Keys works as expected.
I inspected the TextBox specific onBrowserEvents() method and can see, that click events are received well. Just somehow they don't modify the text input control in the browser.
I tested different machines and different browsers, which all behave the same. So it must be something in my Application.
Maybe somebody has an idea what I could have done wrong? I can't even imagine anything that could produce this behaviour on all of my input fields.
It just turned out to be a CSS issue:
I had -moz-user-select: -moz-none; to prevent doubleclick issues for some of my components. I now excluded the input element from it and everything works fine again.
I use this to solve the problem with selecting text and moving the cursor on the text in the inputs:
*, ::before, ::after
-webkit-user-select: text

set text cursor in text field, Java

I have two text fields, and text_field2 text_fiel1. when the program is run directly to the text cursor automatically text_field1. I want to ask how can I make the text cursor when the program is run automatically in text_field2 not in text_cursor1???
requestFocus() method of JTextfield will do.
look at this http://www.java2s.com/Code/JavaAPI/javax.swing/JTextFieldrequestFocus.htm

Java swing "working in background" mouse cursor

Is there a built in cursor that will show the "arrow plus hourglass" mouse pointer that is used when windows is working in the background, yet still allowing you to click on things?
I know about WAIT_CURSOR, but I don't see anything like this. Do I need to make a custom cursor to get the hourglass-pointer combo?
I don't see a built-in cursor that does this. All the pre-defined cursors reside here:
http://download.oracle.com/javase/7/docs/api/java/awt/Cursor.html
as you may well know.
You will need to create a custom cursor or find someone who has already done this. Here's a website showing you how to build your own custom cursor:
http://blog.codebeach.com/2008/02/using-custom-cursors-in-java.html
Goodluck

Getting the Java Swing 'No Drag' Cursor

Is it possible to get a reference to Swing "no Drag "Cursor ,since it is OS Specific, or maybe override it
I think you might be looking for the DragSource class which has bunch of predefined cursors.
I would look into java.awt.Toolkit::createCustomCursor if you want a cursor that is not predefined in java.awt.Cursor
public Cursor createCustomCursor(Image cursor,
Point hotSpot,
String name);
From the Java 6 Documentation:
Creates a new custom cursor object. If the image to display is invalid, the cursor will be hidden (made completely transparent), and the hotspot will be set to (0, 0).
Note that multi-frame images are invalid and may cause this method to hang.

Categories

Resources