Is there any way to disable the textfield of a JComboBox? - java

I know that JComboBox has three components which are textfield, arrow button and the drop down menu.
My task is that disable the textfied so only the button is shown and when clicking the button we can see the dropdown menu.
Is it possible to do that?

"Dropdown only" is the default behavior. The text field only appears if you set the combo box to be editable.
http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html

Related

How to bind to action for radio button in install4j

I'm using install4j in order to create installation wizard.
I have a radio button group that contains 2 different button, in case of selecting the second button i would like to show on the same page some addition fields, while selecting the first one i would like to hide them.
User input, Variable name: test.radio
Radio button labels: radio1;radio2
Is there any possible way to bind to which radio button is selected and perform a "hide & show" operation for some text fields?
Use "Single radio button" form components instead of the "Radio button group" form component. In the configuration panel of those form components there is a "Coupled form components" tab that allows you to hide or show other form components depending on whether the radio button is selected.

jPanel shows empty tooltip text

I have a few radio buttons and then a checkbox, I have tooltip's for the radio buttons but not the checkbox. Which works okay, unless I get a radio to display it's tool tip text and then quickly move to the checkbox, before the tip disappears, and now I have my mouse on the checkbox but it is displaying the tooltip for the previously moused over radio button.
I tried setting a blank ("") tool tip for the checkbox, which works okay except that it displayed a very small tooltip square.
Is there anyway to either force the previous tooltip to go away or to properly set a nothing tooltip for the checkbox?
radioButtonsetText("text");
radioButton.setToolTipText("tooltip text");
checkBox.setText("text");
checkBox.setToolTipText("");
or to properly set a nothing tooltip for the checkbox?
Components don't have a tooltip by default. So don't set the tooltip and your won't have a problem.
If you set the text and want to remove it the try using:
component.setToolTipText(null);

How to open Combo Box popup in javafx

I want to show combo box popup while click or hover on any label(component) instade of combo box and I don't know how to trigger combo box popup panel.
comboBox.show()
Requests that the ComboBox display the popup aspect of the user interface. As mentioned in the ComboBoxBase class javadoc, what is actually shown when this method is called is undefined, but commonly it is some form of popup or dialog window.

Checkbox in Jtable with Dialog

Q: I have implemented jtable with checkbox in it now when user click on particular checkbox dialog gets opened where user can add more information to the selected item
now if user does click close button in dialog then i need to uncheck the selected item from jtable ?
Note :i am opening dialog through setValueAt method of class which extends AbstractTableModel?
How can i workaround this problem?
I have implemented jtable with checkbox in it now when user click on particular checkbox dialog gets opened
Instead of using a check box you can use a JButton as a renderer. Then when you click on the button the dialog will display. Then you don't need to worry about resetting the checkbox.
See Table Button Column for more information.

Keeping selection after clicking a JButton to style text

I'm making a fairly simple text editor, and I have a question about my style buttons. When I highlight text and click my "bold" button, the text bolds as expected, but my selection is not longer visible. I can still unbold the selection, italicize it, or underline it, but you just can't see what is selected. So, I'm wondering if there is a setting that will allow me to click the button, but keep my selection? I tried a JMenuItem instead of a JButton, and that seemed to work, but then it made my toolbar look quite bad. Sample code below.
//frame and pane creation up here
JToolBar tool = new JToolBar();
JToggleButton boldButton = new JToggleButton("Bold");
boldButton.addActionListener(new StyledEditorKit.BoldAction());
tool.add(boldButton);
Any help is appreciated.
So, I'm wondering if there is a setting that will allow me to click the button, but keep my selection?
boldButton.setFocusable( false );
As you noticed, the selection is still there but clicking on the toolbar button removes the focus from the text pane and hides the selection. You need to set the focus back using requestFocus. However, you will need to write your own action listener to add the focus code - you could extend BoldAction to do this.

Categories