Swing shows empty tooltips, how to disable this? - java

I'm creating a java Swing app and I'm new to that.
The problem is that when I move cursor to menu item, for example, it shows me an empty tooltip.
Is there any way to disable this?
P.S. Using NetBeans, if it's important. Maybe it generated some odd code?

Go to the properties of the menu or menu item that displays the empty tooltip and choose tooltip. Then add "null" as a String value for setTooltipText. The empty tooltip will then dissapear.
If the toolTipText property in the designer is bold (changed), you can just press the Reset to Default button at the bottom of the above window, or even right-click on said property in the list and select Restore Default Value.

I guess you're using the (now dead) Swing Application Framework. Netbeans automatically generates an entry in the properties file associated with each panel for the tooltip, with an empty value (instead of not generating the property at all if you leave the text box blank). Just remove the property in the properties file manually.
The lines looking like the following should be removed:
someAction.shortDescription=

Related

Disabling JavaFX ComboBox input

How do I disable input on my editable Combobox? (Well, actually JFoenix JFXCombobox but it's basically the same apart from it's appearance)
setEditable(false) would disable keyboard input on the Combobox but the list would still appear
setDisabled(true) would disable whole Combobox but I want user to be able to focus Combobox so he can copy it's contents if necessery.
Why do I want it like that? In my forms user must first click edit button to be able to change stuff.
Basically, the method ComboBox.setEditable adds/removes an Editor to the ComboBox which can be retrieved via ComboBox.getEditor()
To keep the TextField (to copy from) but disable user-input, simply set the editable flag on the underlying TextField:
private ComboBox<String> myComboBox;
[...]
myComboBox.setEditable(true);
myComboBox.getEditor().setEditable(false);
EDIT:
As #jewelsea said in a comment below, you can hide the list as soon as the user requests to open it:
myComboBox.setOnShown(event -> comboBox.hide());
I think it would be "cleaner" to disable the button which opens the dropdown but unfortunately I have not yet found a way to do that.

In Intellij Idea, how to keep showing context information?

I know for sure that by clicking hot key alt + q, the context of current method or class could show up just like:
But is there any way to make the IDE keep showing the context information at the top of the edit area?
You can't keep the method definition for the 'currently active' method pinned to the top of the editor but if your goal is to display the method definition for the 'currently active' method while you are editing that method then you could use the Structure tool window and select Autoscroll from source. This will show you the definition of the method you are currently editing / your cursor is currently sitting in.
Here's a screenshot:
Autoscroll from source is the last icon on the right at the top of the Structure tool window.
You can activate the Structure tool window via keystokes (e.g. ALT 7), to identify the correct keystroke just have a look at the keystroke associated with the menu item: View > Tool Windows > Structure.
More details in the docs

Making a editable form in java netbeans

How can I design a editable form as in detail of a person by clicking edit button and edit the respective fields of person's details and save it on the same place where they are shown.
eg.
Full Name : JTextField1
Address: JTextField2
and so on...
Now What I want is to save those values on respective places and when I want to edit them then show editable textfield with same values displayed.
Are there any API's or plugins to do it or should I just have to do as setVisible(true/false) for necessary action to perform??
If you are using JavaFX, you can use setEditable(boolean), which will disable or enable the field for editing. You can also use setDisabled(boolean) to disable the field for anything other than viewing.
If you are using Swing/AWT, you can use setEditable(boolean) as well as setEnabled(boolean) to do the same as JavaFX.
Since you are using Swing/Awt, use setEditable to disable or enable the fields when you press the Edit button. :)

Bizzare JFileChooser situation, the right click menu text is blank

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.

JCheckBoxes inside JComboBox

I have added checkboxes inside combo box in Java. But when I open drop down menu and check one check box, the drop down menu closes. So to select each check box I have to open it every time.
Is there any way so that I can keep the drop down list opened till the time I dont click outside so that I can select any number of check boxes at one time only.
Please help!!
I have added checkboxes inside combo box in Java. But when I open drop
down menu and check one check box, the drop down menu closes. So to
select each check box I have to open it every time. Is there any way
so that I can keep the drop down list opened till the time I dont
click outside so that I can select any number of check boxes at one
time only.
no there isn't, this is default property of (BasicXxx)Popup implemented in Swing API, workaround for series of Bugs in Java1.4_xxx
no_way, only by using dirty hacks, usage of can be Java Version sensitive, or required left mouse button as accelerator
don't do that, another way (and proper of possible ways) is usage of JWindow/undecorated JDialog but required to override ESC Key and Focus lost in Windows three (as you can see in good Java JCalandars/JDatePickers),
I recommend that you to use the Japura API to deal with this, check this link:
http://www.japura.org/checkcombobox
Best Regards :)

Categories

Resources