renderer

How to set transparent background for JTree cell?

自作多情 提交于 2019-12-02 03:16:39
Folks, I am trying to create a gradient JTree control. The following code mostly works except that the background for the tree cell is not transparent. I would appreciate it if someone call tell me what is it that I am not doing right. Thank you in advance for your help. Regards, Peter package TestPackage; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import java.awt.*; public class Test { public Test() { JFrame frame = new JFrame(); JPanel framePanel = new JPanel(); framePanel.setLayout(new BorderLayout()); frame

commandButton inactive after ajax rendering

三世轮回 提交于 2019-12-02 01:54:01
I have a problem with these two commandButton : Join and Leave. I want to hide Join if I click on leave and vice-versa. When I put ajax on false, there is no problem (but all the page is refresh and I don't find this optimal). But when ajax attribut is on true with specific updating (cf comment in the code), the rendering is good but the new button whitch appear become inactive. If I click on it, nothing happens (well it's seems the actionListener trigger but the view is not refreshed, I have to manual refresh to see the difference) Thanks for reading. <h:form id="formWaitingList" rendered="#

How to render an image to a JTable cell

情到浓时终转凉″ 提交于 2019-12-01 21:11:10
I want to apply a renderer on a cell of my JTable, to do so I created a class named myRenderer : import java.awt.Component; import javax.swing.ImageIcon; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; public class MyRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, ImageIcon icon) { setIcon(icon); return this; } } And I use this piece of code to apply the renderer on the cell : MyRenderer renderer = new MyRenderer(); renderer.getTableCellRendererComponent(table, icon); table.getColumnModel().getColumn(6)

Dynamically change icon of specific nodes in JTree

廉价感情. 提交于 2019-12-01 20:23:29
问题 I've seen plenty of examples for changing the icon of nodes during tree instantiation, but I'd like a way to dynamically change the icon of an individual node later. So, in my main code I add my custom renderer to my tree: // Icon I want to set nodes to later ImageIcon checkIcon = new ImageIcon("check.jpg"); // Creates tree with my nodes JTree tree = new JTree(nodes.top); // Create custom renderer Scenario1Renderer renderer = new Scenario1Renderer(); // Set to single tree selection tree

Unity Resources.Load<Sprite> vs as Sprite

一个人想着一个人 提交于 2019-12-01 20:16:15
问题 I've tried to change the image of my object with this code (used as Sprite cast): GetComponent<SpriteRenderer>().sprite = Resources.Load("GameObjects/Tiles/Hole") as Sprite; It did not work, however this worked (used <Sprite> ): GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("GameObjects/Tiles/Hole"); What's the difference? 回答1: FunctionR's answer is probably the more common answer, and I may just be wrong here, but I believe the difference between Load() and Load<T>() is that

Dynamically change icon of specific nodes in JTree

风格不统一 提交于 2019-12-01 19:24:08
I've seen plenty of examples for changing the icon of nodes during tree instantiation, but I'd like a way to dynamically change the icon of an individual node later. So, in my main code I add my custom renderer to my tree: // Icon I want to set nodes to later ImageIcon checkIcon = new ImageIcon("check.jpg"); // Creates tree with my nodes JTree tree = new JTree(nodes.top); // Create custom renderer Scenario1Renderer renderer = new Scenario1Renderer(); // Set to single tree selection tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Set tree to my custom

How to change the color of particular cell in JXTreeTable dynamically

▼魔方 西西 提交于 2019-12-01 13:39:38
I am using JXTreeTable for making treetable structure now I want to change the color of specific cell dynamically. How can I change the color of cell? I found this code to change the color, but this is not working. Here is Code: leftTree.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if(Integer.parseInt(rowvalue[0])==row && column==0) { c

Creating a CubeGeometry equivilent using CSS3DRenderer

本秂侑毒 提交于 2019-12-01 12:06:30
I am looking for sample code, that would show how one can create a cube (similar to THREE.CubeGeometry ) in ThreeJS using CSS3DRenderer . Something like below var my_cube = new **CSS3dCubeGeometry**( cube_width, cube_height, cube_depth) var object = new THREE.CSS3DObject( my_cube ); scene.add( object ); THREE.CSS3DObject doesn't exist and I am looking for a potential implementation of it. You can create a cube with CSS3DRenderer like so: // params var r = Math.PI / 2; var d = 50; var pos = [ [ d, 0, 0 ], [ -d, 0, 0 ], [ 0, d, 0 ], [ 0, -d, 0 ], [ 0, 0, d ], [ 0, 0, -d ] ]; var rot = [ [ 0, r,

Overriding JTable's DefaultTableCellRenderer to center all the cells in a JTable

女生的网名这么多〃 提交于 2019-12-01 09:26:37
I've got a problem I can't get rid of. Just so you know, I'm fairly new to using JTables, so the answer might be simple, but I can't find a solution :/ So, I've got a JTable using an AbstractTableModel, which overrides the public Class<?> getColumnClass(int columnIndex_p) method, to tell the type of each column to be displayed. One of them is a Boolean. When I create a simple JTable, using table_l = new JTable(new MyTableModel()); everything is fine, and Boolean values are correctly displayed using checkboxes (on/off). Now, I'd like to center the text on each cell (and, possibly more options

custom cell renderer for particular row and column

假装没事ソ 提交于 2019-12-01 08:56:28
puuuuuuf, I'm starting to like swing :) I'm trying to write a cellRenderer to customy render all cells besides those which in first row and column. So I wrote the following: public class CustomTableCellRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent(table, obj, isSelected, hasFocus, row, column); if(row >0&&column>0){ cell.setBackground(Color.GREEN); } return cell; } } and set the renderer as following: