jcheckbox

Java Swing: Need a good quality developed JTree with checkboxes

大憨熊 提交于 2019-12-28 03:04:44
问题 I was looking for a a JTree implementation, that contains checkboxes and which: When you select one node, all its successors in the tree are automatically selected When you unselect one node, all its successors in the tree are automatically unselected When a parent node is already selected, and the selection was removed from one of its successors, the node color will be changed, to make it intuitive that although this parent node is selected, not all of its successors are selected (Like when

Getting checkbox values on clicking the button in swings [closed]

你离开我真会死。 提交于 2019-12-25 18:17:53
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I need a small code in java for the following scenario: Button should get the selected checkboxes and executing the code for those checkboxes in my form. 回答1: Here is an example I made for you: import java.awt

Java: JCheckBox won't stay checked with ItemListener

≯℡__Kan透↙ 提交于 2019-12-25 08:48:51
问题 Ok, I'm new to listeners (still learning the language), and this is my first full-scale attempt to implement them (ie more than just a practice problem in a textbook). So far, everything is working fine except one big bug: the checkboxes don't stay checked. The ItemListener I assign them runs perfectly (I have a JOptionPane set up to trigger to let me know if it's working or not), but the box itself doesn't stay checked. I went even further and added conditional logic for if it's state is

Custom Java ListCellRenderer - Can't click JCheckBox

穿精又带淫゛_ 提交于 2019-12-25 04:53:56
问题 Made a custom ListCellRenderer: import java.awt.Component; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListCellRenderer; /** * * @author Spencer */ public class TaskRenderer implements ListCellRenderer { private Task task; private JPanel panel = new JPanel(); private JCheckBox checkbox = new JCheckBox(); private JLabel label = new JLabel(); public TaskRenderer() { panel.add(checkbox); panel.add(label); }

How to Reset the check state and uncheck state of Menuitems for Multiple documents using swing

假如想象 提交于 2019-12-23 04:27:03
问题 I want to Reset the state of checkboxMenuItems.For example I create More than one Document then add some text to recently opened document and select LineNumbers then I go to previos opened Document at that time the linenumbers checkbox is reset to original state that is unselect state whether I select it in "check state" in another Dcoument.please help me.Thank you. Here is code: import javax.swing.JInternalFrame; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax

Trouble with JCheckBox checked toggle logic in a JList in Java

你离开我真会死。 提交于 2019-12-22 11:10:16
问题 Hi I am having trouble with toggling a check box that is in a JList, I wish for when an item is clicked to have the check box tick, and if it is ticked again i want it to toggle to unticked. I want to have it possible to have multiple items to be ticked or unticked without the use of the ctrl or shift keys. public class CustCellRenderer extends JCheckBox implements ListCellRenderer { boolean selected = false; void CustCellRenderer() { setOpaque(true); setIconTextGap(12); } // allows a custom

How to prevent JPopUpMenu disappearing when checking checkboxes in it?

妖精的绣舞 提交于 2019-12-20 14:20:13
问题 I want to use JCheckBoxMenuItem s in a JPopupMenu . It works, but the problem is that the popup menu disappears when a checkbox item has been checked or unchecked. So if one wants to check/uncheck several items, the popup needs to be launched repeatedly, which is irritating. Curiously, if I use just plain JCheckBox items in the menu (instead of JCheckBoxMenuItem s), the behavior is just as it should be: the popup stays there and the checkboxes can be checked/unchecked. Once done, the popup

Multiple ITEM_STATE_CHANGED events from jcheckbox in jtree

核能气质少年 提交于 2019-12-20 04:28:19
问题 Somebody, explain me, please, how it works. Here is the code: package checkboxtree; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseEvent; import java.util.EventObject; import java.util.Vector; import javax.swing.AbstractCellEditor; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTree;

Java Swing, Trying to replace boolean check-box in a JTable with an image-icon checkbox

喜你入骨 提交于 2019-12-20 03:21:40
问题 So I have a JTable with check-boxes. I would like to have the check-boxes contain one image when they are "checked" and another image when they are "unchecked" (i.e., display images instead of a checked or unchecked box). Is there a way to do this? I've tried fooling with the TableCellRenderer that returns a JLabel with an ImageIcon but it was not really very effective. More specifically, when the box is checked or unchecked the right images are there, but when the user is changing the check

JPanel Action Listener

南笙酒味 提交于 2019-12-20 01:09:49
问题 I have a JPanel with a bunch of different check boxes and text fields, I have a button that's disabled, and needs to be enabled when specific configurations are setup. What I need is a listener on the the whole JPanel looking for events, whenever anything changes. I believe I need an action listener but I can't find anything to bridge the action Listener with the JPanel JPanel Window = new JPanel(); Window.addActionListener(new ActionListener(){ //Check if configurations is good } I figure I