jcheckbox

JTable - Checkbox add action listener

回眸只為那壹抹淺笑 提交于 2020-05-27 11:49:06
问题 I've created a simple JTable with check box like below: DefaultTableModel model = new DefaultTableModel(); jTable1.setModel(model); model.addColumn("No:", no1); model.addColumn("Remark", remark1); model.addColumn("Color", colors1); model.addColumn("Done"); TableColumn col1 = jTable1.getColumnModel().getColumn(0); col1.setPreferredWidth(1); TableColumn col4 = jTable1.getColumnModel().getColumn(3); col4.setCellEditor(jTable1.getDefaultEditor(Boolean.class)); col4.setCellRenderer(jTable1

JTable - Checkbox add action listener

≯℡__Kan透↙ 提交于 2020-05-27 11:49:04
问题 I've created a simple JTable with check box like below: DefaultTableModel model = new DefaultTableModel(); jTable1.setModel(model); model.addColumn("No:", no1); model.addColumn("Remark", remark1); model.addColumn("Color", colors1); model.addColumn("Done"); TableColumn col1 = jTable1.getColumnModel().getColumn(0); col1.setPreferredWidth(1); TableColumn col4 = jTable1.getColumnModel().getColumn(3); col4.setCellEditor(jTable1.getDefaultEditor(Boolean.class)); col4.setCellRenderer(jTable1

Make JCheckbox bigger..?

拟墨画扇 提交于 2020-01-24 09:11:46
问题 i want to make my JCheckboxes in a JTable bigger (for Touchscreen), but it doesn't change the size. I tried it with setPrefferedSize setSize What should I do?.. 回答1: I assume you mean you want a bigger check box. If so then you need to create images to represent the unselected and selected icons of the check box. Then you can create a renderer and editor using these icons. Finally you would need to increase the height of each row in the table. The code might look something like: Icon normal =

Components in JList are Hidden by White Square Thing Until Clicked

痞子三分冷 提交于 2020-01-16 16:50:24
问题 In a project I've been working on, I noticed that all the JList items in my JScrollPane are hidden until the JScrollPane/JList has been clicked. The weird part is it's not completely covered. There's this white box with a transparent border that spreads out over the whole thing, covering all but a few pixels on all edges. Pictures: As you can see, there is this white block in the middle - notice the pink "border": Now, once I click that white box, it goes away: I know the magenta looks

Question on jtable cell editors in swing

好久不见. 提交于 2020-01-11 11:13: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

Question on jtable cell editors in swing

六眼飞鱼酱① 提交于 2020-01-11 11:12:30
问题 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

How do I write superscript word for checkbox text in java?

南楼画角 提交于 2020-01-09 11:48:54
问题 I made few checkboxes using swing in Java. I want to write a superscript text for the checkboxes but I'm not sure how. The code currently looks like this. JCheckBox hCheckBox = new JCheckBox("[M + H]+"); I want to have "+" sign inside the JCheckBox parameter superscripted. What's an easy way to do this? Thank you in advance. 回答1: Java buttons support html in their text. You need to format the string a little differently though. Try this: JCheckBox hCheckBox = new JCheckBox("<html>[M + H]<sup>

Get all selected index of Checkbox

六月ゝ 毕业季﹏ 提交于 2020-01-07 05:46:06
问题 I am a beginner to Java Swing. I have a table with 3 columns. The first column has only check boxes. I wanted to get the index of all the selected items of the check box and store it in an ArrayList . How can I accomplish this? 回答1: have a look at this, http://www.java2s.com/Code/Java/Swing-JFC/SwingCheckBoxDemo.htm If you want to return all selected items, you can use List or Set for this. Post the code what you have. I may assist... 回答2: As you use a JTable you are using a TableCellRenderer

EmptyBorder around JCheckBox becomes visible when checkbox selected

回眸只為那壹抹淺笑 提交于 2020-01-07 02:32:07
问题 I've set an EmptyBorder around my JCheckBox (for the purpose of indenting it, but that doesn't really matter). When I select (or deselect) my JCheckBox , the border gets drawn around it as a dashed black line. I don't want to even see this border at all. How do I keep it invisible? Here is my (simplified) code: JPanel myPanel = new JPanel(); JCheckBox myCB = new JCheckBox("hello"); myPanel.add(myCB); myCB.setBorder( new EmptyBorder( 2, 15, 2, 2 ) ); 回答1: the border gets drawn around it as a

I want to display a message showing what I selected (Java)

只谈情不闲聊 提交于 2020-01-06 03:08:04
问题 I'm doing a project (something like a restaurant) for collage, and I'm not very good in Java (they didn't really try to teach us). The principle of the project is to show a message saying what radio buttons and check boxes I've selected. I have 5 radio buttons, they are for selecting a meal, and 5 check boxes for selecting a side dish. I've managed to have the radio buttons work but I don't know how to make the check boxes work... This is the code for the radio buttons (this goes for all 5):