cellrenderer

JTree TreeCellRenderer raising issue on showing the selection color

天大地大妈咪最大 提交于 2020-01-14 16:47:28
问题 I am using this below piece of code: class CountryTreeCellRenderer implements TreeCellRenderer { private JLabel label; CountryTreeCellRenderer() { label = new JLabel(); } public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Object o = ((DefaultMutableTreeNode) value).getUserObject(); if (o instanceof Country) { Country country = (Country) o; label.setIcon(new ImageIcon(country.getFlagIcon()));

Cell Renderer for JTable - coloured rows

半腔热情 提交于 2019-12-31 03:48:08
问题 I've been looking around for a solution to this and I can't make head nor tail from various places of how to get my table to do coloured rows without asking my own question. From every place I've looked I gather I need to use a cell renderer but the problem is I don't know how to apply it to my own situation. So I have a simple JTable with 3 columns and I simply want each row to be highlighted in either green, yellow or red depending on the value of a separate variable (not displayed in the

AS3 disable editable/selectable for textInput inside of a Datagrid

我们两清 提交于 2019-12-22 05:26:10
问题 I am currently trying to disable the selectable / editable / or change the textInput to dynamic to get my desired result. I've got a custom datagrid with dropdowns and text input areas. However, if there is no data in my Model # column, I do not want to allow for any entry in the corresponding PurchasePrice cell. col1 = new DataGridColumn("Model"); col1.headerText = "Model #"; c2.consumables_dg.addColumn(col1); col1.width = 60; col1.editable = false; col1.sortable = false; col1.cellRenderer =

How to let the content in JComboBox display in the center?

依然范特西╮ 提交于 2019-12-21 09:10:41
问题 Currently I have this JComboBox , how can I get to center the content inside it? String[] strs = new String[]{"15158133110", "15158133124", "15158133458"}; JComboBox com = new JComboBox(strs); 回答1: You need to create a Renderer then apply it to the JComboBox DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER); com.setRenderer(dlcr); also import this, import javax.swing.DefaultListCellRenderer; 回答2: ((JLabel)jComboBox1

How to set icon in a column of JTable?

只谈情不闲聊 提交于 2019-12-17 06:51:53
问题 I am able to set the column's header but not able to set icon in all the rows of first column of JTable. public class iconRenderer extends DefaultTableCellRenderer{ public Component getTableCellRendererComponent(JTable table,Object obj,boolean isSelected,boolean hasFocus,int row,int column){ imageicon i=(imageicon)obj; if(obj==i) setIcon(i.imageIcon); setBorder(UIManager.getBorder("TableHeader.cellBorder")); setHorizontalAlignment(JLabel.CENTER); return this; } } public class imageicon{

Set cellrenderertext foreground color when a row is highlighted

僤鯓⒐⒋嵵緔 提交于 2019-12-13 14:27:23
问题 When I have a gtk.CellRendererText , I can associate its foreground color with one of the tree store's columns, and set the foreground-set attribute to True, to change the color of the text in that column. However, when the row with the colored column is selected, its color disappears, and is the same as any selected cell's color. How do I change the color when it's selected? 回答1: I've had the same problem and, after trying different alternatives, using the markup property instead of the text

Changing font color on a column in treeview gtk

一笑奈何 提交于 2019-12-13 04:25:12
问题 I've a treeview and I want to change the text color on one column. How could I do this?? thanks 回答1: (Refering to the standard C methods, haven't done much with Vala so far) There are several ways to achieve this. You can change the settings of the text cellrenderer (GtkCellRendererText), an example would be g_object_set (your_text_cell_renderer, "foreground", "red", "foreground-set", TRUE); Another way is using markup: highlighted_txt = g_strconcat ("<span background='yellow' foreground=

Why do cell renderers often extend JLabel?

让人想犯罪 __ 提交于 2019-12-12 08:33:40
问题 I noticed this is common. For example DefaultListCellRenderer, DefaultTableCellRenderer, and DefaultTreeCellRenderer all use it. Also a lot of the custom cell renderers I see online use this as well. I want to use a custom TableCellRenderer in my code, but I'm confused about whether I really need to subclass JLabel. What's the benefit of subclassing JLabel? 回答1: The API for the DefaultTableCellRenderer states: The table class defines a single cell renderer and uses it as a as a rubber-stamp

Highlight cell when row is selected

风格不统一 提交于 2019-12-12 00:15:06
问题 The problem I am having is that when I select a row, the cell with a custom cell renderer doesn't highlight that cell but does the other cells. public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { setFont(ApplicationStyles.TABLE_FONT); if (value != null) { BigDecimal decimalValue = toBigDecimal(value); decimalValue = decimalValue.setScale(2, BigDecimal.ROUND_HALF_EVEN); DecimalFormat formatter = new

Rendering a component into an ExtJS grid

扶醉桌前 提交于 2019-12-11 12:54:44
问题 I want to render a split button into a column in a grid to perform actions on each row. I can't seem to figure out how to build a custom cell renderer that will accomplish this. Each cell will have the exact same split button, but will act on the id of the row the split button is in. 回答1: You need to setup a custom renderer for the column, have a look at this example: http://techmix.net/blog/2010/11/25/add-button-to-extjs-gridpanel-cell-using-renderer/ 来源: https://stackoverflow.com/questions