jcheckbox

How to create a JTree with JCheckbox to Show Systems All drives and its Folders/Files

ε祈祈猫儿з 提交于 2019-12-11 12:47:22
问题 I am beginner in java. I am creating a file chooser that can select multiple drives, folders or files at a time for worm scanning purpose. I have written the code to work fine for a single drive (e.g. c:\ or e:\ etc). I am trying to create a tree for all drives in system. Please tell me how to accomplish this. Code import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; import java.io.File; import java.util.Collections; import java.util.Vector; public class FileTreeDemo {

Setting the color for a JCheckBox cell in a JTable

北战南征 提交于 2019-12-11 10:00:03
问题 I have a JCheckBox working in the last column in a JTable. But when I set the color to the cells in that column, it seem to overwrite the rendered object (JCheckBox). The snippet of code below is what I am trying to do: //Overriding these methods using the DefaultTableModel constructor works . DefaultTableModel model = new DefaultTableModel(data, columnNames) { @Override public Class getColumnClass(int col) { return getValueAt(1, col).getClass(); } @Override public boolean isCellEditable(int

Creating dcheckbox dynamically in Java-NetBeans

浪子不回头ぞ 提交于 2019-12-11 09:54:51
问题 I am developing a simple "To-do List" application which involves obtaining 'things to do' for a particular day from the database and displaying them as checkbox text on a panel resting on a frame.There is a button "done" which can be used to remove the ticked checkboxes after a task is complete. The code that I used for the dynamic creation of the checkboxes is shown below: //cnt-variable used to store the number of tasks for a day //rs1-ResultSet variable into which the task description is

JCheckBoxMenuItem only one selected

纵饮孤独 提交于 2019-12-11 06:40:54
问题 So I want to have a JMenu Level with three JCheckBoxMenuItem like Easy, normal and expert. Of course, only one can be checked and if one is checked, it can't be unchecked (enabled(false)) because it's the only one. I want when one JCheck is checked, all others are unchecked. So it seems easy, but the only solution I found is to do it with a lot of "if" conditions. Is there a way to do it with a better algorithm ? 回答1: It sounds like you'd be better off using a JRadioButton since check boxes

Implementation of switch case for check box

我怕爱的太早我们不能终老 提交于 2019-12-11 06:38:54
问题 Is there any way to implement switch case for checkbox? Example: I have 4 checkboxes, if I selected 2 checkboxes, how to trigger the case to the output I want? double exam = 0.0, assign = 0.0, quiz = 0.0, ct = 0.0; if (examchkbox.isSelected()) { exam = Double.parseDouble(examtextfield.getText()); } if(ctchkbox.isSelected()) { ct = Double.parseDouble(cttextfield.getText()); } if(quizchkbox.isSelected()) { quiz = Double.parseDouble(quiztextfield.getText()); } if(asschkbox.isSelected()) { assign

Delete checkboxes in swings

南楼画角 提交于 2019-12-11 06:02:57
问题 i am doing one project related to swings in this i am facing one problem like some 5 check boxes are there in this if i delete two non immediate check boxes (or) single check box i am able to delete but if i delete two immediate check boxes i am not able to delete i.e i have check boxes like 1,2,3,4,5 if i delete 1 and 3 , 1 and 4 , or 3 and 5 etc... (or) 1,2,3 etc.. if i delete using this combination i am able to delete but if i delete 1 and 2 or 2 and 3 or 4 and 5 like immediate check boxes

how to create jcombobox with jcheck box and multiple selection

被刻印的时光 ゝ 提交于 2019-12-08 00:33:19
问题 I want to create JComboBox with checkboxes and multiple selection . i have created a list with check box after rendering the jlist . I dont know how to render it with jcombobox . Or is it possible to make jlist as drop down list like combo box . for jlist rendering i am using the following code DefaultListModel listModel = new DefaultListModel(); ListCheckBox li= new ListCheckBox(listModel); JScrollPane jsp= new JScrollPane(li); add(jsp); listModel.add(0,new JCheckBox("Other Court"));

Dynamically create jCheckBox and add to a jScrollPane

心已入冬 提交于 2019-12-07 02:34:11
问题 EDIT: Using the solutions presented below, I have changed the code to have a JPanel inside a JScrollPane. Using a JButton i add JCheckBoxes to the JPanel inside the JScrollPane. This was one problem solved, as the a JScrollPanecan only take one JComponent. The rest of the issues were solved setting a gridlayout to the JPanel inside JScrollPane. I have kept my original question here for the sake of posterity: ORIGINAL QUESTION: I'm trying to dynamically create JCheckBox and add them to a

How do I add a JCheckBox to DefaultTableModel by adding a Boolean column?

我的未来我决定 提交于 2019-12-06 21:54:29
I am trying to add a jcheckbox to the first column of a JTable, which uses a DefaultTableModel . I tried returning a Boolean.class for that column, but it doesn't work. I already have a jcombobox in the last column, but using the same method I used to add that in order to add a jcheckbox doesn't work. I read online that java automatically returns a checkbox for you if you render a Boolean.class in a column, but using it also doesn't work. I think this might be a problem in the way I am ordering the components. //import statements. public class CourseSelection extends GUIDesign implements

JTree rendering with JCheckBox nodes

孤街浪徒 提交于 2019-12-06 19:16:51
问题 I am attempting to modify the standard Swing JTree to intermingle nodes with and without checkboxes. This is an example: When I attempt to check/uncheck one of the checkboxes (the 'User 01' node in this example), the tree loses nodes: I my code is an adaptation of this example: http://forums.sun.com/thread.jspa?threadID=5321084&start=13. Instead of embedding a JCheckBox in a DefaultMutableTreeNode like this: new DefaultMutableTreeNode(new CheckBoxNode("Accessibility", true)); I thought it