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.
Related
I am using a bare bones JFileChooser on Redhat 6 with the code:
JFileChooser testFileChooser = new JFileChooser("Test");
testFileChooser.showOpenDialog(this);
The JFileChooser works as expected. In the file selection area, if I right click, I get a dialog with three rows, one with an arrow. There is no text describing what the rows does. The first row switches between list and detail views. The second row appears to do nothing and the third row creates a new folder. When I googled about this problem there appears to be no way to access or inspect this right-click popup dialog of the JFileChooser. I do not understand how it could break in the first place like this. I need ideas for how to fix or workaround this problem please.
I've found a fix/workaround!
JFileChooser uses a FilePane internally, which uses the JFileChooser's getComponentPopupMenu as it's context menu. However, because that returns null, it creates its own.
The text on the labels are gotten from the UIManager, with UIManager.getString calls. For some reason, the UIManager is returning empty strings.
So, we just have to set the strings in the UIManager manually.
If you make these calls before creating the file chooser, that'll fix it.
UIManager.put("FileChooser.detailsViewActionLabelText", "Details");
UIManager.put("FileChooser.listViewActionLabelText", "List");
UIManager.put("FileChooser.viewMenuLabelText", "View");
UIManager.put("FileChooser.refreshActionLabelText", "Refresh"));
UIManager.put("FileChooser.newFolderActionLabelText", "New Folder");
I realize this is 4 years late, but I hope this helps.
Im working with SWT StyledText to display data to the user in one part of the window. In another part I have a graph, over which I slide my mouse pointer. As I slide my mouse over a point in the graph, it highlights the corresponding entry in the StyledText Area.
I want my textArea to automatically scroll to the newest change, so I am using .setTopIndex().
To determine the index I need to be able to look at which entries in the textArea changed from not highlighted to highligted, I use the following (to check if my styleRange changed):
styledText.getStyleRangeAtOffset(offset)
So far my program functions correctly. My next check is:
styledText.getStyleRangeAtOffset(offset).isUnstyled
or
styledText.getStyleRangeAtOffset(offset).foreground
or something like that. Here enters the problem. When I call any of these I get a nullPointerException.
Thank you for all the pointers :) after some debugging I discovered that the unedited styleRange is null. That explains the nullPointer I kept on receiving
In JFrame Form I have added a jTextArea and added a text into it, while still in design mode. But when I run the form I want the text to be invisible, which is not happening. I checked the properties of the JTextArea but I am not really sure how to change the visiblity of the text..
For clearing the JTextArea filed you need to set its text as empty.
For this you need to see JTextArea#setText as null or "".Try this code at the execution of your application.
jTerxtAreaObject.setText("");
Set the color of the text as the same color as the background.
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
I'm trying to make it so when I tab to some text fields on in my JFrame the data in the text field will be highlighted. I thought I had done this in the properties before but I am not seeing the option now. Does anyone know how to do this?
You could use a FocusListener to work out when your field has focus (tutorial here).
Decide whether you want to select the text in the field, or whether you just want to change the background color. It's not quite clear what you mean by highlight.