Letting user set default save directory via textfield - java

Im aware that there are better ways, but I need to implement it like this for this application. Its supposed to be a practice for properties too.
I bound a textProperty defaultDir from textfield inside a setDefaultDir Dialog, with the method FileChooser.setInitialDirectory(new File(defaultDir.get())); inside of my Save Dialog.
The binding itself works fine, I tested it by simply calling a printline of defaultDir right before calling setInitialDirectory(). So the problem must lie with how I input the text in my textfield.
I could not find anything on this online, usually I dont have problems googling stuff but I didnt find anything that would help me out. Since the binding seems to be working just fine, how does the user have to format the Directory in the textfield for this to work? My "C:/User/Jonas/Documents" didnt work
Thanks in advance

Related

tHashInput showing error but cant see anything in component, only can see in java code

Good day,
In my tHashInput, I saw the component having the error sign, as follow:
I click on the component tab, try to figure out what is the error, however, I cant see anything inside.
But if I view it in java code, I can see where is the error, as follow:
Maybe previous developer want to put comment or print it, but make some mistake there.
May I know how can I comment this line? Java code is just for view only not editable right? Any way I can find in the Component tab for this sentence String?
I am new to Talend and first day working on Talend Studio.
you have to right click on the component then click on option Desactivate thashinput
Other information you need to know after , the tHashInput component must be intialized by a tHashOutput COmponent

Can't change LaF JMenu "buttons"

As I'm modifying an existing Look and Feel, I also want to change how the "buttons" of a PopUpMenu behave. Right now it behaves like this, when I hover my mouse over it. As you can see it behaves very "3D":
And I want to let it behave like the buttons I made below them:
I've looked trough alot of documentation of Java Swing but I can't seem to find it. So if someone knows, please help me out. I have tried to change every property I could find.
The correct answer here is, as I found out, not everything can be managed by the LaF. Therefore, sometimes you have to get your hands dirty.
In this case I created my own CSTMButton, because in Swing one is also able to add buttons to a menubar. Now I can create it's own listener to generate the behaviour I want.

android setEnabled but unchange text

I have some edit text fields which I would like to make un-editable at certain times. I have used the setEnabled method but that also grays out the text. Is there a way to toggle whether the field can be edited but not change the appearance of the text? It has been a little while since I last messed with Android but I think I used to be able to use setEditable which did exactly what I am looking for.
I have tried to use the android:focusable="false" but I am still able to edit the field, unless that is only the behavior of the emulator I don't think that will work.
You can disable input for an EditText without any visible indication by setting it's input type to InputType.TYPE_NULL. An example would look like:
import android.text.InputType;
. . .
myEditText..setInputType(InputType.TYPE_NULL);
Note that this behavior doesn't exactly jive with what the reference docs seem to be saying and that there doesn't appear to be an XML equivalent.

JComboBox staying open

I have written a GUI which has many different JComboBoxes. All of them work as I would expect (I click on them, the popup appears, I click on my selection, and the popup closes).
All of them, that is, except for one.
I have looked at my code, and I am using this combo box in the same way as I am using others. I am sure that there is something that I am missing, but I do not know what.
I do not know where to start. What kind of thing should I look at in my code to figure this out? If you were to try to achieve this, what would you do, this info might help.
As a code sample, I have not done anything out of the ordinary:
JComboBox selectionBox = new JComboBox();
selectionBox.addItem(DEFAULT_SELECTION);
selectionBox.addItem("Option1");
selectionBox.addItem("Option2");
selectionBox.addActionListener(this);
Although I understand that it isn't always possible to give a lot of details, an exact answer just isn't possible without more exact information.
That said, I think the best course of action is to examine the code very carefully and make sure that an error cannot be found that could be causing the JComboBox to stay open.
As a LAST resort, you may be able to fix the problem by using JComboBox's hidePopup() method to manually close out of the JComboBox:
yourComboBox.hidePopup();
P.S. As for not knowing where to start ... if, in general, you're having trouble finding errors in your code, https://softwareengineering.stackexchange.com/ might be a good place for that sort of question.

Added tab completion to JFileChooser's File Name inputer

How can I add linux like tab completion to jFileChooser's File Name input field? I'm assuming I need to add a listener to the File Name's text input box to listen for the tab key. But I don't know how to do that. Then once a tab key is hit, I need to look at the directory for files/dir that start with what was inputted. Any ideas on how I can go about doing this?
Emm... I am not pretty sure what the question is but if you want to control is the textfield does contain a file name or something you can simply use JFileChooser as a panel and, as I may remember, there is a way to show/not show its components like "open"/"save"/etc buttons and, of course, replace them with your own; so there should be a way to control its input field I guess. So you need to play around UIManager
For more information you can read this , this and this
If it is not the point... so I still hope you configure your question in a more detailed manner because it is quite unclear :)
Good luck

Categories

Resources