I have checkboxes. I have a buttongroup. When I click on the option "All Checkboxes," I want all checkboxes in the button group to be made unselectable (grayed out) (Except the "All Checkboxes" one which is selected.) How do I this?
Also, how can I add an item/set the items to a Combo Box using NetBeans?
I have checkboxes. I have a buttongroup. When I click on the option "All Checkboxes," I want all checkboxes in the button group to be made unselectable (grayed out) (Except the "All Checkboxes" one which is selected.) How do I this?
A ButtonGroup cannot be used to grey-out (functionally and visibly disable) a JCheckBox. Better to put them in a List<JCheckBox> and in the ActionListener for "All CheckBoxes" iterate through calling setEnabled(true/false) on the items in the list, the parameter depending on the state of the "All Checkboxes" JCheckBox.
Also, how can I add an item/set the items to a Combo Box using NetBeans?
I have no idea how to do this "using NetBeans", but using Swing you simply get the JComboBox's model, usually a DefaultComboBoxModel, and add items to it.
Also, how can I add an item/set the items to a Combo Box using NetBeans?
Just like you would with Swing normally, comboBox.setModel(comboBoxModel). Don't rely on the form editor to do it for you. Somethings you just have to get your hands dirty with.
Related
I am kinda new to JavaFX, so maybe this is very easy to do. I have a ListView<String>, and what I want is that I can have a button which when pressed, basically turns the selected String into a sort of text field in which you can edit the name of that specific item. I hope it is clear what I want. I already tried list.setEditable(true), but that didn't change anything.
In addition to making the ListView editable you also need to make sure to use a cellFactory providing editable cells:
list.setEditable(true);
list.setCellFactory(TextFieldListCell.forListView());
This way you can start a edit on a double click of a cell.
First, I'd use in this case a VBox filled with the TextFields. Those TextFields should have the editable property set to false. When you click on the button, you can call:
((TextField)vbox.getChildren().get(numberofTextFieldInList)).setEditable(true);
and now it should be editable. If you want the TextFields to look like Strings when not being editable, I would modify the aesthetic properties.
I have an SWT combo box in my GUI. Is it possible to check if the combo box has been opened?
(I've a mechanism which refreshes the state shown in the combo box, when a user opens it sometimes it jumps between user selection and that what the algorithm thinks is fine, the user selection has a priority over everything else).
Combo SWT component have method getListVisible() which returns flag if combo dropdown list part is visible or not.. see documentation for combo for details.
The response of Sorceror is about org.eclipse.swt.widgets.Combo
If you need this method on javax.swing.JComboBox you can use isPopupVisible()
I am wondering if it's possible to change the default radio button menu item appearance in Java Swing.
By default a circle with a dot inside will indicate the selected state of the button, but i just want the good old fashioned tick next to a selected menu item and nothing to be shown next to an item that is not selected. (All items in question are of type JRadioButtonMenuItem)
I tried to use .setSelectedIcon(...) which can be found here :
http://docs.oracle.com/javase/7/docs/api/javax/swing/AbstractButton.html#setSelectedIcon(javax.swing.Icon)
But nothing changed, no exceptions thrown and im still stuck with the default appearance.
Any ideas?
Instead of using a JRadioButtonMenuItem, you could use JCheckBoxMenuItem which has a tick mark by default. JCheckBoxMenuItems can also belong to a ButtonGroup also giving you single selection behavior shown by JRadioButtonMenuItem.
Example
Is there a way to make radio buttons do nothing when they are clicked? I am trying to make a Score Board and need a way to show the periods/halves/quarters ect. The radio buttons will be selected by the program to display periods/halves/quarters ect. Is this a good way to do it or is there a better way?
Check out the clickable attribute for Views
Defines whether this view reacts to click events.
Must be a boolean value, either "true" or "false".
http://developer.android.com/reference/android/view/View.html#attr_android:clickable
If the user doesn't ever need to click the radio buttons (ie if its always controlled by the program), why don't you just use images instead of radio buttons.
The benefits of using images for this are...
Images aren't clickable by default
It'll look nicer (you can make the Images look like a real scoreboard)
It doesn't rely on the default Android appearance (which is different for each phone)
I have a UI with a Combo box. The list of items, which can be chosen, has to be refreshed every time the combo is about to open the list.
Is there any way - i.e. to add a listener which will inform UI that Combo is about to open?
Unfortunately I am not able to observe model to update the list when it changes.
Unfortunatelly there is no such method for SWT Components. In Swing it would be easy with the help of the PopupMenuListener Interface.
A workaround I can think of would be to implement a MouseListener and a KeyboardListener (As Comboboxes can be opened by pressing 'space') so you can at least update your Combobox List when those two Events take place.