jcheckbox

Checkbox in only one JTable Cell

为君一笑 提交于 2019-12-02 12:23:11
I want to create an JTable with 2 columns, which looks like a survey. So on the left are the questions and on the right the user can give his answers. But in one line there should be a Checkbox on the right side, so that the user only can answer with yes or no. Is this possible to do with an JTable , and how can I achieve this? regards You have stated in a comment: I tried it with a column of JCheckboxes it works but I just want it in one cell Note this requirement is a little tricky. I think you can override getCellRenderer(int row, int column) and getCellEditor(int row, int column) methods

JTable with editable checkbox

房东的猫 提交于 2019-12-02 10:41:27
问题 The below code is one of my project class.It produce a frame with JTable when I click find button some data will load to table dynamically.The last column of table must be checkbox with event. I tried this code for checkbox (took it from another project..its not working) DefaultTableModel dtm = new DefaultTableModel(data, colName){ public Class getColumnClass(int c) { return (c == 5? Boolean.class : String.class); } }; Actual class public class BookReturnPanel { JPanel retunBookPanel;

JTable with editable checkbox

一曲冷凌霜 提交于 2019-12-02 05:55:33
The below code is one of my project class.It produce a frame with JTable when I click find button some data will load to table dynamically.The last column of table must be checkbox with event. I tried this code for checkbox (took it from another project..its not working) DefaultTableModel dtm = new DefaultTableModel(data, colName){ public Class getColumnClass(int c) { return (c == 5? Boolean.class : String.class); } }; Actual class public class BookReturnPanel { JPanel retunBookPanel; JTextField txtRegNo; JButton btnFind, btnSave; JTable retunTable = null; public JScrollPane jScrollPane = null

Swing JTree with Checkbox and JFileChooser

好久不见. 提交于 2019-12-02 03:33:17
问题 By using JFileChooser I am able to select file and folders getting JList with File Objects and I am showing it with checkbox. Now my requirement is like I want to show the selected file and folder in tree structure with checkbox and the checkbox should be only for root elements not for all child elements. Example : For Example, I selected folders ABC and PQR which containt sub folders and few files now on UI It should be display Checkbox1 ABC-- --SubFolders . --SubFolder . --Files --Files

Swing JTree with Checkbox and JFileChooser

孤街浪徒 提交于 2019-12-02 02:57:29
By using JFileChooser I am able to select file and folders getting JList with File Objects and I am showing it with checkbox. Now my requirement is like I want to show the selected file and folder in tree structure with checkbox and the checkbox should be only for root elements not for all child elements. Example : For Example, I selected folders ABC and PQR which containt sub folders and few files now on UI It should be display Checkbox1 ABC-- --SubFolders . --SubFolder . --Files --Files Checkbox2 PQR-- --SubFolders . --SubFolder . --Files --Files Sounds a bit complicated... as far as the

Checkbox within a JXTreeTable

自作多情 提交于 2019-12-02 02:32:12
问题 Still a Java newbie here, trying to stuff far too advanced for my own good. Nevertheless, here's what I need done: A checkbox within a JXTreeTable. My main class: package info.chrismcgee.sky.production; import info.chrismcgee.sky.production.treetable.NoRootTreeTableModel; import java.awt.Checkbox; import java.awt.Dimension; import java.awt.EventQueue; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import

Question on jtable cell editors in swing

∥☆過路亽.° 提交于 2019-12-02 00:51:13
I want to implement a component that serves as a list of options, that a user can choose to select or not. Visually I thought that it would be best presented in a UI (if there is a better approach please tell me) as follows: Anyway, I thought that this could be implemented via a JTable (single column) and using a JCheckBox as a cell editor. I tried it but did not work. Example of code: public class ListRenderer extends JFrame { JCheckBox checkbox = new JCheckBox("Test"); DefaultCellEditor dce1 = new DefaultCellEditor(checkbox); public ListRenderer(){ Object[][] data = { {"Test"} }; String[]

Align icon and JCheckbox in JPopupmenu

僤鯓⒐⒋嵵緔 提交于 2019-12-01 20:12:08
I have a Problem with some icons and check-boxes in a JPopupMenu . The Check-boxes and Icons are not aligned The Items are created like: JMenuItem deleteAttributeMenuItem = new JMenuItem(locale.getString("TREE_AttrDelete"), iconDelete); JMenuItem primaryKeyAttributeMenuItem = new JCheckBoxMenuItem(locale.getString("TREE_AttrChkBoxPK")); Please take a look at the picture: Any tips? Have a look at this, in order to achieve what you wanted, I did this, JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Check Me", null, true); cbmi.setMargin(new java.awt.Insets(5, 25, 5, 5)); cbmi.setIconTextGap(15);

Using icons with JCheckBox

走远了吗. 提交于 2019-12-01 15:48:23
问题 I have a swing application in which I want to use a JCheckbox with an icon. I constructed the icon as follows: JCheckBox unsubmit = new JCheckBox("Unsubmit",applet.undo); When I do this, the label and the icon appear in my GUI but the box itself is no where to be found. If I construct the JCheckBox without the icon, the box comes back. I've tried adjusting the buttons's preferred size but it had no effect. Anyone know what's going on here? Thanks, Elliott 回答1: The Icon is being used in place

Change JCheckBox/JRadioButton selection color

ぐ巨炮叔叔 提交于 2019-11-30 23:17:55
Is there a way to change the selection color of a checkbox/radiobutton? Here is how to do it for a JCheckBox UIManager.put("CheckBox.focus",Color.RED); There is a nice tool here: http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/ that if you run the Java Web Start program it will allow you to browse the keys and values for each component. 来源: https://stackoverflow.com/questions/4607107/change-jcheckbox-jradiobutton-selection-color