swingbuilder

Groovy SwingBuilder : button to change the color of a panel

别来无恙 提交于 2019-12-04 17:33:47
Why does this code fail ? I want to change the color of one panel in a series of several panels, dynamically constructed (total number of panels not known beforehand). For some reason, this code works when referencing the name of a particular panel (for example 'panel2'), but not when I refer to it dynamically ('panelID'). import groovy.swing.SwingBuilder import javax.swing.WindowConstants as WC import javax.swing.JOptionPane import javax.swing.BoxLayout as BXL swing = new SwingBuilder() frame = swing.frame(title:'test', defaultCloseOperation:WC.DISPOSE_ON_CLOSE) { panel(id:'mainPanel'){ def

How to add JComboBox to a specific cell in the JTable

故事扮演 提交于 2019-11-29 12:42:17
I want to change defaultCellEditor to JComboBox only when a specific cell in a table is selected. Override the getCellEditor(...) method of JTable to return the appropriate editor. Something like: import java.awt.*; import java.awt.event.*; import java.util.List; import java.util.ArrayList; import javax.swing.*; import javax.swing.table.*; public class TableComboBoxByRow extends JFrame { List<TableCellEditor> editors = new ArrayList<TableCellEditor>(3); public TableComboBoxByRow() { // Create the editors to be used for each row String[] items1 = { "Red", "Blue", "Green" }; JComboBox comboBox1

How to add JComboBox to a specific cell in the JTable

被刻印的时光 ゝ 提交于 2019-11-28 06:25:26
问题 I want to change defaultCellEditor to JComboBox only when a specific cell in a table is selected. 回答1: Override the getCellEditor(...) method of JTable to return the appropriate editor. Something like: import java.awt.*; import java.awt.event.*; import java.util.List; import java.util.ArrayList; import javax.swing.*; import javax.swing.table.*; public class TableComboBoxByRow extends JFrame { List<TableCellEditor> editors = new ArrayList<TableCellEditor>(3); public TableComboBoxByRow() { //